From b366318b9326b34300ccfc9aa488be779e56b0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Tue, 28 May 2019 18:13:46 +0200 Subject: [PATCH 01/26] [poc] add documentation and related tests --- .ci/doc/config.yml | 47 ++++ .ci/doc/eslint.json | 236 ++++++++++++++++++ .ci/doc/puppeteer.js | 38 +++ .ci/doc/templates/blank.tpl.js | 14 ++ .ci/doc/templates/catch.tpl.js | 31 +++ .ci/doc/templates/controller.tpl.js | 11 + .../createDocumentAfterSnippet.tpl.js | 27 ++ .ci/doc/templates/default.tpl.html | 12 + .ci/doc/templates/default.tpl.js | 27 ++ .ci/doc/templates/doIt.tpl.js | 5 + .ci/doc/templates/empty-realtime.tpl.js | 23 ++ .ci/doc/templates/empty.tpl.js | 3 + .ci/doc/templates/eventemitter.tpl.js | 6 + .ci/doc/templates/mqtt-end.tpl.js | 4 + .ci/doc/templates/realtime.tpl.js | 47 ++++ .ci/doc/templates/success.tpl.js | 32 +++ .ci/doc/templates/thencatch.tpl.js | 28 +++ .ci/doc/templates/without-connect.tpl.js | 22 ++ .ci/doc/webpackBuild.js | 53 ++++ .ci/docker-compose.yml | 105 +++++++- .ci/start_kuzzle.sh | 2 +- .travis.yml | 8 + doc/src/controllers/auth/check-token/index.md | 38 +++ .../auth/check-token/snippets/check-token.js | 19 ++ .../check-token/snippets/check-token.test.yml | 11 + .../auth/create-my-credentials/index.md | 41 +++ .../snippets/create-my-credentials.js | 11 + .../snippets/create-my-credentials.test.yml | 10 + .../auth/credentials-exist/index.md | 39 +++ .../snippets/credentials-exist.js | 13 + .../snippets/credentials-exist.test.yml | 10 + .../auth/delete-my-credentials/index.md | 43 ++++ .../snippets/delete-my-credentials.js | 13 + .../snippets/delete-my-credentials.test.yml | 10 + .../auth/get-current-user/index.md | 38 +++ .../snippets/get-current-user.js | 23 ++ .../snippets/get-current-user.test.yml | 10 + .../auth/get-my-credentials/index.md | 44 ++++ .../snippets/get-my-credentials.js | 15 ++ .../snippets/get-my-credentials.test.yml | 10 + .../controllers/auth/get-my-rights/index.md | 46 ++++ .../get-my-rights/snippets/get-my-rights.js | 19 ++ .../snippets/get-my-rights.test.yml | 10 + .../controllers/auth/get-strategies/index.md | 38 +++ .../get-strategies/snippets/get-strategies.js | 15 ++ .../snippets/get-strategies.test.yml | 10 + doc/src/controllers/auth/index.md | 6 + doc/src/controllers/auth/login/index.md | 43 ++++ .../controllers/auth/login/snippets/login.js | 12 + .../auth/login/snippets/login.test.yml | 11 + doc/src/controllers/auth/logout/index.md | 22 ++ .../auth/logout/snippets/logout.js | 11 + .../auth/logout/snippets/logout.test.yml | 10 + .../auth/update-my-credentials/index.md | 41 +++ .../snippets/update-my-credentials.js | 18 ++ .../snippets/update-my-credentials.test.yml | 10 + doc/src/controllers/auth/update-self/index.md | 41 +++ .../auth/update-self/snippets/update-self.js | 24 ++ .../update-self/snippets/update-self.test.yml | 10 + .../auth/validate-my-credentials/index.md | 42 ++++ .../snippets/validate-my-credentials.js | 13 + .../snippets/validate-my-credentials.test.yml | 10 + doc/src/controllers/bulk/import/index.md | 85 +++++++ .../bulk/import/snippets/import.js | 30 +++ .../bulk/import/snippets/import.test.yml | 13 + doc/src/controllers/bulk/index.md | 6 + .../controllers/collection/create/index.md | 67 +++++ .../collection/create/snippets/create.js | 19 ++ .../create/snippets/create.test.yml | 10 + .../collection/delete-specifications/index.md | 40 +++ .../snippets/delete-specifications.js | 7 + .../snippets/delete-specifications.test.yml | 10 + .../controllers/collection/exists/index.md | 40 +++ .../collection/exists/snippets/exists.js | 9 + .../exists/snippets/exists.test.yml | 10 + .../collection/get-mapping/index.md | 40 +++ .../get-mapping/snippets/get-mapping.js | 21 ++ .../get-mapping/snippets/get-mapping.test.yml | 10 + .../collection/get-specifications/index.md | 40 +++ .../snippets/get-specifications.js | 23 ++ .../snippets/get-specifications.test.yml | 9 + doc/src/controllers/collection/index.md | 6 + doc/src/controllers/collection/list/index.md | 56 +++++ .../collection/list/snippets/list.js | 18 ++ .../collection/list/snippets/list.test.yml | 10 + .../collection/search-specifications/index.md | 70 ++++++ .../snippets/search-specifications.js | 47 ++++ .../snippets/search-specifications.test.yml | 24 ++ .../controllers/collection/truncate/index.md | 40 +++ .../collection/truncate/snippets/truncate.js | 7 + .../truncate/snippets/truncate.test.yml | 10 + .../collection/update-mapping/index.md | 62 +++++ .../update-mapping/snippets/update-mapping.js | 13 + .../snippets/update-mapping.test.yml | 10 + .../collection/update-specifications/index.md | 58 +++++ .../snippets/update-specifications.js | 25 ++ .../snippets/update-specifications.test.yml | 10 + .../validate-specifications/index.md | 66 +++++ .../snippets/validate-specifications.js | 29 +++ .../snippets/validate-specifications.test.yml | 10 + doc/src/controllers/document/count/index.md | 43 ++++ .../document/count/snippets/count.js | 15 ++ .../document/count/snippets/count.test.yml | 22 ++ doc/src/controllers/document/create/index.md | 51 ++++ .../document/create/snippets/create.js | 33 +++ .../document/create/snippets/create.test.yml | 14 ++ .../document/createOrReplace/index.md | 49 ++++ .../snippets/create-or-replace.js | 33 +++ .../snippets/create-or-replace.test.yml | 14 ++ doc/src/controllers/document/delete/index.md | 42 ++++ .../document/delete/snippets/delete.js | 9 + .../document/delete/snippets/delete.test.yml | 15 ++ .../document/deleteByQuery/index.md | 44 ++++ .../deleteByQuery/snippets/delete-by-query.js | 15 ++ .../snippets/delete-by-query.test.yml | 24 ++ doc/src/controllers/document/get/index.md | 37 +++ .../controllers/document/get/snippets/get.js | 30 +++ .../document/get/snippets/get.test.yml | 14 ++ doc/src/controllers/document/index.md | 8 + doc/src/controllers/document/mCreate/index.md | 47 ++++ .../document/mCreate/snippets/m-create.js | 78 ++++++ .../mCreate/snippets/m-create.test.yml | 14 ++ .../document/mCreateOrReplace/index.md | 47 ++++ .../snippets/m-create-or-replace.js | 80 ++++++ .../snippets/m-create-or-replace.test.yml | 14 ++ doc/src/controllers/document/mDelete/index.md | 44 ++++ .../document/mDelete/snippets/m-delete.js | 14 ++ .../mDelete/snippets/m-delete.test.yml | 14 ++ doc/src/controllers/document/mGet/index.md | 46 ++++ .../document/mGet/snippets/m-get.js | 61 +++++ .../document/mGet/snippets/m-get.test.yml | 14 ++ .../controllers/document/mReplace/index.md | 47 ++++ .../document/mReplace/snippets/m-replace.js | 64 +++++ .../mReplace/snippets/m-replace.test.yml | 14 ++ doc/src/controllers/document/mUpdate/index.md | 52 ++++ .../document/mUpdate/snippets/m-update.js | 51 ++++ .../mUpdate/snippets/m-update.test.yml | 14 ++ doc/src/controllers/document/replace/index.md | 47 ++++ .../document/replace/snippets/replace.js | 36 +++ .../replace/snippets/replace.test.yml | 13 + doc/src/controllers/document/search/index.md | 61 +++++ .../document/search/snippets/search.js | 61 +++++ .../document/search/snippets/search.test.yml | 13 + doc/src/controllers/document/update/index.md | 45 ++++ .../document/update/snippets/update.js | 27 ++ .../document/update/snippets/update.test.yml | 14 ++ .../controllers/document/validate/index.md | 43 ++++ .../document/validate/snippets/validate.js | 13 + .../validate/snippets/validate.test.yml | 14 ++ doc/src/controllers/index.md | 7 + doc/src/controllers/index/create/index.md | 44 ++++ .../index/create/snippets/create.js | 12 + .../index/create/snippets/create.test.yml | 12 + doc/src/controllers/index/delete/index.md | 39 +++ .../index/delete/snippets/delete.js | 7 + .../index/delete/snippets/delete.test.yml | 11 + doc/src/controllers/index/exists/index.md | 39 +++ .../index/exists/snippets/exists.js | 11 + .../index/exists/snippets/exists.test.yml | 11 + .../index/get-auto-refresh/index.md | 49 ++++ .../snippets/getAutoRefresh.js | 7 + .../snippets/getAutoRefresh.test.yml | 11 + doc/src/controllers/index/index.md | 6 + doc/src/controllers/index/list/index.md | 38 +++ .../controllers/index/list/snippets/list.js | 11 + .../index/list/snippets/list.test.yml | 14 ++ doc/src/controllers/index/m-delete/index.md | 39 +++ .../index/m-delete/snippets/mDelete.js | 11 + .../index/m-delete/snippets/mDelete.test.yml | 13 + .../index/refresh-internal/index.md | 49 ++++ .../snippets/refreshInternal.js | 9 + .../snippets/refreshInternal.test.yml | 11 + doc/src/controllers/index/refresh/index.md | 52 ++++ .../index/refresh/snippets/refresh.js | 11 + .../index/refresh/snippets/refresh.test.yml | 11 + .../index/set-auto-refresh/index.md | 50 ++++ .../snippets/setAutoRefresh.js | 9 + .../snippets/setAutoRefresh.test.yml | 13 + doc/src/controllers/ms/append/index.md | 41 +++ .../controllers/ms/append/snippets/append.js | 10 + .../ms/append/snippets/append.test.yml | 9 + doc/src/controllers/ms/bitcount/index.md | 42 ++++ .../ms/bitcount/snippets/bitcount.js | 11 + .../ms/bitcount/snippets/bitcount.test.yml | 11 + doc/src/controllers/ms/bitop/index.md | 42 ++++ .../controllers/ms/bitop/snippets/bitop.js | 11 + .../ms/bitop/snippets/bitop.test.yml | 9 + doc/src/controllers/ms/bitpos/index.md | 43 ++++ .../controllers/ms/bitpos/snippets/bitpos.js | 8 + .../ms/bitpos/snippets/bitpos.test.yml | 9 + doc/src/controllers/ms/dbsize/index.md | 39 +++ .../controllers/ms/dbsize/snippets/dbsize.js | 6 + .../ms/dbsize/snippets/dbsize.test.yml | 9 + doc/src/controllers/ms/decr/index.md | 40 +++ doc/src/controllers/ms/decr/snippets/decr.js | 8 + .../ms/decr/snippets/decr.test.yml | 9 + doc/src/controllers/ms/decrby/index.md | 41 +++ .../controllers/ms/decrby/snippets/decrby.js | 8 + .../ms/decrby/snippets/decrby.test.yml | 9 + doc/src/controllers/ms/del/index.md | 40 +++ doc/src/controllers/ms/del/snippets/del.js | 15 ++ .../controllers/ms/del/snippets/del.test.yml | 9 + doc/src/controllers/ms/exists/index.md | 40 +++ .../controllers/ms/exists/snippets/exists.js | 13 + .../ms/exists/snippets/exists.test.yml | 11 + doc/src/controllers/ms/expire/index.md | 41 +++ .../controllers/ms/expire/snippets/expire.js | 13 + .../ms/expire/snippets/expire.test.yml | 11 + doc/src/controllers/ms/expireat/index.md | 41 +++ .../ms/expireat/snippets/expireat.js | 14 ++ .../ms/expireat/snippets/expireat.test.yml | 11 + doc/src/controllers/ms/flushdb/index.md | 39 +++ .../ms/flushdb/snippets/flushdb.js | 6 + .../ms/flushdb/snippets/flushdb.test.yml | 9 + doc/src/controllers/ms/geoadd/index.md | 51 ++++ .../controllers/ms/geoadd/snippets/geoadd.js | 19 ++ .../ms/geoadd/snippets/geoadd.test.yml | 9 + doc/src/controllers/ms/geodist/index.md | 45 ++++ .../ms/geodist/snippets/geodist.js | 28 +++ .../ms/geodist/snippets/geodist.test.yml | 11 + doc/src/controllers/ms/geohash/index.md | 41 +++ .../ms/geohash/snippets/geohash.js | 20 ++ .../ms/geohash/snippets/geohash.test.yml | 9 + doc/src/controllers/ms/geopos/index.md | 41 +++ .../controllers/ms/geopos/snippets/geopos.js | 24 ++ .../ms/geopos/snippets/geopos.test.yml | 11 + doc/src/controllers/ms/georadius/index.md | 56 +++++ .../ms/georadius/snippets/georadius.js | 61 +++++ .../ms/georadius/snippets/georadius.test.yml | 18 ++ .../controllers/ms/georadiusbymember/index.md | 55 ++++ .../snippets/georadiusbymember.js | 58 +++++ .../snippets/georadiusbymember.test.yml | 18 ++ doc/src/controllers/ms/get/index.md | 40 +++ doc/src/controllers/ms/get/snippets/get.js | 8 + .../controllers/ms/get/snippets/get.test.yml | 9 + doc/src/controllers/ms/getbit/index.md | 42 ++++ .../controllers/ms/getbit/snippets/getbit.js | 11 + .../ms/getbit/snippets/getbit.test.yml | 11 + doc/src/controllers/ms/getrange/index.md | 44 ++++ .../ms/getrange/snippets/getrange.js | 11 + .../ms/getrange/snippets/getrange.test.yml | 11 + doc/src/controllers/ms/getset/index.md | 41 +++ .../controllers/ms/getset/snippets/getset.js | 11 + .../ms/getset/snippets/getset.test.yml | 11 + doc/src/controllers/ms/hdel/index.md | 41 +++ doc/src/controllers/ms/hdel/snippets/hdel.js | 14 ++ .../ms/hdel/snippets/hdel.test.yml | 11 + doc/src/controllers/ms/hexists/index.md | 41 +++ .../ms/hexists/snippets/hexists.js | 11 + .../ms/hexists/snippets/hexists.test.yml | 11 + doc/src/controllers/ms/hget/index.md | 41 +++ doc/src/controllers/ms/hget/snippets/hget.js | 8 + .../ms/hget/snippets/hget.test.yml | 9 + doc/src/controllers/ms/hgetall/index.md | 40 +++ .../ms/hgetall/snippets/hgetall.js | 9 + .../ms/hgetall/snippets/hgetall.test.yml | 9 + doc/src/controllers/ms/hincrby/index.md | 42 ++++ .../ms/hincrby/snippets/hincrby.js | 8 + .../ms/hincrby/snippets/hincrby.test.yml | 9 + doc/src/controllers/ms/hincrbyfloat/index.md | 42 ++++ .../ms/hincrbyfloat/snippets/hincrbyfloat.js | 8 + .../snippets/hincrbyfloat.test.yml | 9 + doc/src/controllers/ms/hkeys/index.md | 40 +++ .../controllers/ms/hkeys/snippets/hkeys.js | 10 + .../ms/hkeys/snippets/hkeys.test.yml | 9 + doc/src/controllers/ms/hlen/index.md | 40 +++ doc/src/controllers/ms/hlen/snippets/hlen.js | 10 + .../ms/hlen/snippets/hlen.test.yml | 9 + doc/src/controllers/ms/hmget/index.md | 41 +++ .../controllers/ms/hmget/snippets/hmget.js | 11 + .../ms/hmget/snippets/hmget.test.yml | 9 + doc/src/controllers/ms/hmset/index.md | 50 ++++ .../controllers/ms/hmset/snippets/hmset.js | 15 ++ .../ms/hmset/snippets/hmset.test.yml | 9 + doc/src/controllers/ms/hscan/index.md | 53 ++++ .../controllers/ms/hscan/snippets/hscan.js | 14 ++ .../ms/hscan/snippets/hscan.test.yml | 11 + doc/src/controllers/ms/hset/index.md | 46 ++++ doc/src/controllers/ms/hset/snippets/hset.js | 8 + .../ms/hset/snippets/hset.test.yml | 9 + doc/src/controllers/ms/hsetnx/index.md | 38 +++ .../controllers/ms/hsetnx/snippets/hsetnx.js | 13 + .../ms/hsetnx/snippets/hsetnx.test.yml | 12 + doc/src/controllers/ms/hstrlen/index.md | 41 +++ .../ms/hstrlen/snippets/hstrlen.js | 8 + .../ms/hstrlen/snippets/hstrlen.test.yml | 9 + doc/src/controllers/ms/hvals/index.md | 40 +++ .../controllers/ms/hvals/snippets/hvals.js | 10 + .../ms/hvals/snippets/hvals.test.yml | 9 + doc/src/controllers/ms/incr/index.md | 40 +++ doc/src/controllers/ms/incr/snippets/incr.js | 8 + .../ms/incr/snippets/incr.test.yml | 9 + doc/src/controllers/ms/incrby/index.md | 41 +++ .../controllers/ms/incrby/snippets/incrby.js | 8 + .../ms/incrby/snippets/incrby.test.yml | 9 + doc/src/controllers/ms/incrbyfloat/index.md | 41 +++ .../ms/incrbyfloat/snippets/incrbyfloat.js | 8 + .../incrbyfloat/snippets/incrbyfloat.test.yml | 9 + doc/src/controllers/ms/index.md | 6 + doc/src/controllers/ms/keys/index.md | 40 +++ doc/src/controllers/ms/keys/snippets/keys.js | 10 + .../ms/keys/snippets/keys.test.yml | 9 + doc/src/controllers/ms/lindex/index.md | 41 +++ .../controllers/ms/lindex/snippets/lindex.js | 8 + .../ms/lindex/snippets/lindex.test.yml | 9 + doc/src/controllers/ms/linsert/index.md | 43 ++++ .../ms/linsert/snippets/linsert.js | 10 + .../ms/linsert/snippets/linsert.test.yml | 9 + doc/src/controllers/ms/llen/index.md | 40 +++ doc/src/controllers/ms/llen/snippets/llen.js | 8 + .../ms/llen/snippets/llen.test.yml | 9 + doc/src/controllers/ms/lpop/index.md | 40 +++ doc/src/controllers/ms/lpop/snippets/lpop.js | 11 + .../ms/lpop/snippets/lpop.test.yml | 11 + doc/src/controllers/ms/lpush/index.md | 43 ++++ .../controllers/ms/lpush/snippets/lpush.js | 11 + .../ms/lpush/snippets/lpush.test.yml | 11 + doc/src/controllers/ms/lpushx/index.md | 41 +++ .../controllers/ms/lpushx/snippets/lpushx.js | 17 ++ .../ms/lpushx/snippets/lpushx.test.yml | 13 + doc/src/controllers/ms/lrange/index.md | 46 ++++ .../controllers/ms/lrange/snippets/lrange.js | 11 + .../ms/lrange/snippets/lrange.test.yml | 11 + doc/src/controllers/ms/lrem/index.md | 42 ++++ doc/src/controllers/ms/lrem/snippets/lrem.js | 11 + .../ms/lrem/snippets/lrem.test.yml | 11 + doc/src/controllers/ms/lset/index.md | 42 ++++ doc/src/controllers/ms/lset/snippets/lset.js | 10 + .../ms/lset/snippets/lset.test.yml | 9 + doc/src/controllers/ms/ltrim/index.md | 44 ++++ .../controllers/ms/ltrim/snippets/ltrim.js | 10 + .../ms/ltrim/snippets/ltrim.test.yml | 9 + doc/src/controllers/ms/mget/index.md | 40 +++ doc/src/controllers/ms/mget/snippets/mget.js | 9 + .../ms/mget/snippets/mget.test.yml | 9 + doc/src/controllers/ms/mset/index.md | 49 ++++ doc/src/controllers/ms/mset/snippets/mset.js | 15 ++ .../ms/mset/snippets/mset.test.yml | 11 + doc/src/controllers/ms/msetnx/index.md | 49 ++++ .../controllers/ms/msetnx/snippets/msetnx.js | 19 ++ .../ms/msetnx/snippets/msetnx.test.yml | 11 + doc/src/controllers/ms/object/index.md | 41 +++ .../controllers/ms/object/snippets/object.js | 8 + .../ms/object/snippets/object.test.yml | 9 + doc/src/controllers/ms/persist/index.md | 40 +++ .../ms/persist/snippets/persist.js | 13 + .../ms/persist/snippets/persist.test.yml | 11 + doc/src/controllers/ms/pexpire/index.md | 41 +++ .../ms/pexpire/snippets/pexpire.js | 13 + .../ms/pexpire/snippets/pexpire.test.yml | 11 + doc/src/controllers/ms/pexpireat/index.md | 41 +++ .../ms/pexpireat/snippets/pexpireat.js | 14 ++ .../ms/pexpireat/snippets/pexpireat.test.yml | 11 + doc/src/controllers/ms/pfadd/index.md | 40 +++ .../controllers/ms/pfadd/snippets/pfadd.js | 8 + .../ms/pfadd/snippets/pfadd.test.yml | 9 + doc/src/controllers/ms/pfcount/index.md | 40 +++ .../ms/pfcount/snippets/pfcount.js | 9 + .../ms/pfcount/snippets/pfcount.test.yml | 9 + doc/src/controllers/ms/pfmerge/index.md | 41 +++ .../ms/pfmerge/snippets/pfmerge.js | 11 + .../ms/pfmerge/snippets/pfmerge.test.yml | 9 + doc/src/controllers/ms/ping/index.md | 39 +++ doc/src/controllers/ms/ping/snippets/ping.js | 6 + .../ms/ping/snippets/ping.test.yml | 9 + doc/src/controllers/ms/psetex/index.md | 42 ++++ .../controllers/ms/psetex/snippets/psetex.js | 11 + .../ms/psetex/snippets/psetex.test.yml | 11 + doc/src/controllers/ms/pttl/index.md | 40 +++ doc/src/controllers/ms/pttl/snippets/pttl.js | 8 + .../ms/pttl/snippets/pttl.test.yml | 9 + doc/src/controllers/ms/randomkey/index.md | 40 +++ .../ms/randomkey/snippets/randomkey.js | 10 + .../ms/randomkey/snippets/randomkey.test.yml | 9 + doc/src/controllers/ms/rename/index.md | 43 ++++ .../controllers/ms/rename/snippets/rename.js | 10 + .../ms/rename/snippets/rename.test.yml | 9 + doc/src/controllers/ms/renamenx/index.md | 41 +++ .../ms/renamenx/snippets/renamenx.js | 13 + .../ms/renamenx/snippets/renamenx.test.yml | 11 + doc/src/controllers/ms/rpop/index.md | 40 +++ doc/src/controllers/ms/rpop/snippets/rpop.js | 11 + .../ms/rpop/snippets/rpop.test.yml | 11 + doc/src/controllers/ms/rpoplpush/index.md | 41 +++ .../ms/rpoplpush/snippets/rpoplpush.js | 12 + .../ms/rpoplpush/snippets/rpoplpush.test.yml | 11 + doc/src/controllers/ms/rpush/index.md | 43 ++++ .../controllers/ms/rpush/snippets/rpush.js | 8 + .../ms/rpush/snippets/rpush.test.yml | 9 + doc/src/controllers/ms/rpushx/index.md | 41 +++ .../controllers/ms/rpushx/snippets/rpushx.js | 12 + .../ms/rpushx/snippets/rpushx.test.yml | 11 + doc/src/controllers/ms/sadd/index.md | 43 ++++ doc/src/controllers/ms/sadd/snippets/sadd.js | 12 + .../ms/sadd/snippets/sadd.test.yml | 12 + doc/src/controllers/ms/scan/index.md | 52 ++++ doc/src/controllers/ms/scan/snippets/scan.js | 14 ++ .../ms/scan/snippets/scan.test.yml | 11 + doc/src/controllers/ms/scard/index.md | 40 +++ .../controllers/ms/scard/snippets/scard.js | 8 + .../ms/scard/snippets/scard.test.yml | 9 + doc/src/controllers/ms/sdiff/index.md | 41 +++ .../controllers/ms/sdiff/snippets/sdiff.js | 11 + .../ms/sdiff/snippets/sdiff.test.yml | 9 + doc/src/controllers/ms/sdiffstore/index.md | 44 ++++ .../ms/sdiffstore/snippets/sdiffstore.js | 13 + .../sdiffstore/snippets/sdiffstore.test.yml | 9 + doc/src/controllers/ms/set/index.md | 47 ++++ doc/src/controllers/ms/set/snippets/set.js | 8 + .../controllers/ms/set/snippets/set.test.yml | 9 + doc/src/controllers/ms/setex/index.md | 42 ++++ .../controllers/ms/setex/snippets/setex.js | 11 + .../ms/setex/snippets/setex.test.yml | 11 + doc/src/controllers/ms/setnx/index.md | 41 +++ .../controllers/ms/setnx/snippets/setnx.js | 12 + .../ms/setnx/snippets/setnx.test.yml | 12 + doc/src/controllers/ms/sinter/index.md | 40 +++ .../controllers/ms/sinter/snippets/sinter.js | 9 + .../ms/sinter/snippets/sinter.test.yml | 9 + doc/src/controllers/ms/sinterstore/index.md | 43 ++++ .../ms/sinterstore/snippets/sinterstore.js | 12 + .../sinterstore/snippets/sinterstore.test.yml | 11 + doc/src/controllers/ms/sismember/index.md | 41 +++ .../ms/sismember/snippets/sismember.js | 11 + .../ms/sismember/snippets/sismember.test.yml | 11 + doc/src/controllers/ms/smembers/index.md | 40 +++ .../ms/smembers/snippets/smembers.js | 8 + .../ms/smembers/snippets/smembers.test.yml | 9 + doc/src/controllers/ms/smove/index.md | 42 ++++ .../controllers/ms/smove/snippets/smove.js | 14 ++ .../ms/smove/snippets/smove.test.yml | 11 + doc/src/controllers/ms/sort/index.md | 46 ++++ doc/src/controllers/ms/sort/snippets/sort.js | 12 + .../ms/sort/snippets/sort.test.yml | 11 + doc/src/controllers/ms/spop/index.md | 41 +++ doc/src/controllers/ms/spop/snippets/spop.js | 14 ++ .../ms/spop/snippets/spop.test.yml | 12 + doc/src/controllers/ms/srandmember/index.md | 39 +++ .../ms/srandmember/snippets/srandmember.js | 12 + .../srandmember/snippets/srandmember.test.yml | 11 + doc/src/controllers/ms/srem/index.md | 41 +++ doc/src/controllers/ms/srem/snippets/srem.js | 11 + .../ms/srem/snippets/srem.test.yml | 11 + doc/src/controllers/ms/sscan/index.md | 53 ++++ .../controllers/ms/sscan/snippets/sscan.js | 12 + .../ms/sscan/snippets/sscan.test.yml | 11 + doc/src/controllers/ms/strlen/index.md | 40 +++ .../controllers/ms/strlen/snippets/strlen.js | 8 + .../ms/strlen/snippets/strlen.test.yml | 9 + doc/src/controllers/ms/sunion/index.md | 40 +++ .../controllers/ms/sunion/snippets/sunion.js | 10 + .../ms/sunion/snippets/sunion.test.yml | 9 + doc/src/controllers/ms/sunionstore/index.md | 43 ++++ .../ms/sunionstore/snippets/sunionstore.js | 16 ++ .../sunionstore/snippets/sunionstore.test.yml | 11 + doc/src/controllers/ms/time/index.md | 42 ++++ doc/src/controllers/ms/time/snippets/time.js | 8 + .../ms/time/snippets/time.test.yml | 10 + doc/src/controllers/ms/touch/index.md | 40 +++ .../controllers/ms/touch/snippets/touch.js | 9 + .../ms/touch/snippets/touch.test.yml | 9 + doc/src/controllers/ms/ttl/index.md | 40 +++ doc/src/controllers/ms/ttl/snippets/ttl.js | 8 + .../controllers/ms/ttl/snippets/ttl.test.yml | 9 + doc/src/controllers/ms/type/index.md | 40 +++ doc/src/controllers/ms/type/snippets/type.js | 16 ++ .../ms/type/snippets/type.test.yml | 12 + doc/src/controllers/ms/zadd/index.md | 60 +++++ doc/src/controllers/ms/zadd/snippets/zadd.js | 15 ++ .../ms/zadd/snippets/zadd.test.yml | 12 + doc/src/controllers/ms/zcard/index.md | 40 +++ .../controllers/ms/zcard/snippets/zcard.js | 12 + .../ms/zcard/snippets/zcard.test.yml | 9 + doc/src/controllers/ms/zcount/index.md | 42 ++++ .../controllers/ms/zcount/snippets/zcount.js | 13 + .../ms/zcount/snippets/zcount.test.yml | 9 + doc/src/controllers/ms/zincrby/index.md | 42 ++++ .../ms/zincrby/snippets/zincrby.js | 17 ++ .../ms/zincrby/snippets/zincrby.test.yml | 12 + doc/src/controllers/ms/zinterstore/index.md | 43 ++++ .../ms/zinterstore/snippets/zinterstore.js | 34 +++ .../zinterstore/snippets/zinterstore.test.yml | 13 + doc/src/controllers/ms/zlexcount/index.md | 44 ++++ .../ms/zlexcount/snippets/zlexcount.js | 14 ++ .../ms/zlexcount/snippets/zlexcount.test.yml | 9 + doc/src/controllers/ms/zrange/index.md | 42 ++++ .../controllers/ms/zrange/snippets/zrange.js | 14 ++ .../ms/zrange/snippets/zrange.test.yml | 11 + doc/src/controllers/ms/zrangebylex/index.md | 45 ++++ .../ms/zrangebylex/snippets/zrangebylex.js | 14 ++ .../zrangebylex/snippets/zrangebylex.test.yml | 9 + doc/src/controllers/ms/zrangebyscore/index.md | 47 ++++ .../zrangebyscore/snippets/zrangebyscore.js | 14 ++ .../snippets/zrangebyscore.test.yml | 11 + doc/src/controllers/ms/zrank/index.md | 41 +++ .../controllers/ms/zrank/snippets/zrank.js | 15 ++ .../ms/zrank/snippets/zrank.test.yml | 11 + doc/src/controllers/ms/zrem/index.md | 41 +++ doc/src/controllers/ms/zrem/snippets/zrem.js | 14 ++ .../ms/zrem/snippets/zrem.test.yml | 9 + .../controllers/ms/zremrangebylex/index.md | 44 ++++ .../zremrangebylex/snippets/zremrangebylex.js | 14 ++ .../snippets/zremrangebylex.test.yml | 9 + .../controllers/ms/zremrangebyrank/index.md | 44 ++++ .../snippets/zremrangebyrank.js | 14 ++ .../snippets/zremrangebyrank.test.yml | 9 + .../controllers/ms/zremrangebyscore/index.md | 44 ++++ .../snippets/zremrangebyscore.js | 14 ++ .../snippets/zremrangebyscore.test.yml | 9 + doc/src/controllers/ms/zrevrange/index.md | 42 ++++ .../ms/zrevrange/snippets/zrevrange.js | 14 ++ .../ms/zrevrange/snippets/zrevrange.test.yml | 10 + .../controllers/ms/zrevrangebylex/index.md | 45 ++++ .../zrevrangebylex/snippets/zrevrangebylex.js | 14 ++ .../snippets/zrevrangebylex.test.yml | 9 + .../controllers/ms/zrevrangebyscore/index.md | 43 ++++ .../snippets/zrevrangebyscore.js | 14 ++ .../snippets/zrevrangebyscore.test.yml | 12 + doc/src/controllers/ms/zrevrank/index.md | 41 +++ .../ms/zrevrank/snippets/zrevrank.js | 15 ++ .../ms/zrevrank/snippets/zrevrank.test.yml | 12 + doc/src/controllers/ms/zscan/index.md | 53 ++++ .../controllers/ms/zscan/snippets/zscan.js | 16 ++ .../ms/zscan/snippets/zscan.test.yml | 11 + doc/src/controllers/ms/zscore/index.md | 41 +++ .../controllers/ms/zscore/snippets/zscore.js | 15 ++ .../ms/zscore/snippets/zscore.test.yml | 11 + doc/src/controllers/ms/zunionstore/index.md | 43 ++++ .../ms/zunionstore/snippets/zunionstore.js | 35 +++ .../zunionstore/snippets/zunionstore.test.yml | 15 ++ doc/src/controllers/realtime/count/index.md | 39 +++ .../realtime/count/snippets/count.js | 14 ++ .../realtime/count/snippets/count.test.yml | 10 + doc/src/controllers/realtime/index.md | 8 + doc/src/controllers/realtime/publish/index.md | 45 ++++ .../realtime/publish/snippets/publish.js | 13 + .../publish/snippets/publish.test.yml | 10 + .../controllers/realtime/subscribe/index.md | 64 +++++ .../document-notifications-leave-scope.js | 48 ++++ ...ocument-notifications-leave-scope.test.yml | 10 + .../snippets/document-notifications.js | 46 ++++ .../snippets/document-notifications.test.yml | 10 + .../snippets/message-notifications.js | 43 ++++ .../snippets/message-notifications.test.yml | 10 + .../subscribe/snippets/user-notifications.js | 42 ++++ .../snippets/user-notifications.test.yml | 9 + .../controllers/realtime/unsubscribe/index.md | 39 +++ .../unsubscribe/snippets/unsubscribe.js | 14 ++ .../unsubscribe/snippets/unsubscribe.test.yml | 10 + .../controllers/server/admin-exists/index.md | 38 +++ .../admin-exists/snippets/admin-exists.js | 7 + .../snippets/admin-exists.test.yml | 10 + .../controllers/server/get-all-stats/index.md | 46 ++++ .../get-all-stats/snippets/get-all-stats.js | 7 + .../snippets/get-all-stats.test.yml | 10 + .../controllers/server/get-config/index.md | 42 ++++ .../server/get-config/snippets/get-config.js | 7 + .../get-config/snippets/get-config.test.yml | 10 + .../server/get-last-stats/index.md | 47 ++++ .../get-last-stats/snippets/get-last-stats.js | 7 + .../snippets/get-last-stats.test.yml | 10 + doc/src/controllers/server/get-stats/index.md | 48 ++++ .../server/get-stats/snippets/get-stats.js | 7 + .../get-stats/snippets/get-stats.test.yml | 10 + doc/src/controllers/server/index.md | 8 + doc/src/controllers/server/info/index.md | 38 +++ .../controllers/server/info/snippets/info.js | 7 + .../server/info/snippets/info.test.yml | 9 + doc/src/controllers/server/now/index.md | 38 +++ .../controllers/server/now/snippets/now.js | 7 + .../server/now/snippets/now.test.yml | 10 + doc/src/core-classes/index.md | 7 + doc/src/core-classes/kuzzle-error/index.md | 7 + .../kuzzle-error/introduction/index.md | 23 ++ .../add-once-listener/index.md | 33 +++ .../snippets/add-once-listener.js | 11 + .../snippets/add-once-listener.test.yml | 9 + .../kuzzle-event-emitter/emit/index.md | 31 +++ .../emit/snippets/emit.js | 5 + .../emit/snippets/emit.test.yml | 9 + .../kuzzle-event-emitter/index.md | 7 + .../introduction/index.md | 18 ++ .../kuzzle-event-emitter/listeners/index.md | 24 ++ .../listeners/snippets/listeners.js | 8 + .../listeners/snippets/listeners.test.yml | 9 + .../kuzzle-event-emitter/on/index.md | 10 + .../kuzzle-event-emitter/once/index.md | 10 + .../prepend-listener/index.md | 31 +++ .../snippets/prepend-listener.js | 10 + .../snippets/prepend-listener.test.yml | 11 + .../prepend-once-listener/index.md | 32 +++ .../snippets/prepend-once-listener.js | 14 ++ .../snippets/prepend-once-listener.test.yml | 12 + .../remove-all-listener/index.md | 31 +++ .../snippets/remove-all-listeners.js | 18 ++ .../snippets/remove-all-listeners.test.yml | 9 + .../remove-listener/index.md | 31 +++ .../snippets/remove-listener.js | 13 + .../snippets/remove-listener.test.yml | 9 + .../core-classes/kuzzle/add-listener/index.md | 32 +++ .../add-listener/snippets/add-listener.js | 9 + .../snippets/add-listener.test.yml | 11 + doc/src/core-classes/kuzzle/connect/index.md | 25 ++ .../kuzzle/connect/snippets/connect.js | 7 + .../kuzzle/connect/snippets/connect.test.yml | 11 + .../core-classes/kuzzle/constructor/index.md | 58 +++++ .../constructor/snippets/constructor.js | 25 ++ .../constructor/snippets/constructor.test.yml | 10 + .../core-classes/kuzzle/disconnect/index.md | 22 ++ .../kuzzle/disconnect/snippets/disconnect.js | 7 + .../disconnect/snippets/disconnect.test.yml | 11 + .../core-classes/kuzzle/flush-queue/index.md | 24 ++ .../flush-queue/snippets/flush-queue.js | 7 + .../flush-queue/snippets/flush-queue.test.yml | 11 + doc/src/core-classes/kuzzle/index.md | 7 + .../core-classes/kuzzle/introduction/index.md | 103 ++++++++ .../core-classes/kuzzle/play-queue/index.md | 25 ++ .../kuzzle/play-queue/snippets/play-queue.js | 7 + .../play-queue/snippets/play-queue.test.yml | 11 + doc/src/core-classes/kuzzle/query/index.md | 58 +++++ .../kuzzle/query/snippets/query.js | 50 ++++ .../kuzzle/query/snippets/query.test.yml | 14 ++ .../kuzzle/start-queuing/index.md | 25 ++ .../start-queuing/snippets/start-queuing.js | 7 + .../snippets/start-queuing.test.yml | 11 + .../core-classes/kuzzle/stop-queuing/index.md | 25 ++ .../stop-queuing/snippets/stop-queuing.js | 7 + .../snippets/stop-queuing.test.yml | 11 + .../core-classes/profile/getRoles/index.md | 24 ++ .../profile/getRoles/snippets/getRoles.js | 28 +++ .../getRoles/snippets/getRoles.test.yml | 12 + doc/src/core-classes/profile/index.md | 7 + .../profile/introduction/index.md | 29 +++ doc/src/core-classes/role/index.md | 7 + .../core-classes/role/introduction/index.md | 22 ++ doc/src/core-classes/search-result/index.md | 7 + .../search-result/introduction/index.md | 35 +++ .../core-classes/search-result/next/index.md | 67 +++++ .../search-result/next/snippets/fromsize.js | 69 +++++ .../next/snippets/fromsize.test.yml | 13 + .../search-result/next/snippets/scroll.js | 74 ++++++ .../next/snippets/scroll.test.yml | 13 + .../core-classes/user/getProfiles/index.md | 24 ++ .../user/getProfiles/snippets/getProfiles.js | 24 ++ .../getProfiles/snippets/getProfiles.test.yml | 12 + doc/src/core-classes/user/index.md | 7 + .../core-classes/user/introduction/index.md | 34 +++ doc/src/essentials/error-handling/index.md | 28 +++ .../snippets/error-handling-async.js | 8 + .../snippets/error-handling-async.test.yml | 10 + .../error-handling/snippets/error-handling.js | 8 + .../snippets/error-handling.test.yml | 10 + doc/src/essentials/events/index.md | 101 ++++++++ doc/src/essentials/extend-sdk/index.md | 102 ++++++++ doc/src/essentials/getting-started/index.md | 7 + .../getting-started/node-js/index.md | 156 ++++++++++++ .../node-js/snippets/create.js | 39 +++ .../node-js/snippets/create.test.yml | 11 + .../getting-started/node-js/snippets/init.js | 37 +++ .../node-js/snippets/init.test.yml | 9 + .../node-js/snippets/load-sdk.js | 9 + .../node-js/snippets/load-sdk.test.yml | 9 + .../node-js/snippets/prepare-db.js | 20 ++ .../node-js/snippets/prepare-db.test.yml | 9 + .../node-js/snippets/subscribe.js | 51 ++++ .../node-js/snippets/subscribe.test.yml | 11 + .../getting-started/raw-web/index.md | 166 ++++++++++++ .../raw-web/snippets/create.html | 31 +++ .../raw-web/snippets/create.test.yml | 12 + .../raw-web/snippets/load-sdk.html | 14 ++ .../raw-web/snippets/load-sdk.test.yml | 10 + .../raw-web/snippets/prepare-db.html | 29 +++ .../raw-web/snippets/prepare-db.test.yml | 10 + .../raw-web/snippets/subscribe.html | 32 +++ .../raw-web/snippets/subscribe.test.yml | 12 + .../getting-started/webpack/index.md | 233 +++++++++++++++++ .../webpack/snippets/create.js | 33 +++ .../webpack/snippets/create.test.yml | 13 + .../webpack/snippets/init-kuzzle.js | 30 +++ .../webpack/snippets/init-kuzzle.test.yml | 10 + .../webpack/snippets/subscribe.js | 49 ++++ .../webpack/snippets/subscribe.test.yml | 14 ++ doc/src/essentials/index.md | 7 + doc/src/essentials/offline-tools/index.md | 76 ++++++ .../realtime-notifications/index.md | 69 +++++ doc/src/index.md | 7 + doc/src/protocols/http/constructor/index.md | 41 +++ .../http/constructor/snippets/constructor.js | 16 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/src/protocols/http/index.md | 7 + doc/src/protocols/http/introduction/index.md | 20 ++ doc/src/protocols/index.md | 7 + .../protocols/socketio/constructor/index.md | 43 ++++ .../constructor/snippets/constructor.js | 16 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/src/protocols/socketio/index.md | 7 + .../protocols/socketio/introduction/index.md | 31 +++ .../protocols/websocket/constructor/index.md | 44 ++++ .../constructor/snippets/constructor.js | 16 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/src/protocols/websocket/index.md | 7 + .../protocols/websocket/introduction/index.md | 28 +++ 702 files changed, 16911 insertions(+), 3 deletions(-) create mode 100644 .ci/doc/config.yml create mode 100644 .ci/doc/eslint.json create mode 100644 .ci/doc/puppeteer.js create mode 100644 .ci/doc/templates/blank.tpl.js create mode 100644 .ci/doc/templates/catch.tpl.js create mode 100644 .ci/doc/templates/controller.tpl.js create mode 100644 .ci/doc/templates/createDocumentAfterSnippet.tpl.js create mode 100644 .ci/doc/templates/default.tpl.html create mode 100644 .ci/doc/templates/default.tpl.js create mode 100644 .ci/doc/templates/doIt.tpl.js create mode 100644 .ci/doc/templates/empty-realtime.tpl.js create mode 100644 .ci/doc/templates/empty.tpl.js create mode 100644 .ci/doc/templates/eventemitter.tpl.js create mode 100644 .ci/doc/templates/mqtt-end.tpl.js create mode 100644 .ci/doc/templates/realtime.tpl.js create mode 100644 .ci/doc/templates/success.tpl.js create mode 100644 .ci/doc/templates/thencatch.tpl.js create mode 100644 .ci/doc/templates/without-connect.tpl.js create mode 100644 .ci/doc/webpackBuild.js create mode 100644 doc/src/controllers/auth/check-token/index.md create mode 100644 doc/src/controllers/auth/check-token/snippets/check-token.js create mode 100644 doc/src/controllers/auth/check-token/snippets/check-token.test.yml create mode 100644 doc/src/controllers/auth/create-my-credentials/index.md create mode 100644 doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.js create mode 100644 doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml create mode 100644 doc/src/controllers/auth/credentials-exist/index.md create mode 100644 doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.js create mode 100644 doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml create mode 100644 doc/src/controllers/auth/delete-my-credentials/index.md create mode 100644 doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js create mode 100644 doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml create mode 100644 doc/src/controllers/auth/get-current-user/index.md create mode 100644 doc/src/controllers/auth/get-current-user/snippets/get-current-user.js create mode 100644 doc/src/controllers/auth/get-current-user/snippets/get-current-user.test.yml create mode 100644 doc/src/controllers/auth/get-my-credentials/index.md create mode 100644 doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.js create mode 100644 doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml create mode 100644 doc/src/controllers/auth/get-my-rights/index.md create mode 100644 doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.js create mode 100644 doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml create mode 100644 doc/src/controllers/auth/get-strategies/index.md create mode 100644 doc/src/controllers/auth/get-strategies/snippets/get-strategies.js create mode 100644 doc/src/controllers/auth/get-strategies/snippets/get-strategies.test.yml create mode 100644 doc/src/controllers/auth/index.md create mode 100644 doc/src/controllers/auth/login/index.md create mode 100644 doc/src/controllers/auth/login/snippets/login.js create mode 100644 doc/src/controllers/auth/login/snippets/login.test.yml create mode 100644 doc/src/controllers/auth/logout/index.md create mode 100644 doc/src/controllers/auth/logout/snippets/logout.js create mode 100644 doc/src/controllers/auth/logout/snippets/logout.test.yml create mode 100644 doc/src/controllers/auth/update-my-credentials/index.md create mode 100644 doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.js create mode 100644 doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml create mode 100644 doc/src/controllers/auth/update-self/index.md create mode 100644 doc/src/controllers/auth/update-self/snippets/update-self.js create mode 100644 doc/src/controllers/auth/update-self/snippets/update-self.test.yml create mode 100644 doc/src/controllers/auth/validate-my-credentials/index.md create mode 100644 doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js create mode 100644 doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml create mode 100644 doc/src/controllers/bulk/import/index.md create mode 100644 doc/src/controllers/bulk/import/snippets/import.js create mode 100644 doc/src/controllers/bulk/import/snippets/import.test.yml create mode 100644 doc/src/controllers/bulk/index.md create mode 100644 doc/src/controllers/collection/create/index.md create mode 100644 doc/src/controllers/collection/create/snippets/create.js create mode 100644 doc/src/controllers/collection/create/snippets/create.test.yml create mode 100644 doc/src/controllers/collection/delete-specifications/index.md create mode 100644 doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.js create mode 100644 doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml create mode 100644 doc/src/controllers/collection/exists/index.md create mode 100644 doc/src/controllers/collection/exists/snippets/exists.js create mode 100644 doc/src/controllers/collection/exists/snippets/exists.test.yml create mode 100644 doc/src/controllers/collection/get-mapping/index.md create mode 100644 doc/src/controllers/collection/get-mapping/snippets/get-mapping.js create mode 100644 doc/src/controllers/collection/get-mapping/snippets/get-mapping.test.yml create mode 100644 doc/src/controllers/collection/get-specifications/index.md create mode 100644 doc/src/controllers/collection/get-specifications/snippets/get-specifications.js create mode 100644 doc/src/controllers/collection/get-specifications/snippets/get-specifications.test.yml create mode 100644 doc/src/controllers/collection/index.md create mode 100644 doc/src/controllers/collection/list/index.md create mode 100644 doc/src/controllers/collection/list/snippets/list.js create mode 100644 doc/src/controllers/collection/list/snippets/list.test.yml create mode 100644 doc/src/controllers/collection/search-specifications/index.md create mode 100644 doc/src/controllers/collection/search-specifications/snippets/search-specifications.js create mode 100644 doc/src/controllers/collection/search-specifications/snippets/search-specifications.test.yml create mode 100644 doc/src/controllers/collection/truncate/index.md create mode 100644 doc/src/controllers/collection/truncate/snippets/truncate.js create mode 100644 doc/src/controllers/collection/truncate/snippets/truncate.test.yml create mode 100644 doc/src/controllers/collection/update-mapping/index.md create mode 100644 doc/src/controllers/collection/update-mapping/snippets/update-mapping.js create mode 100644 doc/src/controllers/collection/update-mapping/snippets/update-mapping.test.yml create mode 100644 doc/src/controllers/collection/update-specifications/index.md create mode 100644 doc/src/controllers/collection/update-specifications/snippets/update-specifications.js create mode 100644 doc/src/controllers/collection/update-specifications/snippets/update-specifications.test.yml create mode 100644 doc/src/controllers/collection/validate-specifications/index.md create mode 100644 doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.js create mode 100644 doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml create mode 100644 doc/src/controllers/document/count/index.md create mode 100644 doc/src/controllers/document/count/snippets/count.js create mode 100644 doc/src/controllers/document/count/snippets/count.test.yml create mode 100644 doc/src/controllers/document/create/index.md create mode 100644 doc/src/controllers/document/create/snippets/create.js create mode 100644 doc/src/controllers/document/create/snippets/create.test.yml create mode 100644 doc/src/controllers/document/createOrReplace/index.md create mode 100644 doc/src/controllers/document/createOrReplace/snippets/create-or-replace.js create mode 100644 doc/src/controllers/document/createOrReplace/snippets/create-or-replace.test.yml create mode 100644 doc/src/controllers/document/delete/index.md create mode 100644 doc/src/controllers/document/delete/snippets/delete.js create mode 100644 doc/src/controllers/document/delete/snippets/delete.test.yml create mode 100644 doc/src/controllers/document/deleteByQuery/index.md create mode 100644 doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.js create mode 100644 doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml create mode 100644 doc/src/controllers/document/get/index.md create mode 100644 doc/src/controllers/document/get/snippets/get.js create mode 100644 doc/src/controllers/document/get/snippets/get.test.yml create mode 100644 doc/src/controllers/document/index.md create mode 100644 doc/src/controllers/document/mCreate/index.md create mode 100644 doc/src/controllers/document/mCreate/snippets/m-create.js create mode 100644 doc/src/controllers/document/mCreate/snippets/m-create.test.yml create mode 100644 doc/src/controllers/document/mCreateOrReplace/index.md create mode 100644 doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js create mode 100644 doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml create mode 100644 doc/src/controllers/document/mDelete/index.md create mode 100644 doc/src/controllers/document/mDelete/snippets/m-delete.js create mode 100644 doc/src/controllers/document/mDelete/snippets/m-delete.test.yml create mode 100644 doc/src/controllers/document/mGet/index.md create mode 100644 doc/src/controllers/document/mGet/snippets/m-get.js create mode 100644 doc/src/controllers/document/mGet/snippets/m-get.test.yml create mode 100644 doc/src/controllers/document/mReplace/index.md create mode 100644 doc/src/controllers/document/mReplace/snippets/m-replace.js create mode 100644 doc/src/controllers/document/mReplace/snippets/m-replace.test.yml create mode 100644 doc/src/controllers/document/mUpdate/index.md create mode 100644 doc/src/controllers/document/mUpdate/snippets/m-update.js create mode 100644 doc/src/controllers/document/mUpdate/snippets/m-update.test.yml create mode 100644 doc/src/controllers/document/replace/index.md create mode 100644 doc/src/controllers/document/replace/snippets/replace.js create mode 100644 doc/src/controllers/document/replace/snippets/replace.test.yml create mode 100644 doc/src/controllers/document/search/index.md create mode 100644 doc/src/controllers/document/search/snippets/search.js create mode 100644 doc/src/controllers/document/search/snippets/search.test.yml create mode 100644 doc/src/controllers/document/update/index.md create mode 100644 doc/src/controllers/document/update/snippets/update.js create mode 100644 doc/src/controllers/document/update/snippets/update.test.yml create mode 100644 doc/src/controllers/document/validate/index.md create mode 100644 doc/src/controllers/document/validate/snippets/validate.js create mode 100644 doc/src/controllers/document/validate/snippets/validate.test.yml create mode 100644 doc/src/controllers/index.md create mode 100644 doc/src/controllers/index/create/index.md create mode 100644 doc/src/controllers/index/create/snippets/create.js create mode 100644 doc/src/controllers/index/create/snippets/create.test.yml create mode 100644 doc/src/controllers/index/delete/index.md create mode 100644 doc/src/controllers/index/delete/snippets/delete.js create mode 100644 doc/src/controllers/index/delete/snippets/delete.test.yml create mode 100644 doc/src/controllers/index/exists/index.md create mode 100644 doc/src/controllers/index/exists/snippets/exists.js create mode 100644 doc/src/controllers/index/exists/snippets/exists.test.yml create mode 100644 doc/src/controllers/index/get-auto-refresh/index.md create mode 100644 doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js create mode 100644 doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml create mode 100644 doc/src/controllers/index/index.md create mode 100644 doc/src/controllers/index/list/index.md create mode 100644 doc/src/controllers/index/list/snippets/list.js create mode 100644 doc/src/controllers/index/list/snippets/list.test.yml create mode 100644 doc/src/controllers/index/m-delete/index.md create mode 100644 doc/src/controllers/index/m-delete/snippets/mDelete.js create mode 100644 doc/src/controllers/index/m-delete/snippets/mDelete.test.yml create mode 100644 doc/src/controllers/index/refresh-internal/index.md create mode 100644 doc/src/controllers/index/refresh-internal/snippets/refreshInternal.js create mode 100644 doc/src/controllers/index/refresh-internal/snippets/refreshInternal.test.yml create mode 100644 doc/src/controllers/index/refresh/index.md create mode 100644 doc/src/controllers/index/refresh/snippets/refresh.js create mode 100644 doc/src/controllers/index/refresh/snippets/refresh.test.yml create mode 100644 doc/src/controllers/index/set-auto-refresh/index.md create mode 100644 doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js create mode 100644 doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml create mode 100644 doc/src/controllers/ms/append/index.md create mode 100644 doc/src/controllers/ms/append/snippets/append.js create mode 100644 doc/src/controllers/ms/append/snippets/append.test.yml create mode 100644 doc/src/controllers/ms/bitcount/index.md create mode 100644 doc/src/controllers/ms/bitcount/snippets/bitcount.js create mode 100644 doc/src/controllers/ms/bitcount/snippets/bitcount.test.yml create mode 100644 doc/src/controllers/ms/bitop/index.md create mode 100644 doc/src/controllers/ms/bitop/snippets/bitop.js create mode 100644 doc/src/controllers/ms/bitop/snippets/bitop.test.yml create mode 100644 doc/src/controllers/ms/bitpos/index.md create mode 100644 doc/src/controllers/ms/bitpos/snippets/bitpos.js create mode 100644 doc/src/controllers/ms/bitpos/snippets/bitpos.test.yml create mode 100644 doc/src/controllers/ms/dbsize/index.md create mode 100644 doc/src/controllers/ms/dbsize/snippets/dbsize.js create mode 100644 doc/src/controllers/ms/dbsize/snippets/dbsize.test.yml create mode 100644 doc/src/controllers/ms/decr/index.md create mode 100644 doc/src/controllers/ms/decr/snippets/decr.js create mode 100644 doc/src/controllers/ms/decr/snippets/decr.test.yml create mode 100644 doc/src/controllers/ms/decrby/index.md create mode 100644 doc/src/controllers/ms/decrby/snippets/decrby.js create mode 100644 doc/src/controllers/ms/decrby/snippets/decrby.test.yml create mode 100644 doc/src/controllers/ms/del/index.md create mode 100644 doc/src/controllers/ms/del/snippets/del.js create mode 100644 doc/src/controllers/ms/del/snippets/del.test.yml create mode 100644 doc/src/controllers/ms/exists/index.md create mode 100644 doc/src/controllers/ms/exists/snippets/exists.js create mode 100644 doc/src/controllers/ms/exists/snippets/exists.test.yml create mode 100644 doc/src/controllers/ms/expire/index.md create mode 100644 doc/src/controllers/ms/expire/snippets/expire.js create mode 100644 doc/src/controllers/ms/expire/snippets/expire.test.yml create mode 100644 doc/src/controllers/ms/expireat/index.md create mode 100644 doc/src/controllers/ms/expireat/snippets/expireat.js create mode 100644 doc/src/controllers/ms/expireat/snippets/expireat.test.yml create mode 100644 doc/src/controllers/ms/flushdb/index.md create mode 100644 doc/src/controllers/ms/flushdb/snippets/flushdb.js create mode 100644 doc/src/controllers/ms/flushdb/snippets/flushdb.test.yml create mode 100644 doc/src/controllers/ms/geoadd/index.md create mode 100644 doc/src/controllers/ms/geoadd/snippets/geoadd.js create mode 100644 doc/src/controllers/ms/geoadd/snippets/geoadd.test.yml create mode 100644 doc/src/controllers/ms/geodist/index.md create mode 100644 doc/src/controllers/ms/geodist/snippets/geodist.js create mode 100644 doc/src/controllers/ms/geodist/snippets/geodist.test.yml create mode 100644 doc/src/controllers/ms/geohash/index.md create mode 100644 doc/src/controllers/ms/geohash/snippets/geohash.js create mode 100644 doc/src/controllers/ms/geohash/snippets/geohash.test.yml create mode 100644 doc/src/controllers/ms/geopos/index.md create mode 100644 doc/src/controllers/ms/geopos/snippets/geopos.js create mode 100644 doc/src/controllers/ms/geopos/snippets/geopos.test.yml create mode 100644 doc/src/controllers/ms/georadius/index.md create mode 100644 doc/src/controllers/ms/georadius/snippets/georadius.js create mode 100644 doc/src/controllers/ms/georadius/snippets/georadius.test.yml create mode 100644 doc/src/controllers/ms/georadiusbymember/index.md create mode 100644 doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.js create mode 100644 doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml create mode 100644 doc/src/controllers/ms/get/index.md create mode 100644 doc/src/controllers/ms/get/snippets/get.js create mode 100644 doc/src/controllers/ms/get/snippets/get.test.yml create mode 100644 doc/src/controllers/ms/getbit/index.md create mode 100644 doc/src/controllers/ms/getbit/snippets/getbit.js create mode 100644 doc/src/controllers/ms/getbit/snippets/getbit.test.yml create mode 100644 doc/src/controllers/ms/getrange/index.md create mode 100644 doc/src/controllers/ms/getrange/snippets/getrange.js create mode 100644 doc/src/controllers/ms/getrange/snippets/getrange.test.yml create mode 100644 doc/src/controllers/ms/getset/index.md create mode 100644 doc/src/controllers/ms/getset/snippets/getset.js create mode 100644 doc/src/controllers/ms/getset/snippets/getset.test.yml create mode 100644 doc/src/controllers/ms/hdel/index.md create mode 100644 doc/src/controllers/ms/hdel/snippets/hdel.js create mode 100644 doc/src/controllers/ms/hdel/snippets/hdel.test.yml create mode 100644 doc/src/controllers/ms/hexists/index.md create mode 100644 doc/src/controllers/ms/hexists/snippets/hexists.js create mode 100644 doc/src/controllers/ms/hexists/snippets/hexists.test.yml create mode 100644 doc/src/controllers/ms/hget/index.md create mode 100644 doc/src/controllers/ms/hget/snippets/hget.js create mode 100644 doc/src/controllers/ms/hget/snippets/hget.test.yml create mode 100644 doc/src/controllers/ms/hgetall/index.md create mode 100644 doc/src/controllers/ms/hgetall/snippets/hgetall.js create mode 100644 doc/src/controllers/ms/hgetall/snippets/hgetall.test.yml create mode 100644 doc/src/controllers/ms/hincrby/index.md create mode 100644 doc/src/controllers/ms/hincrby/snippets/hincrby.js create mode 100644 doc/src/controllers/ms/hincrby/snippets/hincrby.test.yml create mode 100644 doc/src/controllers/ms/hincrbyfloat/index.md create mode 100644 doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js create mode 100644 doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml create mode 100644 doc/src/controllers/ms/hkeys/index.md create mode 100644 doc/src/controllers/ms/hkeys/snippets/hkeys.js create mode 100644 doc/src/controllers/ms/hkeys/snippets/hkeys.test.yml create mode 100644 doc/src/controllers/ms/hlen/index.md create mode 100644 doc/src/controllers/ms/hlen/snippets/hlen.js create mode 100644 doc/src/controllers/ms/hlen/snippets/hlen.test.yml create mode 100644 doc/src/controllers/ms/hmget/index.md create mode 100644 doc/src/controllers/ms/hmget/snippets/hmget.js create mode 100644 doc/src/controllers/ms/hmget/snippets/hmget.test.yml create mode 100644 doc/src/controllers/ms/hmset/index.md create mode 100644 doc/src/controllers/ms/hmset/snippets/hmset.js create mode 100644 doc/src/controllers/ms/hmset/snippets/hmset.test.yml create mode 100644 doc/src/controllers/ms/hscan/index.md create mode 100644 doc/src/controllers/ms/hscan/snippets/hscan.js create mode 100644 doc/src/controllers/ms/hscan/snippets/hscan.test.yml create mode 100644 doc/src/controllers/ms/hset/index.md create mode 100644 doc/src/controllers/ms/hset/snippets/hset.js create mode 100644 doc/src/controllers/ms/hset/snippets/hset.test.yml create mode 100644 doc/src/controllers/ms/hsetnx/index.md create mode 100644 doc/src/controllers/ms/hsetnx/snippets/hsetnx.js create mode 100644 doc/src/controllers/ms/hsetnx/snippets/hsetnx.test.yml create mode 100644 doc/src/controllers/ms/hstrlen/index.md create mode 100644 doc/src/controllers/ms/hstrlen/snippets/hstrlen.js create mode 100644 doc/src/controllers/ms/hstrlen/snippets/hstrlen.test.yml create mode 100644 doc/src/controllers/ms/hvals/index.md create mode 100644 doc/src/controllers/ms/hvals/snippets/hvals.js create mode 100644 doc/src/controllers/ms/hvals/snippets/hvals.test.yml create mode 100644 doc/src/controllers/ms/incr/index.md create mode 100644 doc/src/controllers/ms/incr/snippets/incr.js create mode 100644 doc/src/controllers/ms/incr/snippets/incr.test.yml create mode 100644 doc/src/controllers/ms/incrby/index.md create mode 100644 doc/src/controllers/ms/incrby/snippets/incrby.js create mode 100644 doc/src/controllers/ms/incrby/snippets/incrby.test.yml create mode 100644 doc/src/controllers/ms/incrbyfloat/index.md create mode 100644 doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.js create mode 100644 doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml create mode 100644 doc/src/controllers/ms/index.md create mode 100644 doc/src/controllers/ms/keys/index.md create mode 100644 doc/src/controllers/ms/keys/snippets/keys.js create mode 100644 doc/src/controllers/ms/keys/snippets/keys.test.yml create mode 100644 doc/src/controllers/ms/lindex/index.md create mode 100644 doc/src/controllers/ms/lindex/snippets/lindex.js create mode 100644 doc/src/controllers/ms/lindex/snippets/lindex.test.yml create mode 100644 doc/src/controllers/ms/linsert/index.md create mode 100644 doc/src/controllers/ms/linsert/snippets/linsert.js create mode 100644 doc/src/controllers/ms/linsert/snippets/linsert.test.yml create mode 100644 doc/src/controllers/ms/llen/index.md create mode 100644 doc/src/controllers/ms/llen/snippets/llen.js create mode 100644 doc/src/controllers/ms/llen/snippets/llen.test.yml create mode 100644 doc/src/controllers/ms/lpop/index.md create mode 100644 doc/src/controllers/ms/lpop/snippets/lpop.js create mode 100644 doc/src/controllers/ms/lpop/snippets/lpop.test.yml create mode 100644 doc/src/controllers/ms/lpush/index.md create mode 100644 doc/src/controllers/ms/lpush/snippets/lpush.js create mode 100644 doc/src/controllers/ms/lpush/snippets/lpush.test.yml create mode 100644 doc/src/controllers/ms/lpushx/index.md create mode 100644 doc/src/controllers/ms/lpushx/snippets/lpushx.js create mode 100644 doc/src/controllers/ms/lpushx/snippets/lpushx.test.yml create mode 100644 doc/src/controllers/ms/lrange/index.md create mode 100644 doc/src/controllers/ms/lrange/snippets/lrange.js create mode 100644 doc/src/controllers/ms/lrange/snippets/lrange.test.yml create mode 100644 doc/src/controllers/ms/lrem/index.md create mode 100644 doc/src/controllers/ms/lrem/snippets/lrem.js create mode 100644 doc/src/controllers/ms/lrem/snippets/lrem.test.yml create mode 100644 doc/src/controllers/ms/lset/index.md create mode 100644 doc/src/controllers/ms/lset/snippets/lset.js create mode 100644 doc/src/controllers/ms/lset/snippets/lset.test.yml create mode 100644 doc/src/controllers/ms/ltrim/index.md create mode 100644 doc/src/controllers/ms/ltrim/snippets/ltrim.js create mode 100644 doc/src/controllers/ms/ltrim/snippets/ltrim.test.yml create mode 100644 doc/src/controllers/ms/mget/index.md create mode 100644 doc/src/controllers/ms/mget/snippets/mget.js create mode 100644 doc/src/controllers/ms/mget/snippets/mget.test.yml create mode 100644 doc/src/controllers/ms/mset/index.md create mode 100644 doc/src/controllers/ms/mset/snippets/mset.js create mode 100644 doc/src/controllers/ms/mset/snippets/mset.test.yml create mode 100644 doc/src/controllers/ms/msetnx/index.md create mode 100644 doc/src/controllers/ms/msetnx/snippets/msetnx.js create mode 100644 doc/src/controllers/ms/msetnx/snippets/msetnx.test.yml create mode 100644 doc/src/controllers/ms/object/index.md create mode 100644 doc/src/controllers/ms/object/snippets/object.js create mode 100644 doc/src/controllers/ms/object/snippets/object.test.yml create mode 100644 doc/src/controllers/ms/persist/index.md create mode 100644 doc/src/controllers/ms/persist/snippets/persist.js create mode 100644 doc/src/controllers/ms/persist/snippets/persist.test.yml create mode 100644 doc/src/controllers/ms/pexpire/index.md create mode 100644 doc/src/controllers/ms/pexpire/snippets/pexpire.js create mode 100644 doc/src/controllers/ms/pexpire/snippets/pexpire.test.yml create mode 100644 doc/src/controllers/ms/pexpireat/index.md create mode 100644 doc/src/controllers/ms/pexpireat/snippets/pexpireat.js create mode 100644 doc/src/controllers/ms/pexpireat/snippets/pexpireat.test.yml create mode 100644 doc/src/controllers/ms/pfadd/index.md create mode 100644 doc/src/controllers/ms/pfadd/snippets/pfadd.js create mode 100644 doc/src/controllers/ms/pfadd/snippets/pfadd.test.yml create mode 100644 doc/src/controllers/ms/pfcount/index.md create mode 100644 doc/src/controllers/ms/pfcount/snippets/pfcount.js create mode 100644 doc/src/controllers/ms/pfcount/snippets/pfcount.test.yml create mode 100644 doc/src/controllers/ms/pfmerge/index.md create mode 100644 doc/src/controllers/ms/pfmerge/snippets/pfmerge.js create mode 100644 doc/src/controllers/ms/pfmerge/snippets/pfmerge.test.yml create mode 100644 doc/src/controllers/ms/ping/index.md create mode 100644 doc/src/controllers/ms/ping/snippets/ping.js create mode 100644 doc/src/controllers/ms/ping/snippets/ping.test.yml create mode 100644 doc/src/controllers/ms/psetex/index.md create mode 100644 doc/src/controllers/ms/psetex/snippets/psetex.js create mode 100644 doc/src/controllers/ms/psetex/snippets/psetex.test.yml create mode 100644 doc/src/controllers/ms/pttl/index.md create mode 100644 doc/src/controllers/ms/pttl/snippets/pttl.js create mode 100644 doc/src/controllers/ms/pttl/snippets/pttl.test.yml create mode 100644 doc/src/controllers/ms/randomkey/index.md create mode 100644 doc/src/controllers/ms/randomkey/snippets/randomkey.js create mode 100644 doc/src/controllers/ms/randomkey/snippets/randomkey.test.yml create mode 100644 doc/src/controllers/ms/rename/index.md create mode 100644 doc/src/controllers/ms/rename/snippets/rename.js create mode 100644 doc/src/controllers/ms/rename/snippets/rename.test.yml create mode 100644 doc/src/controllers/ms/renamenx/index.md create mode 100644 doc/src/controllers/ms/renamenx/snippets/renamenx.js create mode 100644 doc/src/controllers/ms/renamenx/snippets/renamenx.test.yml create mode 100644 doc/src/controllers/ms/rpop/index.md create mode 100644 doc/src/controllers/ms/rpop/snippets/rpop.js create mode 100644 doc/src/controllers/ms/rpop/snippets/rpop.test.yml create mode 100644 doc/src/controllers/ms/rpoplpush/index.md create mode 100644 doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.js create mode 100644 doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml create mode 100644 doc/src/controllers/ms/rpush/index.md create mode 100644 doc/src/controllers/ms/rpush/snippets/rpush.js create mode 100644 doc/src/controllers/ms/rpush/snippets/rpush.test.yml create mode 100644 doc/src/controllers/ms/rpushx/index.md create mode 100644 doc/src/controllers/ms/rpushx/snippets/rpushx.js create mode 100644 doc/src/controllers/ms/rpushx/snippets/rpushx.test.yml create mode 100644 doc/src/controllers/ms/sadd/index.md create mode 100644 doc/src/controllers/ms/sadd/snippets/sadd.js create mode 100644 doc/src/controllers/ms/sadd/snippets/sadd.test.yml create mode 100644 doc/src/controllers/ms/scan/index.md create mode 100644 doc/src/controllers/ms/scan/snippets/scan.js create mode 100644 doc/src/controllers/ms/scan/snippets/scan.test.yml create mode 100644 doc/src/controllers/ms/scard/index.md create mode 100644 doc/src/controllers/ms/scard/snippets/scard.js create mode 100644 doc/src/controllers/ms/scard/snippets/scard.test.yml create mode 100644 doc/src/controllers/ms/sdiff/index.md create mode 100644 doc/src/controllers/ms/sdiff/snippets/sdiff.js create mode 100644 doc/src/controllers/ms/sdiff/snippets/sdiff.test.yml create mode 100644 doc/src/controllers/ms/sdiffstore/index.md create mode 100644 doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.js create mode 100644 doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml create mode 100644 doc/src/controllers/ms/set/index.md create mode 100644 doc/src/controllers/ms/set/snippets/set.js create mode 100644 doc/src/controllers/ms/set/snippets/set.test.yml create mode 100644 doc/src/controllers/ms/setex/index.md create mode 100644 doc/src/controllers/ms/setex/snippets/setex.js create mode 100644 doc/src/controllers/ms/setex/snippets/setex.test.yml create mode 100644 doc/src/controllers/ms/setnx/index.md create mode 100644 doc/src/controllers/ms/setnx/snippets/setnx.js create mode 100644 doc/src/controllers/ms/setnx/snippets/setnx.test.yml create mode 100644 doc/src/controllers/ms/sinter/index.md create mode 100644 doc/src/controllers/ms/sinter/snippets/sinter.js create mode 100644 doc/src/controllers/ms/sinter/snippets/sinter.test.yml create mode 100644 doc/src/controllers/ms/sinterstore/index.md create mode 100644 doc/src/controllers/ms/sinterstore/snippets/sinterstore.js create mode 100644 doc/src/controllers/ms/sinterstore/snippets/sinterstore.test.yml create mode 100644 doc/src/controllers/ms/sismember/index.md create mode 100644 doc/src/controllers/ms/sismember/snippets/sismember.js create mode 100644 doc/src/controllers/ms/sismember/snippets/sismember.test.yml create mode 100644 doc/src/controllers/ms/smembers/index.md create mode 100644 doc/src/controllers/ms/smembers/snippets/smembers.js create mode 100644 doc/src/controllers/ms/smembers/snippets/smembers.test.yml create mode 100644 doc/src/controllers/ms/smove/index.md create mode 100644 doc/src/controllers/ms/smove/snippets/smove.js create mode 100644 doc/src/controllers/ms/smove/snippets/smove.test.yml create mode 100644 doc/src/controllers/ms/sort/index.md create mode 100644 doc/src/controllers/ms/sort/snippets/sort.js create mode 100644 doc/src/controllers/ms/sort/snippets/sort.test.yml create mode 100644 doc/src/controllers/ms/spop/index.md create mode 100644 doc/src/controllers/ms/spop/snippets/spop.js create mode 100644 doc/src/controllers/ms/spop/snippets/spop.test.yml create mode 100644 doc/src/controllers/ms/srandmember/index.md create mode 100644 doc/src/controllers/ms/srandmember/snippets/srandmember.js create mode 100644 doc/src/controllers/ms/srandmember/snippets/srandmember.test.yml create mode 100644 doc/src/controllers/ms/srem/index.md create mode 100644 doc/src/controllers/ms/srem/snippets/srem.js create mode 100644 doc/src/controllers/ms/srem/snippets/srem.test.yml create mode 100644 doc/src/controllers/ms/sscan/index.md create mode 100644 doc/src/controllers/ms/sscan/snippets/sscan.js create mode 100644 doc/src/controllers/ms/sscan/snippets/sscan.test.yml create mode 100644 doc/src/controllers/ms/strlen/index.md create mode 100644 doc/src/controllers/ms/strlen/snippets/strlen.js create mode 100644 doc/src/controllers/ms/strlen/snippets/strlen.test.yml create mode 100644 doc/src/controllers/ms/sunion/index.md create mode 100644 doc/src/controllers/ms/sunion/snippets/sunion.js create mode 100644 doc/src/controllers/ms/sunion/snippets/sunion.test.yml create mode 100644 doc/src/controllers/ms/sunionstore/index.md create mode 100644 doc/src/controllers/ms/sunionstore/snippets/sunionstore.js create mode 100644 doc/src/controllers/ms/sunionstore/snippets/sunionstore.test.yml create mode 100644 doc/src/controllers/ms/time/index.md create mode 100644 doc/src/controllers/ms/time/snippets/time.js create mode 100644 doc/src/controllers/ms/time/snippets/time.test.yml create mode 100644 doc/src/controllers/ms/touch/index.md create mode 100644 doc/src/controllers/ms/touch/snippets/touch.js create mode 100644 doc/src/controllers/ms/touch/snippets/touch.test.yml create mode 100644 doc/src/controllers/ms/ttl/index.md create mode 100644 doc/src/controllers/ms/ttl/snippets/ttl.js create mode 100644 doc/src/controllers/ms/ttl/snippets/ttl.test.yml create mode 100644 doc/src/controllers/ms/type/index.md create mode 100644 doc/src/controllers/ms/type/snippets/type.js create mode 100644 doc/src/controllers/ms/type/snippets/type.test.yml create mode 100644 doc/src/controllers/ms/zadd/index.md create mode 100644 doc/src/controllers/ms/zadd/snippets/zadd.js create mode 100644 doc/src/controllers/ms/zadd/snippets/zadd.test.yml create mode 100644 doc/src/controllers/ms/zcard/index.md create mode 100644 doc/src/controllers/ms/zcard/snippets/zcard.js create mode 100644 doc/src/controllers/ms/zcard/snippets/zcard.test.yml create mode 100644 doc/src/controllers/ms/zcount/index.md create mode 100644 doc/src/controllers/ms/zcount/snippets/zcount.js create mode 100644 doc/src/controllers/ms/zcount/snippets/zcount.test.yml create mode 100644 doc/src/controllers/ms/zincrby/index.md create mode 100644 doc/src/controllers/ms/zincrby/snippets/zincrby.js create mode 100644 doc/src/controllers/ms/zincrby/snippets/zincrby.test.yml create mode 100644 doc/src/controllers/ms/zinterstore/index.md create mode 100644 doc/src/controllers/ms/zinterstore/snippets/zinterstore.js create mode 100644 doc/src/controllers/ms/zinterstore/snippets/zinterstore.test.yml create mode 100644 doc/src/controllers/ms/zlexcount/index.md create mode 100644 doc/src/controllers/ms/zlexcount/snippets/zlexcount.js create mode 100644 doc/src/controllers/ms/zlexcount/snippets/zlexcount.test.yml create mode 100644 doc/src/controllers/ms/zrange/index.md create mode 100644 doc/src/controllers/ms/zrange/snippets/zrange.js create mode 100644 doc/src/controllers/ms/zrange/snippets/zrange.test.yml create mode 100644 doc/src/controllers/ms/zrangebylex/index.md create mode 100644 doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.js create mode 100644 doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml create mode 100644 doc/src/controllers/ms/zrangebyscore/index.md create mode 100644 doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.js create mode 100644 doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml create mode 100644 doc/src/controllers/ms/zrank/index.md create mode 100644 doc/src/controllers/ms/zrank/snippets/zrank.js create mode 100644 doc/src/controllers/ms/zrank/snippets/zrank.test.yml create mode 100644 doc/src/controllers/ms/zrem/index.md create mode 100644 doc/src/controllers/ms/zrem/snippets/zrem.js create mode 100644 doc/src/controllers/ms/zrem/snippets/zrem.test.yml create mode 100644 doc/src/controllers/ms/zremrangebylex/index.md create mode 100644 doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.js create mode 100644 doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml create mode 100644 doc/src/controllers/ms/zremrangebyrank/index.md create mode 100644 doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js create mode 100644 doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml create mode 100644 doc/src/controllers/ms/zremrangebyscore/index.md create mode 100644 doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js create mode 100644 doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml create mode 100644 doc/src/controllers/ms/zrevrange/index.md create mode 100644 doc/src/controllers/ms/zrevrange/snippets/zrevrange.js create mode 100644 doc/src/controllers/ms/zrevrange/snippets/zrevrange.test.yml create mode 100644 doc/src/controllers/ms/zrevrangebylex/index.md create mode 100644 doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js create mode 100644 doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml create mode 100644 doc/src/controllers/ms/zrevrangebyscore/index.md create mode 100644 doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js create mode 100644 doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml create mode 100644 doc/src/controllers/ms/zrevrank/index.md create mode 100644 doc/src/controllers/ms/zrevrank/snippets/zrevrank.js create mode 100644 doc/src/controllers/ms/zrevrank/snippets/zrevrank.test.yml create mode 100644 doc/src/controllers/ms/zscan/index.md create mode 100644 doc/src/controllers/ms/zscan/snippets/zscan.js create mode 100644 doc/src/controllers/ms/zscan/snippets/zscan.test.yml create mode 100644 doc/src/controllers/ms/zscore/index.md create mode 100644 doc/src/controllers/ms/zscore/snippets/zscore.js create mode 100644 doc/src/controllers/ms/zscore/snippets/zscore.test.yml create mode 100644 doc/src/controllers/ms/zunionstore/index.md create mode 100644 doc/src/controllers/ms/zunionstore/snippets/zunionstore.js create mode 100644 doc/src/controllers/ms/zunionstore/snippets/zunionstore.test.yml create mode 100644 doc/src/controllers/realtime/count/index.md create mode 100644 doc/src/controllers/realtime/count/snippets/count.js create mode 100644 doc/src/controllers/realtime/count/snippets/count.test.yml create mode 100644 doc/src/controllers/realtime/index.md create mode 100644 doc/src/controllers/realtime/publish/index.md create mode 100644 doc/src/controllers/realtime/publish/snippets/publish.js create mode 100644 doc/src/controllers/realtime/publish/snippets/publish.test.yml create mode 100644 doc/src/controllers/realtime/subscribe/index.md create mode 100644 doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js create mode 100644 doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml create mode 100644 doc/src/controllers/realtime/subscribe/snippets/document-notifications.js create mode 100644 doc/src/controllers/realtime/subscribe/snippets/document-notifications.test.yml create mode 100644 doc/src/controllers/realtime/subscribe/snippets/message-notifications.js create mode 100644 doc/src/controllers/realtime/subscribe/snippets/message-notifications.test.yml create mode 100644 doc/src/controllers/realtime/subscribe/snippets/user-notifications.js create mode 100644 doc/src/controllers/realtime/subscribe/snippets/user-notifications.test.yml create mode 100644 doc/src/controllers/realtime/unsubscribe/index.md create mode 100644 doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.js create mode 100644 doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml create mode 100644 doc/src/controllers/server/admin-exists/index.md create mode 100644 doc/src/controllers/server/admin-exists/snippets/admin-exists.js create mode 100644 doc/src/controllers/server/admin-exists/snippets/admin-exists.test.yml create mode 100644 doc/src/controllers/server/get-all-stats/index.md create mode 100644 doc/src/controllers/server/get-all-stats/snippets/get-all-stats.js create mode 100644 doc/src/controllers/server/get-all-stats/snippets/get-all-stats.test.yml create mode 100644 doc/src/controllers/server/get-config/index.md create mode 100644 doc/src/controllers/server/get-config/snippets/get-config.js create mode 100644 doc/src/controllers/server/get-config/snippets/get-config.test.yml create mode 100644 doc/src/controllers/server/get-last-stats/index.md create mode 100644 doc/src/controllers/server/get-last-stats/snippets/get-last-stats.js create mode 100644 doc/src/controllers/server/get-last-stats/snippets/get-last-stats.test.yml create mode 100644 doc/src/controllers/server/get-stats/index.md create mode 100644 doc/src/controllers/server/get-stats/snippets/get-stats.js create mode 100644 doc/src/controllers/server/get-stats/snippets/get-stats.test.yml create mode 100644 doc/src/controllers/server/index.md create mode 100644 doc/src/controllers/server/info/index.md create mode 100644 doc/src/controllers/server/info/snippets/info.js create mode 100644 doc/src/controllers/server/info/snippets/info.test.yml create mode 100644 doc/src/controllers/server/now/index.md create mode 100644 doc/src/controllers/server/now/snippets/now.js create mode 100644 doc/src/controllers/server/now/snippets/now.test.yml create mode 100644 doc/src/core-classes/index.md create mode 100644 doc/src/core-classes/kuzzle-error/index.md create mode 100644 doc/src/core-classes/kuzzle-error/introduction/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/add-once-listener/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml create mode 100644 doc/src/core-classes/kuzzle-event-emitter/emit/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml create mode 100644 doc/src/core-classes/kuzzle-event-emitter/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/introduction/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/listeners/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml create mode 100644 doc/src/core-classes/kuzzle-event-emitter/on/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/once/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/prepend-listener/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml create mode 100644 doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml create mode 100644 doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml create mode 100644 doc/src/core-classes/kuzzle-event-emitter/remove-listener/index.md create mode 100644 doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js create mode 100644 doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml create mode 100644 doc/src/core-classes/kuzzle/add-listener/index.md create mode 100644 doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.js create mode 100644 doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml create mode 100644 doc/src/core-classes/kuzzle/connect/index.md create mode 100644 doc/src/core-classes/kuzzle/connect/snippets/connect.js create mode 100644 doc/src/core-classes/kuzzle/connect/snippets/connect.test.yml create mode 100644 doc/src/core-classes/kuzzle/constructor/index.md create mode 100644 doc/src/core-classes/kuzzle/constructor/snippets/constructor.js create mode 100644 doc/src/core-classes/kuzzle/constructor/snippets/constructor.test.yml create mode 100644 doc/src/core-classes/kuzzle/disconnect/index.md create mode 100644 doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.js create mode 100644 doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml create mode 100644 doc/src/core-classes/kuzzle/flush-queue/index.md create mode 100644 doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.js create mode 100644 doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml create mode 100644 doc/src/core-classes/kuzzle/index.md create mode 100644 doc/src/core-classes/kuzzle/introduction/index.md create mode 100644 doc/src/core-classes/kuzzle/play-queue/index.md create mode 100644 doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.js create mode 100644 doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml create mode 100644 doc/src/core-classes/kuzzle/query/index.md create mode 100644 doc/src/core-classes/kuzzle/query/snippets/query.js create mode 100644 doc/src/core-classes/kuzzle/query/snippets/query.test.yml create mode 100644 doc/src/core-classes/kuzzle/start-queuing/index.md create mode 100644 doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.js create mode 100644 doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml create mode 100644 doc/src/core-classes/kuzzle/stop-queuing/index.md create mode 100644 doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js create mode 100644 doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml create mode 100644 doc/src/core-classes/profile/getRoles/index.md create mode 100644 doc/src/core-classes/profile/getRoles/snippets/getRoles.js create mode 100644 doc/src/core-classes/profile/getRoles/snippets/getRoles.test.yml create mode 100644 doc/src/core-classes/profile/index.md create mode 100644 doc/src/core-classes/profile/introduction/index.md create mode 100644 doc/src/core-classes/role/index.md create mode 100644 doc/src/core-classes/role/introduction/index.md create mode 100644 doc/src/core-classes/search-result/index.md create mode 100644 doc/src/core-classes/search-result/introduction/index.md create mode 100644 doc/src/core-classes/search-result/next/index.md create mode 100644 doc/src/core-classes/search-result/next/snippets/fromsize.js create mode 100644 doc/src/core-classes/search-result/next/snippets/fromsize.test.yml create mode 100644 doc/src/core-classes/search-result/next/snippets/scroll.js create mode 100644 doc/src/core-classes/search-result/next/snippets/scroll.test.yml create mode 100644 doc/src/core-classes/user/getProfiles/index.md create mode 100644 doc/src/core-classes/user/getProfiles/snippets/getProfiles.js create mode 100644 doc/src/core-classes/user/getProfiles/snippets/getProfiles.test.yml create mode 100644 doc/src/core-classes/user/index.md create mode 100644 doc/src/core-classes/user/introduction/index.md create mode 100644 doc/src/essentials/error-handling/index.md create mode 100644 doc/src/essentials/error-handling/snippets/error-handling-async.js create mode 100644 doc/src/essentials/error-handling/snippets/error-handling-async.test.yml create mode 100644 doc/src/essentials/error-handling/snippets/error-handling.js create mode 100644 doc/src/essentials/error-handling/snippets/error-handling.test.yml create mode 100644 doc/src/essentials/events/index.md create mode 100644 doc/src/essentials/extend-sdk/index.md create mode 100644 doc/src/essentials/getting-started/index.md create mode 100644 doc/src/essentials/getting-started/node-js/index.md create mode 100644 doc/src/essentials/getting-started/node-js/snippets/create.js create mode 100644 doc/src/essentials/getting-started/node-js/snippets/create.test.yml create mode 100644 doc/src/essentials/getting-started/node-js/snippets/init.js create mode 100644 doc/src/essentials/getting-started/node-js/snippets/init.test.yml create mode 100644 doc/src/essentials/getting-started/node-js/snippets/load-sdk.js create mode 100644 doc/src/essentials/getting-started/node-js/snippets/load-sdk.test.yml create mode 100644 doc/src/essentials/getting-started/node-js/snippets/prepare-db.js create mode 100644 doc/src/essentials/getting-started/node-js/snippets/prepare-db.test.yml create mode 100644 doc/src/essentials/getting-started/node-js/snippets/subscribe.js create mode 100644 doc/src/essentials/getting-started/node-js/snippets/subscribe.test.yml create mode 100644 doc/src/essentials/getting-started/raw-web/index.md create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/create.html create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/create.test.yml create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/load-sdk.html create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/load-sdk.test.yml create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/prepare-db.html create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/prepare-db.test.yml create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/subscribe.html create mode 100644 doc/src/essentials/getting-started/raw-web/snippets/subscribe.test.yml create mode 100644 doc/src/essentials/getting-started/webpack/index.md create mode 100644 doc/src/essentials/getting-started/webpack/snippets/create.js create mode 100644 doc/src/essentials/getting-started/webpack/snippets/create.test.yml create mode 100644 doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.js create mode 100644 doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml create mode 100644 doc/src/essentials/getting-started/webpack/snippets/subscribe.js create mode 100644 doc/src/essentials/getting-started/webpack/snippets/subscribe.test.yml create mode 100644 doc/src/essentials/index.md create mode 100644 doc/src/essentials/offline-tools/index.md create mode 100644 doc/src/essentials/realtime-notifications/index.md create mode 100644 doc/src/index.md create mode 100644 doc/src/protocols/http/constructor/index.md create mode 100644 doc/src/protocols/http/constructor/snippets/constructor.js create mode 100644 doc/src/protocols/http/constructor/snippets/constructor.test.yml create mode 100644 doc/src/protocols/http/index.md create mode 100644 doc/src/protocols/http/introduction/index.md create mode 100644 doc/src/protocols/index.md create mode 100644 doc/src/protocols/socketio/constructor/index.md create mode 100644 doc/src/protocols/socketio/constructor/snippets/constructor.js create mode 100644 doc/src/protocols/socketio/constructor/snippets/constructor.test.yml create mode 100644 doc/src/protocols/socketio/index.md create mode 100644 doc/src/protocols/socketio/introduction/index.md create mode 100644 doc/src/protocols/websocket/constructor/index.md create mode 100644 doc/src/protocols/websocket/constructor/snippets/constructor.js create mode 100644 doc/src/protocols/websocket/constructor/snippets/constructor.test.yml create mode 100644 doc/src/protocols/websocket/index.md create mode 100644 doc/src/protocols/websocket/introduction/index.md diff --git a/.ci/doc/config.yml b/.ci/doc/config.yml new file mode 100644 index 000000000..7b8025f7d --- /dev/null +++ b/.ci/doc/config.yml @@ -0,0 +1,47 @@ +--- + +snippets: + mount: /mnt + path: doc/src/**/snippets/*.test.yml + templates: /mnt/.ci/doc/templates + +runners: + default: node + + node: + service: doc-runner-node + path: /var/snippets/node + lint: + global: true + cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }} + before: timeout -t 600 ash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done' + run: + cmd: node {{ snippet.source }} + before: timeout -t 600 ash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done' + + web: + service: doc-runner-web + path: /var/snippets/web + lint: + global: true + cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}/*.html + before: timeout 600 bash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done' + run: + cmd: node puppeteer.js {{ snippet.dir }}/{{ snippet.source }} + before: timeout 600 bash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done' + + webpack: + service: doc-runner-webpack + path: /var/snippets/webpack + lint: + global: true + cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }} + before: timeout 600 bash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done' + build: + cmd: node webpackBuild.js {{ snippet.dir }}/{{ snippet.source }} + before: timeout 600 bash -c 'until stat /tmp/runner_is_ready; do sleep 1; done' + run: + cmd: node puppeteer.js /tmp/{{ snippet.name }}/index.html + before: timeout 600 bash -c 'until curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done' + + diff --git a/.ci/doc/eslint.json b/.ci/doc/eslint.json new file mode 100644 index 000000000..3424a4451 --- /dev/null +++ b/.ci/doc/eslint.json @@ -0,0 +1,236 @@ +{ + "parserOptions": { + "ecmaVersion": 9, + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "module" + }, + + "env": { + "es6": true, + "node": true, + "browser": true + }, + + "plugins": ["import", "node", "promise", "standard", "html"], + + "globals": { + "document": false, + "navigator": false, + "window": false, + "KuzzleSDK": true + }, + + "rules": { + "accessor-pairs": "error", + "arrow-spacing": ["error", { "before": true, "after": true }], + "block-spacing": ["error", "always"], + "brace-style": ["error", "1tbs", { "allowSingleLine": true }], + "camelcase": ["error", { "properties": "never" }], + "comma-dangle": [ + "error", + { + "arrays": "never", + "objects": "never", + "imports": "never", + "exports": "never", + "functions": "never" + } + ], + "comma-spacing": ["error", { "before": false, "after": true }], + "comma-style": ["error", "last"], + "constructor-super": "error", + "curly": ["error", "multi-line"], + "dot-location": ["error", "property"], + "eol-last": "error", + "eqeqeq": ["error", "always", { "null": "ignore" }], + "func-call-spacing": ["error", "never"], + "generator-star-spacing": ["error", { "before": true, "after": true }], + "handle-callback-err": ["error", "^(err|error)$"], + "indent": [ + "error", + 2, + { + "SwitchCase": 1, + "VariableDeclarator": 1, + "outerIIFEBody": 1, + "MemberExpression": 1, + "FunctionDeclaration": { "parameters": 1, "body": 1 }, + "FunctionExpression": { "parameters": 1, "body": 1 }, + "CallExpression": { "arguments": 1 }, + "ArrayExpression": 1, + "ObjectExpression": 1, + "ImportDeclaration": 1, + "flatTernaryExpressions": false, + "ignoreComments": false + } + ], + "key-spacing": ["error", { "beforeColon": false, "afterColon": true }], + "keyword-spacing": ["error", { "before": true, "after": true }], + "new-cap": ["error", { "newIsCap": true, "capIsNew": false }], + "new-parens": "error", + "no-array-constructor": "error", + "no-caller": "error", + "no-class-assign": "error", + "no-compare-neg-zero": "error", + "no-cond-assign": "error", + "no-const-assign": "error", + "no-constant-condition": ["error", { "checkLoops": false }], + "no-control-regex": "error", + "no-debugger": "error", + "no-delete-var": "error", + "no-dupe-args": "error", + "no-dupe-class-members": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-empty-character-class": "error", + "no-empty-pattern": "error", + "no-eval": "error", + "no-ex-assign": "error", + "no-extend-native": "error", + "no-extra-bind": "error", + "no-extra-boolean-cast": "error", + "no-extra-parens": ["error", "functions"], + "no-fallthrough": "error", + "no-floating-decimal": "error", + "no-func-assign": "error", + "no-global-assign": "error", + "no-implied-eval": "error", + "no-inner-declarations": ["error", "functions"], + "no-invalid-regexp": "error", + "no-irregular-whitespace": "error", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": ["error", { "allowLoop": false, "allowSwitch": false }], + "no-lone-blocks": "error", + "no-mixed-operators": [ + "error", + { + "groups": [ + ["==", "!=", "===", "!==", ">", ">=", "<", "<="], + ["&&", "||"], + ["in", "instanceof"] + ], + "allowSamePrecedence": true + } + ], + "no-mixed-spaces-and-tabs": "error", + "no-multi-spaces": "error", + "no-multi-str": "error", + "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }], + "no-negated-in-lhs": "error", + "no-new": "error", + "no-new-func": "error", + "no-new-object": "error", + "no-new-require": "error", + "no-new-symbol": "error", + "no-new-wrappers": "error", + "no-obj-calls": "error", + "no-octal": "error", + "no-octal-escape": "error", + "no-path-concat": "error", + "no-proto": "error", + "no-redeclare": "error", + "no-regex-spaces": "error", + "no-return-assign": ["error", "except-parens"], + "no-return-await": "error", + "no-self-assign": "error", + "no-self-compare": "error", + "no-sequences": "error", + "no-shadow-restricted-names": "error", + "no-sparse-arrays": "error", + "no-tabs": "error", + "no-template-curly-in-string": "error", + "no-this-before-super": "error", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef": "error", + "no-undef-init": "error", + "no-unexpected-multiline": "error", + "no-unmodified-loop-condition": "error", + "no-unneeded-ternary": ["error", { "defaultAssignment": false }], + "no-unreachable": "error", + "no-unsafe-finally": "error", + "no-unsafe-negation": "error", + "no-unused-expressions": [ + "error", + { + "allowShortCircuit": true, + "allowTernary": true, + "allowTaggedTemplates": true + } + ], + "no-use-before-define": [ + "error", + { "functions": false, "classes": false, "variables": false } + ], + "no-useless-call": "error", + "no-useless-computed-key": "error", + "no-useless-constructor": "error", + "no-useless-escape": "error", + "no-useless-rename": "error", + "no-useless-return": "error", + "no-whitespace-before-property": "error", + "no-with": "error", + "object-property-newline": [ + "error", + { "allowMultiplePropertiesPerLine": true } + ], + "one-var": ["error", { "initialized": "never" }], + "operator-linebreak": [ + "error", + "after", + { "overrides": { "?": "before", ":": "before" } } + ], + "prefer-promise-reject-errors": "error", + "quotes": [ + "error", + "single", + { "avoidEscape": true, "allowTemplateLiterals": true } + ], + "rest-spread-spacing": ["error", "never"], + "semi-spacing": ["error", { "before": false, "after": true }], + "space-before-blocks": ["error", "always"], + "space-before-function-paren": ["error", "always"], + "space-in-parens": ["error", "never"], + "space-infix-ops": "error", + "space-unary-ops": ["error", { "words": true, "nonwords": false }], + "spaced-comment": [ + "error", + "always", + { + "line": { "markers": ["*package", "!", "/", ",", "="] }, + "block": { + "balanced": true, + "markers": ["*package", "!", ",", ":", "::", "flow-include"], + "exceptions": ["*"] + } + } + ], + "symbol-description": "error", + "template-curly-spacing": ["error", "never"], + "template-tag-spacing": ["error", "never"], + "unicode-bom": ["error", "never"], + "use-isnan": "error", + "valid-typeof": ["error", { "requireStringLiterals": true }], + "wrap-iife": ["error", "any", { "functionPrototypeMethods": true }], + "yield-star-spacing": ["error", "both"], + "yoda": ["error", "never"], + + "import/export": "error", + "import/first": "error", + "import/no-duplicates": "error", + "import/no-webpack-loader-syntax": "error", + + "node/no-deprecated-api": "error", + "node/process-exit-as-throw": "error", + + "promise/param-names": "error", + + "standard/array-bracket-even-spacing": ["error", "either"], + "standard/computed-property-even-spacing": ["error", "even"], + "standard/no-callback-literal": "error", + "standard/object-curly-even-spacing": ["error", "either"] + } +} diff --git a/.ci/doc/puppeteer.js b/.ci/doc/puppeteer.js new file mode 100644 index 000000000..6e7ef84b1 --- /dev/null +++ b/.ci/doc/puppeteer.js @@ -0,0 +1,38 @@ +const puppeteer = require('puppeteer'); +const renderedSnippetPath = process.argv[2]; + +const runInBrowser = async snippetPath => { + let browser; + + try { + browser = await puppeteer.launch({ + dumpio: true, + args: ['--no-sandbox'] + }); + } catch (error) { + console.error(error); + return; + } + + try { + const page = await browser.newPage(); + + page.on('error', err => { + console.error(err); + }); + + page.on('pageerror', err => { + console.error(err); + }); + + await page.goto(`file:${snippetPath}`, { + waitUntil: 'networkidle0' + }); + } catch (error) { + console.error(error); + } finally { + await browser.close(); + } +}; + +runInBrowser(renderedSnippetPath); diff --git a/.ci/doc/templates/blank.tpl.js b/.ci/doc/templates/blank.tpl.js new file mode 100644 index 000000000..351ecaebe --- /dev/null +++ b/.ci/doc/templates/blank.tpl.js @@ -0,0 +1,14 @@ +// load the Kuzzle SDK module +const + { + Kuzzle, + WebSocket, + Http + } = require('kuzzle-sdk'); + +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +[snippet-code] +console.log('Everything is ok'); diff --git a/.ci/doc/templates/catch.tpl.js b/.ci/doc/templates/catch.tpl.js new file mode 100644 index 000000000..888ecdc2a --- /dev/null +++ b/.ci/doc/templates/catch.tpl.js @@ -0,0 +1,31 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + try { + [snippet-code] + } catch (e) { + console.log('Success'); + } finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/templates/controller.tpl.js b/.ci/doc/templates/controller.tpl.js new file mode 100644 index 000000000..17a2ff24e --- /dev/null +++ b/.ci/doc/templates/controller.tpl.js @@ -0,0 +1,11 @@ +// load the Kuzzle SDK module +const + { + Kuzzle, + WebSocket, + BaseController + } = require('kuzzle-sdk'); + +BaseController.prototype.query = () => Promise.resolve(null); + +[snippet-code] diff --git a/.ci/doc/templates/createDocumentAfterSnippet.tpl.js b/.ci/doc/templates/createDocumentAfterSnippet.tpl.js new file mode 100644 index 000000000..4327ab128 --- /dev/null +++ b/.ci/doc/templates/createDocumentAfterSnippet.tpl.js @@ -0,0 +1,27 @@ +// This template imports the snippet and then creates a document in the +// 'yellow-taxi collection in the `nyc-open-data` index. + +[snippet-code] + +// Require a kuzzle instance assigning it to a weird variable to avoid collisions and create the instance. +const $k = require('kuzzle-sdk'); +const $kInstance = new $k.Kuzzle(new $k.WebSocket('kuzzle')); + +// add a listener to detect any connection problems +$kInstance.on('networkError', error => { + console.error(`[doItAndCreateDocument.tpl] Network Error: ${error}`); +}); + +$kInstance.connect().then(() => { + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + return $kInstance.document.create('nyc-open-data', 'yellow-taxi', driver); +}).catch(error => { + console.error(`[doItAndCreateDocument.tpl] Error creating document: ${error}`); +}).finally(() => { + $kInstance.disconnect(); +}); diff --git a/.ci/doc/templates/default.tpl.html b/.ci/doc/templates/default.tpl.html new file mode 100644 index 000000000..e19296a86 --- /dev/null +++ b/.ci/doc/templates/default.tpl.html @@ -0,0 +1,12 @@ + + + + + + Snippet testing + + + + [snippet-code] + + diff --git a/.ci/doc/templates/default.tpl.js b/.ci/doc/templates/default.tpl.js new file mode 100644 index 000000000..116a1203e --- /dev/null +++ b/.ci/doc/templates/default.tpl.js @@ -0,0 +1,27 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + [snippet-code] finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/templates/doIt.tpl.js b/.ci/doc/templates/doIt.tpl.js new file mode 100644 index 000000000..9194dec7a --- /dev/null +++ b/.ci/doc/templates/doIt.tpl.js @@ -0,0 +1,5 @@ +// This template expects a snippet that declares a function called doIt function +// which it calls. +[snippet-code] + +doIt(); diff --git a/.ci/doc/templates/empty-realtime.tpl.js b/.ci/doc/templates/empty-realtime.tpl.js new file mode 100644 index 000000000..f8139c144 --- /dev/null +++ b/.ci/doc/templates/empty-realtime.tpl.js @@ -0,0 +1,23 @@ +function sleep (ms, i = 0) { + setTimeout(() => { + if (i >= 150 || outputs.length > 0) { + console.log = consoleLog; + console.log(...outputs); + + // force exit: do not wait for the event loop to be empty + process.exit(0); + } + sleep(ms, ++i); + }, ms); +} + +const consoleLog = console.log; +const outputs = []; + +console.log = (...args) => { + outputs.push(...args); +}; + +[snippet-code] + +sleep(200); diff --git a/.ci/doc/templates/empty.tpl.js b/.ci/doc/templates/empty.tpl.js new file mode 100644 index 000000000..3da052031 --- /dev/null +++ b/.ci/doc/templates/empty.tpl.js @@ -0,0 +1,3 @@ +[snippet-code] + +console.log('Success'); diff --git a/.ci/doc/templates/eventemitter.tpl.js b/.ci/doc/templates/eventemitter.tpl.js new file mode 100644 index 000000000..df1a48f9f --- /dev/null +++ b/.ci/doc/templates/eventemitter.tpl.js @@ -0,0 +1,6 @@ +const + { + KuzzleEventEmitter + } = require('kuzzle-sdk'); + +[snippet-code] diff --git a/.ci/doc/templates/mqtt-end.tpl.js b/.ci/doc/templates/mqtt-end.tpl.js new file mode 100644 index 000000000..4b051836c --- /dev/null +++ b/.ci/doc/templates/mqtt-end.tpl.js @@ -0,0 +1,4 @@ +[snippet-code] finally { + console.log('Success'); + client.end(); +} diff --git a/.ci/doc/templates/realtime.tpl.js b/.ci/doc/templates/realtime.tpl.js new file mode 100644 index 000000000..2ef73a8b6 --- /dev/null +++ b/.ci/doc/templates/realtime.tpl.js @@ -0,0 +1,47 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +function sleep (ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Cannot connect to Kuzzle: ${error.message}`); + } + + const consoleLog = console.log; + const outputs = []; + + console.log = (...args) => { + outputs.push(...args); + }; + + [snippet-code] finally { + for (let i = 150; i > 0 && outputs.length <= 0; --i) { + await sleep(200); + } + + console.log = consoleLog; + console.log(...outputs); + + // force exit: do not wait for the event loop to be empty + process.exit(0); + } +})(); diff --git a/.ci/doc/templates/success.tpl.js b/.ci/doc/templates/success.tpl.js new file mode 100644 index 000000000..a697cd07f --- /dev/null +++ b/.ci/doc/templates/success.tpl.js @@ -0,0 +1,32 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async function run () { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + try { + [snippet-code] + console.log('Success'); + } catch (e) { + console.log(e); + } finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/templates/thencatch.tpl.js b/.ci/doc/templates/thencatch.tpl.js new file mode 100644 index 000000000..562702342 --- /dev/null +++ b/.ci/doc/templates/thencatch.tpl.js @@ -0,0 +1,28 @@ +const Bluebird = require('bluebird'); + +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +Bluebird.resolve( + kuzzle + .connect() + .then(() => { + return [snippet-code] + }) +) + .catch(() => 'nothing') + .finally(() => kuzzle.disconnect()); diff --git a/.ci/doc/templates/without-connect.tpl.js b/.ci/doc/templates/without-connect.tpl.js new file mode 100644 index 000000000..abd722bb2 --- /dev/null +++ b/.ci/doc/templates/without-connect.tpl.js @@ -0,0 +1,22 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + [snippet-code] finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/webpackBuild.js b/.ci/doc/webpackBuild.js new file mode 100644 index 000000000..72038a3c2 --- /dev/null +++ b/.ci/doc/webpackBuild.js @@ -0,0 +1,53 @@ +const path = require('path'); +const webpack = require('webpack'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +const build = async file => { + const config = { + entry: file, + output: { + path: path.resolve('/tmp', path.basename(file).replace(/\.[^.]+$/, '')), + filename: 'build.js' + }, + module: { + rules: [ + { + test: /\.js$/, + loader: 'babel-loader' + } + ] + }, + devtool: 'eval-source-map', + plugins: [new HtmlWebpackPlugin()] + }; + + return new Promise((resolve, reject) => { + webpack(config, (err, stats) => { + if (err) { + if (err.details) { + return reject(err.details); + } + return reject(err.stack || err); + } + const info = stats.toJson(); + + if (stats.hasErrors()) { + return reject(info.errors); + } + + if (stats.hasWarnings()) { + return resolve(info.warnings); + } + resolve(true); + }); + }); +}; + +(async () => { + try { + await build(process.argv[2]); + } catch (e) { + console.error(e); + throw e; + } +})(); diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 4e8befb88..0b2ea93f9 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3' services: kuzzle: @@ -21,9 +21,110 @@ services: image: redis:3.2 elasticsearch: - image: kuzzleio/elasticsearch:5.4.1 + image: kuzzleio/elasticsearch:5.6.10 ulimits: nofile: 65536 environment: - cluster.name=kuzzle - "ES_JAVA_OPTS=-Xms256m -Xmx256m" + + doc-tests: + image: kuzzleio/snippets-tests + privileged: true + depends_on: + - kuzzle + - doc-runner-node + - doc-runner-web + - doc-runner-webpack + volumes: + - ..:/mnt + - /var/run/docker.sock:/var/run/docker.sock + - snippets:/var/snippets + environment: + - CONFIG_FILE=/mnt/.ci/doc/config.yml + + doc-runner-node: + image: node:8-alpine + working_dir: /var/snippets/node + command: > + ash -c ' + apk add --no-cache curl; + npm install -g \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + npm install \ + bluebird \ + /mnt/; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ..:/mnt + - snippets:/var/snippets + + doc-runner-web: + image: buildkite/puppeteer:latest + working_dir: /var/snippets/web + command: > + bash -c ' + apt-get update; + apt-get install -y curl; + npm install -g \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; + npm install \ + /mnt/ \ + puppeteer; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ..:/mnt + - snippets:/var/snippets + + doc-runner-webpack: + image: buildkite/puppeteer:latest + working_dir: /var/snippets/webpack + command: > + bash -c ' + apt-get update; + apt-get install -y curl; + npm install -g \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/; + cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/; + npm install \ + /mnt/ \ + babel-loader \ + @babel/core \ + puppeteer \ + html-webpack-plugin \ + webpack \ + webpack-cli; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ..:/mnt + - snippets:/var/snippets + +volumes: + snippets: + diff --git a/.ci/start_kuzzle.sh b/.ci/start_kuzzle.sh index 539eec912..1acb2fc0e 100755 --- a/.ci/start_kuzzle.sh +++ b/.ci/start_kuzzle.sh @@ -2,7 +2,7 @@ set -e # Download and launch custom Kuzzle stack -docker-compose -f .ci/docker-compose.yml up -d +docker-compose -f .ci/docker-compose.yml run -d kuzzle printf 'Waiting for Kuzzle stack to be up and running' diff --git a/.travis.yml b/.travis.yml index ddace1a2e..ca72b2275 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,14 @@ jobs: after_success: - cat ./coverage/lcov.info | ./node_modules/.bin/codecov + - name: Documentation tests + stage: Tests + language: node_js + node_js: 8 + + script: + - docker-compose .ci/docker-compose doc-tests node index + - stage: "Deploy Stable release on NPM" if: type != pull_request && branch = master sudo: false diff --git a/doc/src/controllers/auth/check-token/index.md b/doc/src/controllers/auth/check-token/index.md new file mode 100644 index 000000000..afb15081b --- /dev/null +++ b/doc/src/controllers/auth/check-token/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: checkToken +description: Checks a JWT's validity. +--- + +# checkToken + +Checks a token validity. + +This API route does not require the caller to be logged in. + +
+ +```javascript +checkToken(token); +``` + +
+ +| Property | Type | Description | +| -------- | ----------------- | ----------- | +| `token` |
string
| JWT token | + +## Resolves + +An `object` representing the token validity status + +| Name | Type | Description | +| ------------- | ------------------ | --------------------------------- | +| `valid` |
boolean
| Tell if the token is valid or not | +| `state` |
string
| Explain why the token is invalid | +|  `expires_at` |
number
| Token expiration timestamp | + +## Usage + +<<< ./snippets/check-token.js diff --git a/doc/src/controllers/auth/check-token/snippets/check-token.js b/doc/src/controllers/auth/check-token/snippets/check-token.js new file mode 100644 index 000000000..7d7914b85 --- /dev/null +++ b/doc/src/controllers/auth/check-token/snippets/check-token.js @@ -0,0 +1,19 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + const jwt = await kuzzle.auth.login('local', credentials); + + const result = await kuzzle.auth.checkToken(jwt); + console.log(result); + /* + { valid: true, expiresAt: 1540824822897 } + */ + + if (result.valid) { + console.log('Token is valid'); + } else { + console.error(`Token is invalid: ${result.state}`); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/check-token/snippets/check-token.test.yml b/doc/src/controllers/auth/check-token/snippets/check-token.test.yml new file mode 100644 index 000000000..1e603a0d7 --- /dev/null +++ b/doc/src/controllers/auth/check-token/snippets/check-token.test.yml @@ -0,0 +1,11 @@ +--- +name: auth#checkToken +description: Checks a JWT token's validity. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Token is valid + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/create-my-credentials/index.md b/doc/src/controllers/auth/create-my-credentials/index.md new file mode 100644 index 000000000..bbb2d9ea7 --- /dev/null +++ b/doc/src/controllers/auth/create-my-credentials/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: createMyCredentials +description: Create the current user's credentials for the specified strategy. +--- + +# createMyCredentials + +Creates new credentials for the specified strategy for the current user. + +
+ +```javascript +createMyCredentials(strategy, credentials, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `credentials` |
object
| New credentials | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +An `object` representing the new credentials. +The content depends on the authentication strategy. + +## Usage + +<<< ./snippets/create-my-credentials.js diff --git a/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.js b/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.js new file mode 100644 index 000000000..e502caf85 --- /dev/null +++ b/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.js @@ -0,0 +1,11 @@ +const credentials = { username: 'foo', password: 'bar' }; + +await kuzzle.auth.login('local', credentials); + +const response = await kuzzle.auth.createMyCredentials('other', credentials); +console.log(response); +/* + { username: 'foo', password: 'bar' } +*/ + +console.log('Credentials successfully created'); diff --git a/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml b/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml new file mode 100644 index 000000000..fe731bd48 --- /dev/null +++ b/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#createMyCredentials +description: Creates the current user's credentials for the specified strategy +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: catch +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/credentials-exist/index.md b/doc/src/controllers/auth/credentials-exist/index.md new file mode 100644 index 000000000..5b50cfc12 --- /dev/null +++ b/doc/src/controllers/auth/credentials-exist/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: credentialsExist +description: Check that the current user has credentials for the specified strategy +--- + +# credentialsExist + +Checks that the current authenticated user has credentials for the specified authentication strategy. + +
+ +```javascript +credentialsExist(strategy, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | --------------- | +| `local` |
string
| Strategy to use | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to `true` if the credentials exist, `false` otherwise. + +## Usage + +<<< ./snippets/credentials-exist.js diff --git a/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.js b/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.js new file mode 100644 index 000000000..e194679cd --- /dev/null +++ b/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.js @@ -0,0 +1,13 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const exists = await kuzzle.auth.credentialsExist('local'); + + if (exists === true) { + console.log('Credentials exist'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml b/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml new file mode 100644 index 000000000..a1e62d66d --- /dev/null +++ b/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml @@ -0,0 +1,10 @@ +name: auth#credentialsExist +description: Checks a JWT token's validity. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Credentials exist + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/delete-my-credentials/index.md b/doc/src/controllers/auth/delete-my-credentials/index.md new file mode 100644 index 000000000..a77775358 --- /dev/null +++ b/doc/src/controllers/auth/delete-my-credentials/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: deleteMyCredentials +description: Deletes credentials for a specific strategy, associated to the current user +--- + +# deleteMyCredentials + +Deletes credentials for a specific strategy associated to the current user. + +Deleting credantials, doesn't revoke existing/active JWT tokens. + +If the credentials that generated the current JWT are removed, the user will remain logged in until they log out or their session expire. After that, they will no longer be able to log in with the deleted credentials. + +
+ +```javascript +deleteMyCredentials(strategy, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +A `boolean` indicating if the credentials are being deleted. + +## Usage + +<<< ./snippets/delete-my-credentials.js diff --git a/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js b/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js new file mode 100644 index 000000000..fc0ac408b --- /dev/null +++ b/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js @@ -0,0 +1,13 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const success = await kuzzle.auth.deleteMyCredentials('local'); + console.log(success); + if (success === true) { + console.log('Credentials successfully deleted'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml b/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml new file mode 100644 index 000000000..2b5b741ae --- /dev/null +++ b/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#deleteMyCredentials +description: Deletes the current user's credentials for the specified strategy +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Credentials successfully deleted + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/get-current-user/index.md b/doc/src/controllers/auth/get-current-user/index.md new file mode 100644 index 000000000..74c7d3cf0 --- /dev/null +++ b/doc/src/controllers/auth/get-current-user/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: getCurrentUser +description: Returns the profile object for the user linked to the json web token +--- + +# getCurrentUser + +Returns information about the currently logged in user. + +
+ +```javascript +getCurrentUser([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +A [User](/sdk/js/6/user) representing the current user logged with the SDK. + +## Usage + +<<< ./snippets/get-current-user.js diff --git a/doc/src/controllers/auth/get-current-user/snippets/get-current-user.js b/doc/src/controllers/auth/get-current-user/snippets/get-current-user.js new file mode 100644 index 000000000..ee93620ed --- /dev/null +++ b/doc/src/controllers/auth/get-current-user/snippets/get-current-user.js @@ -0,0 +1,23 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.getCurrentUser(); + console.log(user); + /* + User { + _id: 'foo', + content: + { profileIds: [ 'default' ], + _kuzzle_info: + { author: '-1', + createdAt: 1540210776636, + updatedAt: null, + updater: null } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/get-current-user/snippets/get-current-user.test.yml b/doc/src/controllers/auth/get-current-user/snippets/get-current-user.test.yml new file mode 100644 index 000000000..dc3dcf93f --- /dev/null +++ b/doc/src/controllers/auth/get-current-user/snippets/get-current-user.test.yml @@ -0,0 +1,10 @@ +name: auth#getCurrentUser +description: Returns the profile object for the user linked to the `json web token` +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/get-my-credentials/index.md b/doc/src/controllers/auth/get-my-credentials/index.md new file mode 100644 index 000000000..d2f4d5cf1 --- /dev/null +++ b/doc/src/controllers/auth/get-my-credentials/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: getMyCredentials +description: Returns the current user's credential information for the specified strategy. +--- + +# getMyCredentials + +Returns credentials information for the currently logged in user. + +The returned data depends on the given authentication strategy, and should never include any sensitive information. + +The result can be an empty object. + +
+ +```javascript +getMyCredentials(strategy, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +An `object` representing the credentials for the provided authentication strategy. +Its content depends on the authentication strategy. + +## Usage + +<<< ./snippets/get-my-credentials.js diff --git a/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.js b/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.js new file mode 100644 index 000000000..6ba4e4f7a --- /dev/null +++ b/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.js @@ -0,0 +1,15 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const localCredentials = await kuzzle.auth.getMyCredentials('local'); + console.log(localCredentials); + /* + { username: 'foo', kuid: 'foo' } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml b/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml new file mode 100644 index 000000000..e43b7ca38 --- /dev/null +++ b/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#getMyCredentials +description: Returns the current user's credential information for the specified ``. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/get-my-rights/index.md b/doc/src/controllers/auth/get-my-rights/index.md new file mode 100644 index 000000000..c11b14927 --- /dev/null +++ b/doc/src/controllers/auth/get-my-rights/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: getMyRights +description: Returns the rights for the user linked to the `JSON Web Token`. +--- + +# getMyRights + +Returns the exhaustive list of granted or denied rights for the currently logged in user. + +
+ +```javascript +getMyRights([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +An `object[]` containing: + +| Property | Type | Description | +| ------------- | ----------------- | ------------------------------------------- | +| `controller` |
string
| Controller on wich the rights are applied | +| `action` |
string
| Action on wich the rights are applied | +| `index` |
string
| Index on wich the rights are applied | +|  `collection` |
string
| Collection on wich the rights are applied | +|  `value` |
string
| Rights (`allowed`, `denied`, `conditional`) | + +## Usage + +<<< ./snippets/get-my-rights.js diff --git a/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.js b/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.js new file mode 100644 index 000000000..e61d723d6 --- /dev/null +++ b/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.js @@ -0,0 +1,19 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const rights = await kuzzle.auth.getMyRights(); + console.log(rights); + /* + [ { controller: '*', + action: '*', + collection: '*', + index: '*', + value: 'allowed' } ] + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml b/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml new file mode 100644 index 000000000..059f24813 --- /dev/null +++ b/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml @@ -0,0 +1,10 @@ +name: auth#getMyRights +description: Returns the rights for the user linked to the json web token +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/get-strategies/index.md b/doc/src/controllers/auth/get-strategies/index.md new file mode 100644 index 000000000..7e0db7986 --- /dev/null +++ b/doc/src/controllers/auth/get-strategies/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: getStrategies +description: Get all authentication strategies registered in Kuzzle. +--- + +# getStrategies + +Gets the exhaustive list of registered authentication strategies. + +
+ +```javascript +getStrategies([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type | Description | Default | +| ---------- | ------------------------------- | --------------------------------- | ------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +An array of available strategies names. + +## Usage + +<<< ./snippets/get-strategies.js diff --git a/doc/src/controllers/auth/get-strategies/snippets/get-strategies.js b/doc/src/controllers/auth/get-strategies/snippets/get-strategies.js new file mode 100644 index 000000000..ad8cb4034 --- /dev/null +++ b/doc/src/controllers/auth/get-strategies/snippets/get-strategies.js @@ -0,0 +1,15 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const strategies = await kuzzle.auth.getStrategies(); + console.log(strategies); + /* + [ 'local', 'facebook' ] + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/get-strategies/snippets/get-strategies.test.yml b/doc/src/controllers/auth/get-strategies/snippets/get-strategies.test.yml new file mode 100644 index 000000000..993d67742 --- /dev/null +++ b/doc/src/controllers/auth/get-strategies/snippets/get-strategies.test.yml @@ -0,0 +1,10 @@ +name: auth#getStrategies +description: Get all authentication strategies registered in Kuzzle +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/index.md b/doc/src/controllers/auth/index.md new file mode 100644 index 000000000..f2c86af03 --- /dev/null +++ b/doc/src/controllers/auth/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: auth +description: auth controller documentation +--- diff --git a/doc/src/controllers/auth/login/index.md b/doc/src/controllers/auth/login/index.md new file mode 100644 index 000000000..3baeac2db --- /dev/null +++ b/doc/src/controllers/auth/login/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: login +description: Authenticate a user +--- + +# login + +Authenticates a user. + +
+ +```javascript +login(strategy, [credentials], [expiresIn]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | -------------------------------------------------------------------------------------- | +| `strategy` |
string
| Name of the strategy to use | +| `credentials` |
object
|  Credentials for the strategy | +| `expiresIn` |
string
|  Expiration time in [ms library](https://www.npmjs.com/package/ms) format. (e.g. `2h`) | + +#### strategy + +The name of the [authentication strategy](/core/1/guide/guides/kuzzle-depth/authentication/) used to log the user in. + +Depending on the chosen authentication strategy, additional credential arguments may be required. +The API request example in this page provides the necessary arguments for the [`local` authentication plugin](https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local). + +Check the appropriate [authentication plugin](/core/1/plugins/essentials/strategies/) documentation to get the list of additional arguments to provide. + +## Resolves + +The **login** action returns the encrypted JSON Web Token. + +## Usage + +_Local strategy login example_ + +<<< ./snippets/login.js diff --git a/doc/src/controllers/auth/login/snippets/login.js b/doc/src/controllers/auth/login/snippets/login.js new file mode 100644 index 000000000..90d725579 --- /dev/null +++ b/doc/src/controllers/auth/login/snippets/login.js @@ -0,0 +1,12 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + const jwt = await kuzzle.auth.login('local', credentials); + console.log(jwt); + /* + 'eyJhbGciOiJIUzI1NiIsIkpXVCJ9.eyJfaWQiOiJmb28iLCJpYXQiOjE.wSPmb0z2tErRdYEg' + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/login/snippets/login.test.yml b/doc/src/controllers/auth/login/snippets/login.test.yml new file mode 100644 index 000000000..8c986543f --- /dev/null +++ b/doc/src/controllers/auth/login/snippets/login.test.yml @@ -0,0 +1,11 @@ +--- +name: auth#login +description: Authenticate a user +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/logout/index.md b/doc/src/controllers/auth/logout/index.md new file mode 100644 index 000000000..594597e00 --- /dev/null +++ b/doc/src/controllers/auth/logout/index.md @@ -0,0 +1,22 @@ +--- +code: true +type: page +title: logout +description: Revokes the user's token & unsubscribe them from registered rooms. +--- + +# logout + +Revokes the user's authentication token. + +If there were any, real-time subscriptions are cancelled. + +
+ +```javascript +logout(); +``` + +## Usage + +<<< ./snippets/logout.js diff --git a/doc/src/controllers/auth/logout/snippets/logout.js b/doc/src/controllers/auth/logout/snippets/logout.js new file mode 100644 index 000000000..c5f06be4b --- /dev/null +++ b/doc/src/controllers/auth/logout/snippets/logout.js @@ -0,0 +1,11 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + await kuzzle.auth.logout(); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/logout/snippets/logout.test.yml b/doc/src/controllers/auth/logout/snippets/logout.test.yml new file mode 100644 index 000000000..cf6a09c0e --- /dev/null +++ b/doc/src/controllers/auth/logout/snippets/logout.test.yml @@ -0,0 +1,10 @@ +name: auth#logout +description: Revokes the user's token & unsubscribe them from registered rooms. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/update-my-credentials/index.md b/doc/src/controllers/auth/update-my-credentials/index.md new file mode 100644 index 000000000..04db42062 --- /dev/null +++ b/doc/src/controllers/auth/update-my-credentials/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: updateMyCredentials +description: Update the current user's credentials for the specified strategy. +--- + +# updateMyCredentials + +Updates the credentials of the currently logged in user for the specified strategy. + +
+ +```javascript +updateMyCredentials(strategy, credentials, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `credentials` |
object
| New credentials | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +An `object` representing the new credentials. +The content depends on the authentication strategy. + +## Usage + +<<< ./snippets/update-my-credentials.js diff --git a/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.js b/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.js new file mode 100644 index 000000000..faa96bf0c --- /dev/null +++ b/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.js @@ -0,0 +1,18 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const response = await kuzzle.auth.updateMyCredentials( + 'local', + { password: 'worakls' } + ); + console.log(response); + /* + { username: 'foo' } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml b/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml new file mode 100644 index 000000000..43f5545c9 --- /dev/null +++ b/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#updateMyCredentials +description: Update the current user's credentials for the specified ``. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/update-self/index.md b/doc/src/controllers/auth/update-self/index.md new file mode 100644 index 000000000..0d8c014cf --- /dev/null +++ b/doc/src/controllers/auth/update-self/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: updateSelf +description: Updates the current user object in Kuzzle. +--- + +# updateSelf + +Updates the currently logged in user content. + +This route cannot update the list of associated security profiles. To change a user's security profiles, the route [security:updateUser](/core/1/api/api-reference/controller-security/update-user/) must be used instead. + +
+ +```javascript +updateSelf(content, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ----------------------- | +| `content` |
object
| User custom information | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +A [User](/sdk/js/6/user) representing the current user logged with the SDK. + +## Usage + +<<< ./snippets/update-self.js diff --git a/doc/src/controllers/auth/update-self/snippets/update-self.js b/doc/src/controllers/auth/update-self/snippets/update-self.js new file mode 100644 index 000000000..9be64a2da --- /dev/null +++ b/doc/src/controllers/auth/update-self/snippets/update-self.js @@ -0,0 +1,24 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.updateSelf({ hungry: 'music' }); + console.log(user); + /* + User { + _id: 'foo', + content: + { profileIds: [ 'default' ], + hungry: 'music', + _kuzzle_info: + { author: '-1', + createdAt: 1540210776636, + updatedAt: null, + updater: null } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/update-self/snippets/update-self.test.yml b/doc/src/controllers/auth/update-self/snippets/update-self.test.yml new file mode 100644 index 000000000..ac9007638 --- /dev/null +++ b/doc/src/controllers/auth/update-self/snippets/update-self.test.yml @@ -0,0 +1,10 @@ +name: auth#updateSelf +description: Updates the current user object in Kuzzle +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/auth/validate-my-credentials/index.md b/doc/src/controllers/auth/validate-my-credentials/index.md new file mode 100644 index 000000000..62f7b2abf --- /dev/null +++ b/doc/src/controllers/auth/validate-my-credentials/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: validateMyCredentials +description: Validate the current user's credentials for the specified strategy. +--- + +# validateMyCredentials + +Validates the provided credentials against a specified authentication strategy. + +This route neither creates nor modifies credentials. + +
+ +```javascript +validateMyCredentials(strategy, [credentials], [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `credentials` |
object
| Credentials | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to `true` if the credentials are valid, `false` otherwise. + +## Usage + +<<< ./snippets/validate-my-credentials.js diff --git a/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js b/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js new file mode 100644 index 000000000..84a5d4b0e --- /dev/null +++ b/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js @@ -0,0 +1,13 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const valid = await kuzzle.auth.validateMyCredentials('local', credentials); + + if (valid === true) { + console.log('Credentials are valid'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml b/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml new file mode 100644 index 000000000..0f62e9367 --- /dev/null +++ b/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#validateMyCredentials +description: Validate the current user's credentials for the specified ``. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Credentials are valid + +sdk: js +version: 6 diff --git a/doc/src/controllers/bulk/import/index.md b/doc/src/controllers/bulk/import/index.md new file mode 100644 index 000000000..3dc55c05a --- /dev/null +++ b/doc/src/controllers/bulk/import/index.md @@ -0,0 +1,85 @@ +--- +code: true +type: page +title: import +description: Performs a bulk import on a collection +--- + +# Import + +Create, update or delete large amount of documents as fast as possible. + +This route is faster than the `document:m*` routes family (e.g. [document:mCreate](/sdk/js/6/controllers/document/mCreate)), but no real-time notifications will be generated, even if some of the documents in the import match subscription filters. + +If some documents actions fail, the client will receive a [PartialError](/core/1/api/essentials/errors/#partialerror) error. + +
+ +```javascript +import (bulkData, [options]) +``` + +
+ +| Arguments | Type | Description | +| ---------- | ------------------- | ----------------------------------------------- | +| `bulkData` |
object[]
| List of documents to be added to the collection | +| `options` |
object
| Query options | + +### bulkData + +This API takes a JSON array containing a list of objects working in pairs. +In each pair, the first object specifies the action to perform (the most common is `create`) and the second specifies the document itself, like in the example below: + +```javascript +[ + // The action object + { create: { _id: 'id', _index: 'index', _type: 'collection' } }, + // The document object + { myField: 'myValue', myOtherField: 'myOtherValue' }, + // Another action object + { create: { _id: 'another-id', _index: 'index', _type: 'collection' } }, + // Another document object + { myField: 'anotherValue', myOtherField: 'yetAnotherValue' } +]; +``` + +Note that the action object always has an attribute whose key specifies the action to take and whose value is an object specifying the location of ano object in the database (the `_index`, `_type` and `_id` tuple). Also note that, in Elasticsearch, the field `_type` correspond to `collection` in Kuzzle. + +Possible actions are `create`, `index`, `update`, `delete`. + +Learn more at [Elasticsearch Bulk API](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-bulk.html) + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +--- + +## Resolves + +An object containing information about the import status for each document. + +| Property | Type | Description | +| -------- | ------------------- | --------------------------------------------------- | +| `errors` |
boolean
| `true` if there is some errors with the import | +| `items` |
object[]
| Array of object containing document import statuses | + +Each object has the following structure: + +```javascript +{ + "": { + _id: "another-id", + status: 200 + } +} +``` + +## Usage + +<<< ./snippets/import.js diff --git a/doc/src/controllers/bulk/import/snippets/import.js b/doc/src/controllers/bulk/import/snippets/import.js new file mode 100644 index 000000000..91c0ebe3d --- /dev/null +++ b/doc/src/controllers/bulk/import/snippets/import.js @@ -0,0 +1,30 @@ +const bulkData = [ + { create: { _id: '1', _index: 'nyc-open-data', _type: 'yellow-taxi' } }, + { a: 'document', with: 'any', number: 'of fields' }, + { create: { _id: '2', _index: 'nyc-open-data', _type: 'yellow-taxi' } }, + { another: 'document' }, + { create: { _id: '3', _index: 'nyc-open-data', _type: 'yellow-taxi' } }, + { and: { another: 'one' } } +]; + +try { + const response = await kuzzle.bulk.import(bulkData); + console.log(response); + /* + { errors: false, + items: + [ { create: create: { + _id: "1", + status: 200 } }, + { create: create: { + _id: "2", + status: 200 } }, + { create: create: { + _id: "3", + status: 200 } } ] } + */ + + console.log(`Successfully imported ${response.length} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/bulk/import/snippets/import.test.yml b/doc/src/controllers/bulk/import/snippets/import.test.yml new file mode 100644 index 000000000..72ef6d02f --- /dev/null +++ b/doc/src/controllers/bulk/import/snippets/import.test.yml @@ -0,0 +1,13 @@ +--- +name: bulk#import +description: Bulk imports three documents into Kuzzle +hooks: + before: | + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: curl -X DELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully imported 3 documents + +sdk: js +version: 6 diff --git a/doc/src/controllers/bulk/index.md b/doc/src/controllers/bulk/index.md new file mode 100644 index 000000000..33c10f9c7 --- /dev/null +++ b/doc/src/controllers/bulk/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: bulk +description: bulk controller documentation +--- diff --git a/doc/src/controllers/collection/create/index.md b/doc/src/controllers/collection/create/index.md new file mode 100644 index 000000000..cd7be0be9 --- /dev/null +++ b/doc/src/controllers/collection/create/index.md @@ -0,0 +1,67 @@ +--- +code: true +type: page +title: create +description: Create a new collection +--- + +# create + +Creates a new [collection](/core/1/guide/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided index. + +You can also provide an optional data mapping that allow you to exploit the full capabilities of our +persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html)). + +This method will only update the mapping if the collection already exists. + +
+ +```javascript +create(index, collection, [mapping], [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `mapping` |
object
| Describes the data mapping to associate to the new collection, using Elasticsearch [mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html) | +| `options` |
object
| Query options | + +### mapping + +An object representing the data mapping of the collection. + +The mapping must have a root field `properties` that contain the mapping definition: + +```js +const mapping = { + properties: { + field1: { type: 'text' }, + field2: { + properties: { + nestedField: { type: 'keyword' } + } + } + } +}; +``` + +You can see the full list of Elasticsearch mapping types [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html). + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves if the collection is successfully created. + +## Usage + +<<< ./snippets/create.js diff --git a/doc/src/controllers/collection/create/snippets/create.js b/doc/src/controllers/collection/create/snippets/create.js new file mode 100644 index 000000000..4c10502d6 --- /dev/null +++ b/doc/src/controllers/collection/create/snippets/create.js @@ -0,0 +1,19 @@ +const mapping = { + properties: { + license: { type: 'keyword' }, + driver: { + properties: { + name: { type: 'keyword' }, + curriculum: { type: 'text' } + } + } + } +}; + +try { + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi', mapping); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/create/snippets/create.test.yml b/doc/src/controllers/collection/create/snippets/create.test.yml new file mode 100644 index 000000000..15793fcf0 --- /dev/null +++ b/doc/src/controllers/collection/create/snippets/create.test.yml @@ -0,0 +1,10 @@ +name: collection#create +description: Create a new collection +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/delete-specifications/index.md b/doc/src/controllers/collection/delete-specifications/index.md new file mode 100644 index 000000000..59d0e9e06 --- /dev/null +++ b/doc/src/controllers/collection/delete-specifications/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: deleteSpecifications +description: Delete validation specifications for a collection +--- + +# deleteSpecifications + +Deletes validation specifications for a data collection. + +
+ +```javascript +deleteSpecifications(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves if successful. + +## Usage + +<<< ./snippets/delete-specifications.js diff --git a/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.js b/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.js new file mode 100644 index 000000000..6672ffd79 --- /dev/null +++ b/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.js @@ -0,0 +1,7 @@ +try { + await kuzzle.collection.deleteSpecifications('nyc-open-data', 'yellow-taxi'); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml b/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml new file mode 100644 index 000000000..5542ecfe0 --- /dev/null +++ b/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml @@ -0,0 +1,10 @@ +name: collection#deleteSpecifications +description: Delete validation specifications for a collection +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/exists/index.md b/doc/src/controllers/collection/exists/index.md new file mode 100644 index 000000000..978df396b --- /dev/null +++ b/doc/src/controllers/collection/exists/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: exists +description: Check if collection exists +--- + +# exists + +Check if a collection exists in Kuzzle. + +
+ +```javascript +exists(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to `true` if the collection exists, `false` otherwise. + +## Usage + +<<< ./snippets/exists.js diff --git a/doc/src/controllers/collection/exists/snippets/exists.js b/doc/src/controllers/collection/exists/snippets/exists.js new file mode 100644 index 000000000..167a241af --- /dev/null +++ b/doc/src/controllers/collection/exists/snippets/exists.js @@ -0,0 +1,9 @@ +try { + const exists = kuzzle.collection.exists('nyc-open-data', 'green-taxi'); + + if (exists) { + console.log('Success'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/exists/snippets/exists.test.yml b/doc/src/controllers/collection/exists/snippets/exists.test.yml new file mode 100644 index 000000000..3c3c4e32d --- /dev/null +++ b/doc/src/controllers/collection/exists/snippets/exists.test.yml @@ -0,0 +1,10 @@ +name: collection#exists +description: Check if collection exists +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/get-mapping/index.md b/doc/src/controllers/collection/get-mapping/index.md new file mode 100644 index 000000000..dfecf3989 --- /dev/null +++ b/doc/src/controllers/collection/get-mapping/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: getMapping +description: Return collection mapping +--- + +# getMapping + +Returns a data collection mapping. + +
+ +```javascript +getMapping(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an `object` representing the collection mapping. + +## Usage + +<<< ./snippets/get-mapping.js diff --git a/doc/src/controllers/collection/get-mapping/snippets/get-mapping.js b/doc/src/controllers/collection/get-mapping/snippets/get-mapping.js new file mode 100644 index 000000000..0505683f1 --- /dev/null +++ b/doc/src/controllers/collection/get-mapping/snippets/get-mapping.js @@ -0,0 +1,21 @@ +try { + const mapping = await kuzzle.collection.getMapping('nyc-open-data', 'yellow-taxi'); + console.log(mapping); + /* + { + properties: { + license: { type: 'keyword' }, + driver: { + properties: { + name: { type: 'keyword' }, + curriculum: { type: 'text' } + } + } + } + } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/get-mapping/snippets/get-mapping.test.yml b/doc/src/controllers/collection/get-mapping/snippets/get-mapping.test.yml new file mode 100644 index 000000000..3d0570200 --- /dev/null +++ b/doc/src/controllers/collection/get-mapping/snippets/get-mapping.test.yml @@ -0,0 +1,10 @@ +name: collection#getMapping +description: Return collection mapping +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/get-specifications/index.md b/doc/src/controllers/collection/get-specifications/index.md new file mode 100644 index 000000000..ff539a900 --- /dev/null +++ b/doc/src/controllers/collection/get-specifications/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: getSpecifications +description: Returns the validation specifications +--- + +# getSpecifications + +Returns the validation specifications associated to the given index and collection. + +
+ +```javascript +getSpecifications(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve to an object representing the collection specifications. + +## Usage + +<<< ./snippets/get-specifications.js diff --git a/doc/src/controllers/collection/get-specifications/snippets/get-specifications.js b/doc/src/controllers/collection/get-specifications/snippets/get-specifications.js new file mode 100644 index 000000000..14d0f14c7 --- /dev/null +++ b/doc/src/controllers/collection/get-specifications/snippets/get-specifications.js @@ -0,0 +1,23 @@ +try { + const specifications = await kuzzle.collection.getSpecifications('nyc-open-data', 'yellow-taxi'); + console.log(specifications); + /* + { + "collection": "yellow-taxi", + "index": "nyc-open-data", + "validation": { + "fields": { + "age": { + "defaultValue": 42, + "mandatory": true, + "type": "integer" + } + }, + "strict": true + } + } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/get-specifications/snippets/get-specifications.test.yml b/doc/src/controllers/collection/get-specifications/snippets/get-specifications.test.yml new file mode 100644 index 000000000..a50f49c51 --- /dev/null +++ b/doc/src/controllers/collection/get-specifications/snippets/get-specifications.test.yml @@ -0,0 +1,9 @@ +name: collection#getSpecifications +description: Returns the validation specifications +hooks: + before: "curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi && curl -X PUT -H \"Content-Type: application/json\" -d '{\"nyc-open-data\": {\"yellow-taxi\": {\"strict\": false,\"fields\": {\"license\": {\"type\": \"string\"}}}}}' kuzzle:7512/_specifications" + after: +template: default +expected: Success +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/index.md b/doc/src/controllers/collection/index.md new file mode 100644 index 000000000..a263a05db --- /dev/null +++ b/doc/src/controllers/collection/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: collection +description: collection controller documentation +--- diff --git a/doc/src/controllers/collection/list/index.md b/doc/src/controllers/collection/list/index.md new file mode 100644 index 000000000..5da2329dc --- /dev/null +++ b/doc/src/controllers/collection/list/index.md @@ -0,0 +1,56 @@ +--- +code: true +type: page +title: list +description: Returns the collection list of an index +--- + +# list + +Returns the list of data collections associated to a provided data index. +The returned list is sorted in alphanumerical order. + +
+ +```javascript +list(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `from` |
number

(`0`) | Offset of the first result | +| `size` |
number

(`10`) | Maximum number of returned results | + +## Resolves + +Resolves to an object containing the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ------------------------------------------------------------------ | +| `type` |
string
| Types of returned collections
(`all`, `realtime` or `stored`) | +| `collections` |
object[]
| List of collections | +| `from` |
number
| Offset of the first result | +| `size` |
number
| Maximum number of returned results | + +Each object in the `collections` array contains the following properties: + +| Property | Type | Description | +| -------- | ----------------- | ---------------------------------------- | +| `name` |
string
| Collection name | +| `type` |
string
| Collection type (`realtime` or `stored`) | + +## Usage + +<<< ./snippets/list.js diff --git a/doc/src/controllers/collection/list/snippets/list.js b/doc/src/controllers/collection/list/snippets/list.js new file mode 100644 index 000000000..aa6388f3c --- /dev/null +++ b/doc/src/controllers/collection/list/snippets/list.js @@ -0,0 +1,18 @@ +try { + const options = { from: 1, size: 1 }; + + const collectionList = await kuzzle.collection.list('mtp-open-data', options); + console.log(collectionList); + /* + { + type: 'all', + collections: [ { name: 'pink-taxi', type: 'stored' } ], + from: 1, + size: 1 + } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/list/snippets/list.test.yml b/doc/src/controllers/collection/list/snippets/list.test.yml new file mode 100644 index 000000000..39641aa7b --- /dev/null +++ b/doc/src/controllers/collection/list/snippets/list.test.yml @@ -0,0 +1,10 @@ +name: collection#list +description: Returns the collection list of an index +hooks: + before: curl -X POST kuzzle:7512/mtp-open-data/_create && curl -X PUT kuzzle:7512/mtp-open-data/pink-taxi && curl -X PUT kuzzle:7512/mtp-open-data/dark-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/search-specifications/index.md b/doc/src/controllers/collection/search-specifications/index.md new file mode 100644 index 000000000..d93f4d349 --- /dev/null +++ b/doc/src/controllers/collection/search-specifications/index.md @@ -0,0 +1,70 @@ +--- +code: true +type: page +title: searchSpecifications +description: Search for specifications +--- + +# searchSpecifications + + + +Searches collection specifications. + +There is a limit to how many items can be returned by a single search query. +That limit is by default set at 10000, and you can't get over it even with the from and size pagination options. + +
+ When processing a large number of items (i.e. more than 1000), it is advised to paginate the results using SearchResult.next rather than increasing the size parameter. +
+ +
+ +```javascript +searchSpecifications([body], [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------------------- | +| `body` |
object
| An object containing the search query | +| `options` |
object
| Query options | + +### body + +The body is a set of filters using [Elasticsearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-body.html) to match the documents you are looking for. +The filters must be inside the `query` property of the body. + +Example: + +```js +const body = { + query: { + match_all: { + boost: 1 + } + } +}; +``` + +### options + +| Arguments | Type | Description | +| ---------- | ------------------------------- | ------------------------------------ | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | +| `from` |
number

(`0`) | Offset of the first document | +| `size` |
number

(`10`) | Maximum number of documents returned | +| `scroll` |
string

| Maximum duration for scroll session | + +- `size` controls the maximum number of documents returned in the response +- `from` is usually used with the `size` argument, and defines the offset from the first result you want to fetch +- `scroll` is used to fetch large result sets, and it must be set with a [time duration](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#time-units). If set, a forward-only cursor will be created (and automatically destroyed at the end of the set duration), and its identifier will be returned in the `scrollId` property, along with the first page of the results. + +## Resolves + +Resolve to a [SpecificationsSearchResult](/sdk/js/6/search-result). + +## Usage + +<<< ./snippets/search-specifications.js diff --git a/doc/src/controllers/collection/search-specifications/snippets/search-specifications.js b/doc/src/controllers/collection/search-specifications/snippets/search-specifications.js new file mode 100644 index 000000000..af3c1bb4b --- /dev/null +++ b/doc/src/controllers/collection/search-specifications/snippets/search-specifications.js @@ -0,0 +1,47 @@ +try { + const body = { + query: { + match_all: { + boost: 1 + } + } + }; + + const options = { + size: 50, + offset: 0, + scroll: '10m' + }; + + const searchResult = await kuzzle.collection.searchSpecifications(body, options); + console.log(searchResult); + /* + { + "total": 1, + "max_score": 1, + "hits": [ + { + "_index": "%kuzzle", + "_type": "validations", + "_id": "nyc-open-data#yellow-taxi", + "_score": 1, + "_source": { + "validation": { + "strict": false, + "fields": { + "license": { + "type": "string" + } + } + }, + "index": "nyc-open-data", + "collection": "yellow-taxi" + } + } + ], + "scrollId": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAACSFlgtZTJFYjNiU1FxQzhSNUFpNlZHZGcAAAAAAAAAkxZYLWUyRWIzYlNRcUM4UjVBaTZWR2RnAAAAAAAAAJQWWC1lMkViM2JTUXFDOFI1QWk2VkdkZwAAAAAAAACVFlgtZTJFYjNiU1FxQzhSNUFpNlZHZGcAAAAAAAAAlhZYLWUyRWIzYlNRcUM4UjVBaTZWR2Rn" + } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/search-specifications/snippets/search-specifications.test.yml b/doc/src/controllers/collection/search-specifications/snippets/search-specifications.test.yml new file mode 100644 index 000000000..920b4e2f3 --- /dev/null +++ b/doc/src/controllers/collection/search-specifications/snippets/search-specifications.test.yml @@ -0,0 +1,24 @@ +name: collection#searchSpecifications +description: Search for specifications +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -X PUT -H "Content-Type: application/json" -d '{ + "nyc-open-data": { + "yellow-taxi": { + "strict": false, + "fields": { + "license": { + "type": "string" + } + } + } + } + }' kuzzle:7512/_specifications?refresh=wait_for + after: +template: default +expected: 'fetched: 1' +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/truncate/index.md b/doc/src/controllers/collection/truncate/index.md new file mode 100644 index 000000000..e86c4dab1 --- /dev/null +++ b/doc/src/controllers/collection/truncate/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: truncate +description: Remove all documents from collection +--- + +# truncate + +Removes all documents from a data collection, while keeping the associated mapping. + +
+ +```javascript +truncate(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves when the collection is successfully truncated. + +## Usage + +<<< ./snippets/truncate.js diff --git a/doc/src/controllers/collection/truncate/snippets/truncate.js b/doc/src/controllers/collection/truncate/snippets/truncate.js new file mode 100644 index 000000000..84c9f8ff1 --- /dev/null +++ b/doc/src/controllers/collection/truncate/snippets/truncate.js @@ -0,0 +1,7 @@ +try { + await kuzzle.collection.truncate('nyc-open-data', 'yellow-taxi'); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/truncate/snippets/truncate.test.yml b/doc/src/controllers/collection/truncate/snippets/truncate.test.yml new file mode 100644 index 000000000..f34edd066 --- /dev/null +++ b/doc/src/controllers/collection/truncate/snippets/truncate.test.yml @@ -0,0 +1,10 @@ +name: collection#truncate +description: Remove all documents from collection +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/update-mapping/index.md b/doc/src/controllers/collection/update-mapping/index.md new file mode 100644 index 000000000..2f50650b2 --- /dev/null +++ b/doc/src/controllers/collection/update-mapping/index.md @@ -0,0 +1,62 @@ +--- +code: true +type: page +title: updateMapping +description: Update the collection mapping +--- + +# updateMapping + +Updates a data collection mapping. + +
+ +```javascript +updateMapping(index, collection, mapping, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `mapping` |
object
| Describes the data mapping to associate to the new collection, using Elasticsearch [mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html) | +| `options` |
object
| Query options | + +### mapping + +An object representing the collection data mapping. + +This object must have a root field `properties` that contain the mapping definition: + +```javascript +const mapping = { + properties: { + field1: { type: 'text' }, + field2: { + properties: { + nestedField: { type: 'keyword' } + } + } + } +}; +``` + +You can see the full list of Elasticsearch mapping types [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-types.html). + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve if the collection is successfully updated. + +## Usage + +<<< ./snippets/update-mapping.js diff --git a/doc/src/controllers/collection/update-mapping/snippets/update-mapping.js b/doc/src/controllers/collection/update-mapping/snippets/update-mapping.js new file mode 100644 index 000000000..0f37af87f --- /dev/null +++ b/doc/src/controllers/collection/update-mapping/snippets/update-mapping.js @@ -0,0 +1,13 @@ +const mapping = { + properties: { + plate: { type: 'keyword' } + } +}; + +try { + await kuzzle.collection.updateMapping('nyc-open-data', 'yellow-taxi', mapping); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/update-mapping/snippets/update-mapping.test.yml b/doc/src/controllers/collection/update-mapping/snippets/update-mapping.test.yml new file mode 100644 index 000000000..272e5e002 --- /dev/null +++ b/doc/src/controllers/collection/update-mapping/snippets/update-mapping.test.yml @@ -0,0 +1,10 @@ +name: collection#updateMapping +description: Update the collection mapping +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/update-specifications/index.md b/doc/src/controllers/collection/update-specifications/index.md new file mode 100644 index 000000000..54595e73b --- /dev/null +++ b/doc/src/controllers/collection/update-specifications/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: updateSpecifications +description: Update the validation specifications +--- + +# updateSpecifications + +The updateSpecifications method allows you to create or update the validation specifications for a collection. + +When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug. + +
+ +```javascript +updateSpecifications(index, collection, specifications, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------------- | ----------------- | ------------------------ | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `specifications` |
object
| Specifications to update | +| `options` |
object
| Query options | + +### specifications + +An object representing the specifications. + +This object must follow the [Specification Structure](/core/1/guide/guides/essentials/data-validation/): + +```js +{ + strict: , + fields: { + // ... specification for each field + } +} +``` + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve to an object containing the specifications. + +## Usage + +<<< ./snippets/update-specifications.js diff --git a/doc/src/controllers/collection/update-specifications/snippets/update-specifications.js b/doc/src/controllers/collection/update-specifications/snippets/update-specifications.js new file mode 100644 index 000000000..af495e99a --- /dev/null +++ b/doc/src/controllers/collection/update-specifications/snippets/update-specifications.js @@ -0,0 +1,25 @@ +const specifications = { + strict: false, + fields: { + license: { + mandatory: true, + type: 'string' + } + } +}; + +try { + const result = await kuzzle.collection.updateSpecifications('nyc-open-data', 'yellow-taxi', specifications); + console.log(result); + /* + { strict: false, + fields: { + license: { + mandatory: true, + type: 'string' } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/update-specifications/snippets/update-specifications.test.yml b/doc/src/controllers/collection/update-specifications/snippets/update-specifications.test.yml new file mode 100644 index 000000000..9a9ef7582 --- /dev/null +++ b/doc/src/controllers/collection/update-specifications/snippets/update-specifications.test.yml @@ -0,0 +1,10 @@ +name: collection#updateSpecifications +description: Update the validation specifications +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi + after: curl -X DELETE kuzzle:7512/nyc-open-data/yellow-taxi/_specifications +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/collection/validate-specifications/index.md b/doc/src/controllers/collection/validate-specifications/index.md new file mode 100644 index 000000000..4c24b5606 --- /dev/null +++ b/doc/src/controllers/collection/validate-specifications/index.md @@ -0,0 +1,66 @@ +--- +code: true +type: page +title: validateSpecifications +description: Validate specifications format +--- + +# validateSpecifications + +The validateSpecifications method checks if a validation specification is well formatted. It does not store or modify the existing specification. + +When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug. + +
+ +```javascript +validateSpecifications(index, collection, specifications, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------------- | ----------------- | -------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `specifications` |
object
| Specifications to validate | +| `options` |
object
| Query options | + +### specifications + +An object representing the specifications. + +This object must follow the [Specification Structure](/core/1/guide/datavalidation): + +```js +{ + strict: , + fields: { + // ... specification for each field + } +} +``` + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an object which contain information about the specifications validity. + +It contains the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ---------------------------- | +| `valid` |
boolean
| Specifications validity | +| `details` |
string[]
| Specifications errors | +| `description` |
string
| Global description of errors | + +## Usage + +<<< ./snippets/validate-specifications.js diff --git a/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.js b/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.js new file mode 100644 index 000000000..772108c04 --- /dev/null +++ b/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.js @@ -0,0 +1,29 @@ +try { + const specifications = { + strict: false, + fields: { + license: { + mandatory: true, + type: 'symbol' // symbol is not a recognized type + } + } + }; + + const result = await kuzzle.collection.validateSpecifications('nyc-open-data', 'yellow-taxi', specifications); + console.log(result); + /* + { + valid: false, + details: [ + 'In nyc-open-data.yellow-taxi.license: symbol is not a recognized type.' + ], + description: 'Some errors with provided specifications.' + } + */ + + if (result.valid === false) { + console.log(result.description); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml b/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml new file mode 100644 index 000000000..9f7b8a750 --- /dev/null +++ b/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml @@ -0,0 +1,10 @@ +name: collection#validateSpecifications +description: Validate specifications format +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi + after: +template: default +expected: Some errors with provided specifications. + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/count/index.md b/doc/src/controllers/document/count/index.md new file mode 100644 index 000000000..dbde718c8 --- /dev/null +++ b/doc/src/controllers/document/count/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: count +description: Count documents matching the given query +--- + +# count + +Counts documents in a data collection. + +A query can be provided to alter the count result, otherwise returns the total number of documents in the data collection. + +Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax. + +
+ +```javascript +count(index, collection, query, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `query` |
object
| Query to match | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to the number of matched documents. + +## Usage + +<<< ./snippets/count.js diff --git a/doc/src/controllers/document/count/snippets/count.js b/doc/src/controllers/document/count/snippets/count.js new file mode 100644 index 000000000..ae59873a8 --- /dev/null +++ b/doc/src/controllers/document/count/snippets/count.js @@ -0,0 +1,15 @@ +try { + const count = await kuzzle.document.count( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { license: 'valid' } + } + } + ); + + console.log(`Found ${count} documents matching license:valid`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/count/snippets/count.test.yml b/doc/src/controllers/document/count/snippets/count.test.yml new file mode 100644 index 000000000..0ff409fe9 --- /dev/null +++ b/doc/src/controllers/document/count/snippets/count.test.yml @@ -0,0 +1,22 @@ +--- +name: document#count +description: Count documents matching the given query +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"license": "valid"}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + curl -XPOST kuzzle:7512/nyc-open-data/_refresh + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Found 5 documents matching license:valid + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/create/index.md b/doc/src/controllers/document/create/index.md new file mode 100644 index 000000000..c27ca936b --- /dev/null +++ b/doc/src/controllers/document/create/index.md @@ -0,0 +1,51 @@ +--- +code: true +type: page +title: create +description: Create a new document +--- + +# create + +Creates a new document in the persistent data storage. + +Throws an error if the document already exists. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (indexed documents are available for `search`). + +
+ +```javascript +create(index, collection, document, [id], [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | -------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `document` |
object
| Document content | +| `id` |
string
| Optional document ID | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the document creation result. + +| Name | Type | Description | +| --------- | ----------------- | ------------------------------------------------------ | +| \_id |
string
| ID of the newly created document | +| \_version |
number
| Version of the document in the persistent data storage | +| \_source |
object
| Created document | + +## Usage + +<<< ./snippets/create.js diff --git a/doc/src/controllers/document/create/snippets/create.js b/doc/src/controllers/document/create/snippets/create.js new file mode 100644 index 000000000..b9dccf166 --- /dev/null +++ b/doc/src/controllers/document/create/snippets/create.js @@ -0,0 +1,33 @@ +try { + const response = await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + { lastName: 'Eggins' }, + 'some-id' + ); + + if (response._id === 'some-id') { + console.log('Success'); + } + /* + response = + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 1, + result: 'created', + _shards: { total: 2, successful: 1, failed: 0 }, + created: true, + _source: + { lastName: 'Eggins', + _kuzzle_info: + { author: '-1', + createdAt: 1537443212089, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/create/snippets/create.test.yml b/doc/src/controllers/document/create/snippets/create.test.yml new file mode 100644 index 000000000..a70c73244 --- /dev/null +++ b/doc/src/controllers/document/create/snippets/create.test.yml @@ -0,0 +1,14 @@ +name: document#create +description: Create a new document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/createOrReplace/index.md b/doc/src/controllers/document/createOrReplace/index.md new file mode 100644 index 000000000..d3b9e859e --- /dev/null +++ b/doc/src/controllers/document/createOrReplace/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: createOrReplace +description: Creates or replaces a document +--- + +# createOrReplace + +Creates a new document in the persistent data storage, or replaces its content if it already exists. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (indexed documents are available for `search`). + +
+ +```javascript +createOrReplace(index, collection, id, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | ---------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `document` |
object
| Document content | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the document creation result. + +| Name | Type | Description | +| --------- | ----------------- | ---------------------------------------------------------- | +| \_id |
string
| The id of the newly created document | +| \_version |
number
| The version of the document in the persistent data storage | +| \_source |
object
| The created document | + +## Usage + +<<< ./snippets/create-or-replace.js diff --git a/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.js b/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.js new file mode 100644 index 000000000..0aeac5744 --- /dev/null +++ b/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.js @@ -0,0 +1,33 @@ +try { + const response = await kuzzle.document.createOrReplace( + 'nyc-open-data', + 'yellow-taxi', + 'some-id', + { lastName: 'McHan' } + ); + + if (response._id === 'some-id') { + console.log('Success'); + } + /* + response = + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 1, + result: 'created', + _shards: { total: 2, successful: 1, failed: 0 }, + created: true, + _source: + { lastName: 'McHan', + _kuzzle_info: + { author: '-1', + createdAt: 1537443212089, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.test.yml b/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.test.yml new file mode 100644 index 000000000..a6302a57c --- /dev/null +++ b/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.test.yml @@ -0,0 +1,14 @@ +name: document#createOrReplace +description: Creates or replaces a document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/delete/index.md b/doc/src/controllers/document/delete/index.md new file mode 100644 index 000000000..0ad458677 --- /dev/null +++ b/doc/src/controllers/document/delete/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: delete +description: Deletes a document from kuzzle +--- + +# delete + +Deletes a document. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (and to no longer be available in search). + +
+ +```javascript +delete (index, collection, id, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to the id of the deleted document. + +## Usage + +<<< ./snippets/delete.js diff --git a/doc/src/controllers/document/delete/snippets/delete.js b/doc/src/controllers/document/delete/snippets/delete.js new file mode 100644 index 000000000..a1700237a --- /dev/null +++ b/doc/src/controllers/document/delete/snippets/delete.js @@ -0,0 +1,9 @@ +try { + const id = await kuzzle.document.delete('nyc-open-data', 'yellow-taxi', 'some-id'); + + if (id === 'some-id') { + console.log('Success'); + } +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/document/delete/snippets/delete.test.yml b/doc/src/controllers/document/delete/snippets/delete.test.yml new file mode 100644 index 000000000..3b885c736 --- /dev/null +++ b/doc/src/controllers/document/delete/snippets/delete.test.yml @@ -0,0 +1,15 @@ +name: document#delete +description: Deletes a document from kuzzle +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -H "Content-type: application/json" -XPUT -d '{}' kuzzle:7512/nyc-open-data/yellow-taxi/some-id + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/deleteByQuery/index.md b/doc/src/controllers/document/deleteByQuery/index.md new file mode 100644 index 000000000..47e3bffab --- /dev/null +++ b/doc/src/controllers/document/deleteByQuery/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: deleteByQuery +description: Delete documents matching query +--- + +# deleteByQuery + +Deletes documents matching the provided search query. + +Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax. + +An empty or null query will match all documents in the collection. + +
+ +```javascript +deleteByQuery(index, collection, [query], [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `query` |
object
| Query to match | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an array of strings containing the deleted document ids. + +## Usage + +<<< ./snippets/delete-by-query.js diff --git a/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.js b/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.js new file mode 100644 index 000000000..ad36861b6 --- /dev/null +++ b/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.js @@ -0,0 +1,15 @@ +try { + const deleted = await kuzzle.document.deleteByQuery( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + term: { capacity: 7 } + } + } + ); + + console.log(`Successfully deleted ${deleted.length} documents`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml b/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml new file mode 100644 index 000000000..f7889d668 --- /dev/null +++ b/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml @@ -0,0 +1,24 @@ +name: document#deleteByQuery +description: Delete documents matching query +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"capacity": 4}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"capacity": 7}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + + curl -XPOST kuzzle:7512/nyc-open-data/_refresh + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully deleted 5 documents + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/get/index.md b/doc/src/controllers/document/get/index.md new file mode 100644 index 000000000..f1ba3b924 --- /dev/null +++ b/doc/src/controllers/document/get/index.md @@ -0,0 +1,37 @@ +--- +code: true +type: page +title: get +description: Get a document from kuzzle +--- + +# get + +Gets a document. + +
+ +```javascript +get(index, collection, id, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +## Usage + +<<< ./snippets/get.js diff --git a/doc/src/controllers/document/get/snippets/get.js b/doc/src/controllers/document/get/snippets/get.js new file mode 100644 index 000000000..e5e33c88e --- /dev/null +++ b/doc/src/controllers/document/get/snippets/get.js @@ -0,0 +1,30 @@ +try { + await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + { capacity: 4 }, + 'some-id' + ); + + const response = await kuzzle.document.get('nyc-open-data', 'yellow-taxi', 'some-id'); + /* + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 1, + found: true, + _source: + { capacity: 4, + _kuzzle_info: + { author: '-1', + createdAt: 1538409095673, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/get/snippets/get.test.yml b/doc/src/controllers/document/get/snippets/get.test.yml new file mode 100644 index 000000000..8ba2e38a2 --- /dev/null +++ b/doc/src/controllers/document/get/snippets/get.test.yml @@ -0,0 +1,14 @@ +name: document#get +description: Get a document from kuzzle +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/index.md b/doc/src/controllers/document/index.md new file mode 100644 index 000000000..e06e625ab --- /dev/null +++ b/doc/src/controllers/document/index.md @@ -0,0 +1,8 @@ +--- +code: true +type: branch +title: document +description: Document controller +--- + +# Document Controller diff --git a/doc/src/controllers/document/mCreate/index.md b/doc/src/controllers/document/mCreate/index.md new file mode 100644 index 000000000..5cf504870 --- /dev/null +++ b/doc/src/controllers/document/mCreate/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mCreate +description: Create multiple documents in kuzzle +--- + +# mCreate + +Creates multiple documents. + +Throws a partial error (error code 206) if one or more documents creations fail. + +
+ +```javascript +mCreate(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to create | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing created documents. + +| Property | Type | Description | +| -------- | --------------- | --------------------------------- | +| `hits` | `array` | Created documents | +| `total` | `number` | Total number of created documents | + +## Usage + +<<< ./snippets/m-create.js diff --git a/doc/src/controllers/document/mCreate/snippets/m-create.js b/doc/src/controllers/document/mCreate/snippets/m-create.js new file mode 100644 index 000000000..d3446a457 --- /dev/null +++ b/doc/src/controllers/document/mCreate/snippets/m-create.js @@ -0,0 +1,78 @@ +try { + const documents = [ + { + _id: 'some-id', + body: { 'capacity': 4 } + }, + { + body: { this: 'document id is auto-computed' } + } + ]; + const response = await kuzzle.document.mCreate( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(response); + /* + { + "hits": [ + { + "_id": "some-id", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036563677 + }, + "capacity": 4 + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + }, + { + "_id": "AWcIiqbeBiYFF8kkRLKg", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036563677 + }, + "this": "document id is auto-computed" + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + } + ], + "total": 2 + } + */ + console.log(`Successfully created ${response.total} documents`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/document/mCreate/snippets/m-create.test.yml b/doc/src/controllers/document/mCreate/snippets/m-create.test.yml new file mode 100644 index 000000000..f1007f6bf --- /dev/null +++ b/doc/src/controllers/document/mCreate/snippets/m-create.test.yml @@ -0,0 +1,14 @@ +name: document#mCreate +description: Create multiple documents in kuzzle +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully created 2 documents + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/mCreateOrReplace/index.md b/doc/src/controllers/document/mCreateOrReplace/index.md new file mode 100644 index 000000000..2d2ab6465 --- /dev/null +++ b/doc/src/controllers/document/mCreateOrReplace/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mCreateOrReplace +description: Create or replace documents +--- + +# mCreateOrReplace + +Creates or replaces multiple documents. + +Throws a partial error (error code 206) if one or more document creations/replacements fail. + +
+ +```javascript +mCreateOrReplace(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to create | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing created documents. + +| Property | Type | Description | +| -------- | --------------- | --------------------------------- | +| `hits` | `array` | Created documents | +| `total` | `number` | Total number of created documents | + +## Usage + +<<< ./snippets/m-create-or-replace.js diff --git a/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js b/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js new file mode 100644 index 000000000..5bc7e3011 --- /dev/null +++ b/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js @@ -0,0 +1,80 @@ +try { + const documents = [ + { + _id: 'some-id', + body: { 'capacity': 4 } + }, + { + _id: 'some-other-id', + body: { 'capacity': 4 } + } + ]; + + const response = await kuzzle.document.mCreateOrReplace( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(JSON.stringify(response)); + /* + { + "hits": [ + { + "_id": "some-id", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036740596 + }, + "capacity": 4 + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + }, + { + "_id": "some-other-id", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036740596 + }, + "capacity": 4 + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + } + ], + "total": 2 + } + */ + console.log(`Successfully createOrReplace ${response.total} documents`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml b/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml new file mode 100644 index 000000000..c12b79ed6 --- /dev/null +++ b/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml @@ -0,0 +1,14 @@ +name: document#mCreateOrReplace +description: Create or replace documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully createOrReplace 2 documents + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/mDelete/index.md b/doc/src/controllers/document/mDelete/index.md new file mode 100644 index 000000000..6bef0490f --- /dev/null +++ b/doc/src/controllers/document/mDelete/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: mDelete +description: Delete documents +--- + +# mDelete + +Deletes multiple documents. + +Throws a partial error (error code 206) if one or more document deletions fail. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document indexation (indexed documents are available for `search`). + +
+ +```javascript +mDelete(index, collection, ids, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ------------------------------ | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `ids` | `array` | IDs of the documents to delete | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an array of objects representing the deleted documents. + +## Usage + +<<< ./snippets/m-delete.js diff --git a/doc/src/controllers/document/mDelete/snippets/m-delete.js b/doc/src/controllers/document/mDelete/snippets/m-delete.js new file mode 100644 index 000000000..5a865a222 --- /dev/null +++ b/doc/src/controllers/document/mDelete/snippets/m-delete.js @@ -0,0 +1,14 @@ +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-other-id'); + + const deleted = await kuzzle.document.mDelete( + 'nyc-open-data', + 'yellow-taxi', + ['some-id', 'some-other-id'] + ); + + console.log(`Successfully deleted ${deleted.length} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/mDelete/snippets/m-delete.test.yml b/doc/src/controllers/document/mDelete/snippets/m-delete.test.yml new file mode 100644 index 000000000..70ef6ef2d --- /dev/null +++ b/doc/src/controllers/document/mDelete/snippets/m-delete.test.yml @@ -0,0 +1,14 @@ +name: document#mDelete +description: Delete documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully deleted 2 documents + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/mGet/index.md b/doc/src/controllers/document/mGet/index.md new file mode 100644 index 000000000..20cb5730c --- /dev/null +++ b/doc/src/controllers/document/mGet/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: mGet +description: Get multiple documents +--- + +# mGet + +Gets multiple documents. + +Throws a partial error (error code 206) if one or more document can not be retrieved. + +
+ +```javascript +mGet(index, collection, ids, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | --------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `ids` | `array` | Document ids | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an object containing the retrieved documents. + +| Property | Type | Description | +| -------- | --------------- | ------------------------- | +| `hits` | `array` | Retrieved documents | +| `total` | `number` | Total retrieved documents | + +## Usage + +<<< ./snippets/m-get.js diff --git a/doc/src/controllers/document/mGet/snippets/m-get.js b/doc/src/controllers/document/mGet/snippets/m-get.js new file mode 100644 index 000000000..bca631dac --- /dev/null +++ b/doc/src/controllers/document/mGet/snippets/m-get.js @@ -0,0 +1,61 @@ +const doc1 = { capacity: 4 }; +const doc2 = { capacity: 7 }; + +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc1, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc2, 'some-other-id'); + + const response = await kuzzle.document.mGet( + 'nyc-open-data', + 'yellow-taxi', + ['some-id', 'some-other-id'] + ); + + console.log(response); + /* + { + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "some-id", + "_version": 1, + "found": true, + "_source": { + "capacity": 4, + "_kuzzle_info": { + "author": "-1", + "createdAt": 1542036871353, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "some-other-id", + "_version": 1, + "found": true, + "_source": { + "capacity": 7, + "_kuzzle_info": { + "author": "-1", + "createdAt": 1542036871374, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + } + ], + "total": 2 + } + */ + console.log(`Successfully get ${response.total} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/mGet/snippets/m-get.test.yml b/doc/src/controllers/document/mGet/snippets/m-get.test.yml new file mode 100644 index 000000000..d5222f8aa --- /dev/null +++ b/doc/src/controllers/document/mGet/snippets/m-get.test.yml @@ -0,0 +1,14 @@ +name: document#mGet +description: Get multiple documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully get 2 documents + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/mReplace/index.md b/doc/src/controllers/document/mReplace/index.md new file mode 100644 index 000000000..d2fa11d22 --- /dev/null +++ b/doc/src/controllers/document/mReplace/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mReplace +description: Replace documents +--- + +# mReplace + +Replaces multiple documents. + +Throws a partial error (error code 206) if one or more documents can not be replaced. + +
+ +```javascript +mReplace(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to update | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the replaced documents. + +| Property | Type | Description | +| -------- | --------------- | ------------------------ | +| `hits` | `array` | Replaced documents | +| `total` | `number` | Total replaced documents | + +## Usage + +<<< ./snippets/m-replace.js diff --git a/doc/src/controllers/document/mReplace/snippets/m-replace.js b/doc/src/controllers/document/mReplace/snippets/m-replace.js new file mode 100644 index 000000000..52a1821e3 --- /dev/null +++ b/doc/src/controllers/document/mReplace/snippets/m-replace.js @@ -0,0 +1,64 @@ +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-other-id'); + + const documents = [ + { + _id: 'some-id', + body: { capacity: 4 } + }, + { + _id: 'some-other-id', + body: { capacity: 4 } + } + ]; + + const response = await kuzzle.document.mReplace( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(response); + /* + { hits: + [ { _id: 'some-id', + _source: + { _kuzzle_info: + { active: true, + author: '-1', + updater: null, + updatedAt: null, + deletedAt: null, + createdAt: 1538639586995 }, + capacity: 4 }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 }, + { _id: 'some-other-id', + _source: + { _kuzzle_info: + { active: true, + author: '-1', + updater: null, + updatedAt: null, + deletedAt: null, + createdAt: 1538639586995 }, + capacity: 4 }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 } ], + total: 2 } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/mReplace/snippets/m-replace.test.yml b/doc/src/controllers/document/mReplace/snippets/m-replace.test.yml new file mode 100644 index 000000000..fe7320540 --- /dev/null +++ b/doc/src/controllers/document/mReplace/snippets/m-replace.test.yml @@ -0,0 +1,14 @@ +name: document#mReplace +description: Replace documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/mUpdate/index.md b/doc/src/controllers/document/mUpdate/index.md new file mode 100644 index 000000000..c6ce22d3c --- /dev/null +++ b/doc/src/controllers/document/mUpdate/index.md @@ -0,0 +1,52 @@ +--- +code: true +type: page +title: mUpdate +description: Update documents +--- + +# mUpdate + +Updates multiple documents. + +Returns a partial error (error code 206) if one or more documents can not be updated. + +Conflicts may occur if the same document gets updated multiple times within a short timespan in a database cluster. + +You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error. + +
+ +```javascript +mUpdate(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to update | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ----------------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | +| `retryOnConflict` | `int`
(`0`) | The number of times the database layer should retry in case of version conflict | + +## Resolves + +Resolves to an object containing the updated documents. + +| Property | Type | Description | +| -------- | --------------- | ----------------------- | +| `hits` | `array` | Updated documents | +| `total` | `number` | Total updated documents | + +## Usage + +<<< ./snippets/m-update.js diff --git a/doc/src/controllers/document/mUpdate/snippets/m-update.js b/doc/src/controllers/document/mUpdate/snippets/m-update.js new file mode 100644 index 000000000..10a7910b9 --- /dev/null +++ b/doc/src/controllers/document/mUpdate/snippets/m-update.js @@ -0,0 +1,51 @@ +const doc1 = { capacity: 4 }; +const doc2 = { capacity: 7 }; + +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc1, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc2, 'some-other-id'); + + const documents = [ + { + _id: 'some-id', + body: { category: 'sedan' } + }, + { + _id: 'some-other-id', + body: { category: 'limousine' } + } + ]; + + const response = await kuzzle.document.mReplace( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(response); + /* + { hits: + [ { _id: 'some-id', + _source: { _kuzzle_info: [Object], category: 'sedan' }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 }, + { _id: 'some-other-id', + _source: { _kuzzle_info: [Object], category: 'limousine' }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 } ], + total: 2 } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/mUpdate/snippets/m-update.test.yml b/doc/src/controllers/document/mUpdate/snippets/m-update.test.yml new file mode 100644 index 000000000..58ade7ff0 --- /dev/null +++ b/doc/src/controllers/document/mUpdate/snippets/m-update.test.yml @@ -0,0 +1,14 @@ +name: document#mUpdate +description: Update documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/replace/index.md b/doc/src/controllers/document/replace/index.md new file mode 100644 index 000000000..2dc508387 --- /dev/null +++ b/doc/src/controllers/document/replace/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: replace +description: Replace a document +--- + +# replace + +Replaces the content of an existing document. + +
+ +```javascript +replace(index, collection, id, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | ------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `document` |
object
| New content of the document to update | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the the document update result. + +| Name | Type | Description | +| --------- | ----------------- | ------------------------------------------------------ | +| \_id |
string
| ID of the newly created document | +| \_version |
number
| Version of the document in the persistent data storage | +| \_source |
object
| The updated document | + +## Usage + +<<< ./snippets/replace.js diff --git a/doc/src/controllers/document/replace/snippets/replace.js b/doc/src/controllers/document/replace/snippets/replace.js new file mode 100644 index 000000000..be26e5ed2 --- /dev/null +++ b/doc/src/controllers/document/replace/snippets/replace.js @@ -0,0 +1,36 @@ +const doc = { color: 'yellow' }; + +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc, 'some-id'); + + const response = await kuzzle.document.replace( + 'nyc-open-data', + 'yellow-taxi', + 'some-id', + { capacity: 4, category: 'sedan' } + ); + + console.log(response); + /* + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + _source: + { capacity: 4, + category: 'sedan', + _kuzzle_info: + { author: '-1', + createdAt: 1538654776456, + updatedAt: 1538654776456, + updater: '-1', + active: true, + deletedAt: null } } } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/replace/snippets/replace.test.yml b/doc/src/controllers/document/replace/snippets/replace.test.yml new file mode 100644 index 000000000..2159e6a89 --- /dev/null +++ b/doc/src/controllers/document/replace/snippets/replace.test.yml @@ -0,0 +1,13 @@ +name: document#replace +description: Replace a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/search/index.md b/doc/src/controllers/document/search/index.md new file mode 100644 index 000000000..ed851c5da --- /dev/null +++ b/doc/src/controllers/document/search/index.md @@ -0,0 +1,61 @@ +--- +code: true +type: page +title: search +description: Search for documents +--- + +# search + +Searches documents. + +There is a limit to how many documents can be returned by a single search query. +That limit is by default set at 10000 documents, and you can't get over it even with the from and size pagination options. + +
+

+ When processing a large number of documents (i.e. more than 1000), it is advised to paginate the results using SearchResult.next rather than increasing the size parameter. +

+
+ +
+ +```javascript +search(index, collection, [query], [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `query` |
object
| Search query | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `from` |
number

(`0`) | Offset of the first document to fetch | +| `size` |
number

(`10`) | Maximum number of documents to retrieve per page | +| `scroll` |
string

(`""`) | When set, gets a forward-only cursor having its ttl set to the given value (ie `30s`; cf [elasticsearch time limits](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#time-units)) | + +## Body properties + +### Optional: + +- `query`: the search query itself, using the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax. +- `aggregations`: control how the search results should be [aggregated](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations.html) +- `sort`: contains a list of fields, used to [sort search results](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-sort.html), in order of importance. + +An empty body matches all documents in the queried collection. + +## Resolves + +Resolves to a [SearchResult](/sdk/js/6/search-result) object. + +## Usage + +<<< ./snippets/search.js diff --git a/doc/src/controllers/document/search/snippets/search.js b/doc/src/controllers/document/search/snippets/search.js new file mode 100644 index 000000000..97d037cd2 --- /dev/null +++ b/doc/src/controllers/document/search/snippets/search.js @@ -0,0 +1,61 @@ +const suv = { category: 'suv' }; +const limousine = { category: 'limousine' }; + +try { + const requests = []; + + for (let i = 0; i < 5; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); + } + for (let i = 0; i < 10; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', limousine)); + } + await Promise.all(requests); + + await kuzzle.index.refresh('nyc-open-data'); + + const results = await kuzzle.document.search( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + category: 'suv' + } + } + } + ); + + console.log(results); + /* + { + "aggregations": undefined, + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "AWgi6A1POQUM6ucJ3q06", + "_score": 0.046520017, + "_source": { + "category": "suv", + "_kuzzle_info": { + "author": "-1", + "createdAt": 1546773859655, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + ... + ] + }, + "total": 5, + "fetched": 5, + "scroll_id": undefined + */ + console.log(`Successfully retrieved ${results.total} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/search/snippets/search.test.yml b/doc/src/controllers/document/search/snippets/search.test.yml new file mode 100644 index 000000000..be1107e88 --- /dev/null +++ b/doc/src/controllers/document/search/snippets/search.test.yml @@ -0,0 +1,13 @@ +name: document#search +description: Search for documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully retrieved 5 documents +sdk: js +version: 6 diff --git a/doc/src/controllers/document/update/index.md b/doc/src/controllers/document/update/index.md new file mode 100644 index 000000000..c92edebac --- /dev/null +++ b/doc/src/controllers/document/update/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: update +description: Update a document +--- + +# update + +Updates a document content. + +Conflicts may occur if the same document gets updated multiple times within a short timespan, in a database cluster. +You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error. + +
+ +```javascript +update(index, collection, id, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | ----------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `document` |
object
| Partial content of the document to update | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ----------------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | +| `retryOnConflict` |
int

(`0`) | The number of times the database layer should retry in case of version conflict | + +## Resolves + +Resolves to an object containing the the document update result. + +## Usage + +<<< ./snippets/update.js diff --git a/doc/src/controllers/document/update/snippets/update.js b/doc/src/controllers/document/update/snippets/update.js new file mode 100644 index 000000000..76d587a5f --- /dev/null +++ b/doc/src/controllers/document/update/snippets/update.js @@ -0,0 +1,27 @@ +try { + await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + { capacity: 4 }, + 'some-id' + ); + + const response = await kuzzle.document.update( + 'nyc-open-data', + 'yellow-taxi', + 'some-id', + { category: 'suv' } + ); + + console.log(response); + /* + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 } } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/document/update/snippets/update.test.yml b/doc/src/controllers/document/update/snippets/update.test.yml new file mode 100644 index 000000000..de65fb652 --- /dev/null +++ b/doc/src/controllers/document/update/snippets/update.test.yml @@ -0,0 +1,14 @@ +name: document#update +description: Update a document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: "result: 'updated'" + +sdk: js +version: 6 diff --git a/doc/src/controllers/document/validate/index.md b/doc/src/controllers/document/validate/index.md new file mode 100644 index 000000000..89002971f --- /dev/null +++ b/doc/src/controllers/document/validate/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: validate +description: Validate a document +--- + +# validate + +Validates data against existing validation rules. + +Note that if no validation specifications are set for the ``/``, the document will always be valid. + +This request does **not** store or publish the document. + +
+ +```javascript +validate(index, collection, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | -------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `document` |
object
| Document to validate | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a boolean value set to true if the document is valid and false otherwise. + +## Usage + +<<< ./snippets/validate.js diff --git a/doc/src/controllers/document/validate/snippets/validate.js b/doc/src/controllers/document/validate/snippets/validate.js new file mode 100644 index 000000000..b2073205c --- /dev/null +++ b/doc/src/controllers/document/validate/snippets/validate.js @@ -0,0 +1,13 @@ +try { + const valid = await kuzzle.document.validate( + 'nyc-open-data', + 'yellow-taxi', + { capacity: 4 } + ); + + if (valid) { + console.log('Success'); + } +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/document/validate/snippets/validate.test.yml b/doc/src/controllers/document/validate/snippets/validate.test.yml new file mode 100644 index 000000000..7de251334 --- /dev/null +++ b/doc/src/controllers/document/validate/snippets/validate.test.yml @@ -0,0 +1,14 @@ +name: document#validate +description: Validate a document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/index.md b/doc/src/controllers/index.md new file mode 100644 index 000000000..35788d401 --- /dev/null +++ b/doc/src/controllers/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 300 +title: Controllers +description: Javascript SDK v6.x controllers +--- diff --git a/doc/src/controllers/index/create/index.md b/doc/src/controllers/index/create/index.md new file mode 100644 index 000000000..9f5ceee55 --- /dev/null +++ b/doc/src/controllers/index/create/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: create +description: Creates an index +--- + +# create + +Creates a new data index. + +
+ +```javascript +create(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an `object` containing the index creation status + +| Name | Type | Description | +| --------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------- | +| `acknowledged` |
boolean
| Indicates whether the index was successfully created in the Elastic cluster | +| `shards_acknowledged` |
boolean
| Indicates whether the requisite number of shard copies were started for each shard in the index before timing out | + +## Usage + +<<< ./snippets/create.js diff --git a/doc/src/controllers/index/create/snippets/create.js b/doc/src/controllers/index/create/snippets/create.js new file mode 100644 index 000000000..e1ce98080 --- /dev/null +++ b/doc/src/controllers/index/create/snippets/create.js @@ -0,0 +1,12 @@ +try { + const response = await kuzzle.index.create('nyc-open-data'); + console.log(response); + /* + { acknowledged: true, + shards_acknowledged: true } + */ + + console.log('Index created'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/create/snippets/create.test.yml b/doc/src/controllers/index/create/snippets/create.test.yml new file mode 100644 index 000000000..9437cac16 --- /dev/null +++ b/doc/src/controllers/index/create/snippets/create.test.yml @@ -0,0 +1,12 @@ +--- +name: index#create +description: Creates a new index +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: default +expected: + - "acknowledged: true" + - "Index created" +sdk: js +version: 6 diff --git a/doc/src/controllers/index/delete/index.md b/doc/src/controllers/index/delete/index.md new file mode 100644 index 000000000..86dd310b8 --- /dev/null +++ b/doc/src/controllers/index/delete/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: delete +description: Deletes an index +--- + +# delete + +Deletes a data index. + +
+ +```javascript +delete (index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves if the index was successfully deleted in the Elasticsearch cluster. + +## Usage + +<<< ./snippets/delete.js diff --git a/doc/src/controllers/index/delete/snippets/delete.js b/doc/src/controllers/index/delete/snippets/delete.js new file mode 100644 index 000000000..ee0771bf9 --- /dev/null +++ b/doc/src/controllers/index/delete/snippets/delete.js @@ -0,0 +1,7 @@ +try { + kuzzle.index.delete('nyc-open-data'); + + console.log('Index deleted'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/delete/snippets/delete.test.yml b/doc/src/controllers/index/delete/snippets/delete.test.yml new file mode 100644 index 000000000..75385676a --- /dev/null +++ b/doc/src/controllers/index/delete/snippets/delete.test.yml @@ -0,0 +1,11 @@ +--- +name: index#delete +description: Deletes an index +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Index deleted + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/exists/index.md b/doc/src/controllers/index/exists/index.md new file mode 100644 index 000000000..177abd303 --- /dev/null +++ b/doc/src/controllers/index/exists/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: exists +description: Check for index existence +--- + +# exists + +Checks if the given data index exists. + +
+ +```javascript +exists(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` that indicate whether the index exists or not. + +## Usage + +<<< ./snippets/exists.js diff --git a/doc/src/controllers/index/exists/snippets/exists.js b/doc/src/controllers/index/exists/snippets/exists.js new file mode 100644 index 000000000..5fdc1199d --- /dev/null +++ b/doc/src/controllers/index/exists/snippets/exists.js @@ -0,0 +1,11 @@ +try { + const exists = await kuzzle.index.exists('nyc-open-data'); + + if (exists === true) { + console.log('Index exists'); + } else { + console.log('Index does not exists'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/exists/snippets/exists.test.yml b/doc/src/controllers/index/exists/snippets/exists.test.yml new file mode 100644 index 000000000..55257010d --- /dev/null +++ b/doc/src/controllers/index/exists/snippets/exists.test.yml @@ -0,0 +1,11 @@ +--- +name: index#exists +description: Tests if an index exists +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Index exists + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/get-auto-refresh/index.md b/doc/src/controllers/index/get-auto-refresh/index.md new file mode 100644 index 000000000..8c55abebd --- /dev/null +++ b/doc/src/controllers/index/get-auto-refresh/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: getAutoRefresh +description: Returns the status of autorefresh flag +--- + +# getAutoRefresh + +This action returns the current autorefresh status of a data index. + +Each index has an autorefresh flag. +When set to true, each write request triggers a [refresh](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html) action in Elasticsearch. +Without a refresh after a write request, the documents may not be immediately visible in search. + +
+ A refresh operation comes with some performance costs. + While forcing the autoRefresh can be convenient on a development or test environment, + we recommend that you avoid using it in production or at least carefully monitor its implications before using it. +
+ +
+ +```javascript +getAutoRefresh(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` that indicate the status of the **autoRefresh** flag. + +## Usage + +<<< ./snippets/getAutoRefresh.js diff --git a/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js b/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js new file mode 100644 index 000000000..0197ea180 --- /dev/null +++ b/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js @@ -0,0 +1,7 @@ +try { + const status = await kuzzle.index.getAutoRefresh('nyc-open-data'); + + console.log(`autorefresh is ${status}`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml b/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml new file mode 100644 index 000000000..e8117816b --- /dev/null +++ b/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml @@ -0,0 +1,11 @@ +--- +name: index#getAutoRefresh +description: Return autorefresh status for index +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data && curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: autorefresh is false + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/index.md b/doc/src/controllers/index/index.md new file mode 100644 index 000000000..a9e958562 --- /dev/null +++ b/doc/src/controllers/index/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: index +description: index controller documentation +--- diff --git a/doc/src/controllers/index/list/index.md b/doc/src/controllers/index/list/index.md new file mode 100644 index 000000000..a626d87c0 --- /dev/null +++ b/doc/src/controllers/index/list/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: list +description: Lists the indexes +--- + +# list + +Returns the complete list of data indexes. + +
+ +```javascript +list([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an array of index names. + +## Usage + +<<< ./snippets/list.js diff --git a/doc/src/controllers/index/list/snippets/list.js b/doc/src/controllers/index/list/snippets/list.js new file mode 100644 index 000000000..3a05ff38e --- /dev/null +++ b/doc/src/controllers/index/list/snippets/list.js @@ -0,0 +1,11 @@ +try { + const indexes = await kuzzle.index.list(); + console.log(indexes); + /* + [ 'nyc-open-data', 'mtp-open-data' ] + */ + + console.log(`Kuzzle contains ${indexes.length} indexes`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/list/snippets/list.test.yml b/doc/src/controllers/index/list/snippets/list.test.yml new file mode 100644 index 000000000..6981feadf --- /dev/null +++ b/doc/src/controllers/index/list/snippets/list.test.yml @@ -0,0 +1,14 @@ +--- +name: index#list +description: Lists indexes handled by kuzzle +hooks: + before: | + curl -X POST kuzzle:7512/admin/_resetDatabase + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X POST kuzzle:7512/mtp-open-data/_create + after: +template: default +expected: Kuzzle contains 2 indexes + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/m-delete/index.md b/doc/src/controllers/index/m-delete/index.md new file mode 100644 index 000000000..473c7c1eb --- /dev/null +++ b/doc/src/controllers/index/m-delete/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: mDelete +description: Deletes multiple indexes +--- + +# mDelete + +Deletes multiple data indexes. + +
+ +```javascript +mDelete(indexes, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ----------------------------- | +| `indexes` |
string[]
| List of index names to delete | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an array of Successfully deleted indexes. + +## Usage + +<<< ./snippets/mDelete.js diff --git a/doc/src/controllers/index/m-delete/snippets/mDelete.js b/doc/src/controllers/index/m-delete/snippets/mDelete.js new file mode 100644 index 000000000..be18a7a57 --- /dev/null +++ b/doc/src/controllers/index/m-delete/snippets/mDelete.js @@ -0,0 +1,11 @@ +try { + const indexes = await kuzzle.index.mDelete(['nyc-open-data', 'mtp-open-data']); + console.log(indexes); + /* + [ 'nyc-open-data', 'mtp-open-data' ] + */ + + console.log(`Successfully deleted ${indexes.length} indexes`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/m-delete/snippets/mDelete.test.yml b/doc/src/controllers/index/m-delete/snippets/mDelete.test.yml new file mode 100644 index 000000000..8f9334ad1 --- /dev/null +++ b/doc/src/controllers/index/m-delete/snippets/mDelete.test.yml @@ -0,0 +1,13 @@ +--- +name: index#mDelete +description: Delete multiple indexes +hooks: + before: | + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X POST kuzzle:7512/mtp-open-data/_create + after: +template: default +expected: Successfully deleted 2 indexes + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/refresh-internal/index.md b/doc/src/controllers/index/refresh-internal/index.md new file mode 100644 index 000000000..f8ec74000 --- /dev/null +++ b/doc/src/controllers/index/refresh-internal/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: refreshInternal +description: Forces an immediate reindexation of Kuzzle internal storage. +--- + +# refreshInternal + +When writing or deleting security and internal documents (users, roles, profiles, configuration, etc.) in Kuzzle, the update needs to be indexed before being reflected in the search index. + +The `refreshInternal` action forces a [refresh](//sdk/js/6/controllers/index/refresh), on the internal index, making the documents available to search immediately. + +
+ A refresh operation comes with some performance costs. + +From [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html): +"While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." + +
+ +
+ +```javascript +refreshInternal(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` containing the refresh status. + +## Usage + +<<< ./snippets/refreshInternal.js diff --git a/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.js b/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.js new file mode 100644 index 000000000..4febc0507 --- /dev/null +++ b/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.js @@ -0,0 +1,9 @@ +try { + const success = await kuzzle.index.refreshInternal(); + + if (success) { + console.log('Internal index successfully refreshed'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.test.yml b/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.test.yml new file mode 100644 index 000000000..372fe4208 --- /dev/null +++ b/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.test.yml @@ -0,0 +1,11 @@ +--- +name: index#refreshInternal +description: Forces an immediate reindexation of Kuzzle internal storage. +hooks: + before: + after: +template: default +expected: Internal index successfully refreshed + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/refresh/index.md b/doc/src/controllers/index/refresh/index.md new file mode 100644 index 000000000..77d6eac98 --- /dev/null +++ b/doc/src/controllers/index/refresh/index.md @@ -0,0 +1,52 @@ +--- +code: true +type: page +title: refresh +description: Forces an Elasticsearch search index update +--- + +# refresh + +When writing or deleting documents in Kuzzle, the update needs to be indexed before being available in search results. + +
+ A refresh operation comes with some performance costs. + +From [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html): +"While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." + +
+ +
+ +```javascript +refresh(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an `object` containing the refresh status on shards. + +| Name | Type | Description | +| ------------ | ----------------- | ----------------------------- | +| `total` |
number
| Total number of shards | +| `successful` |
number
| Successfully refreshed shards | +| `failed` |
number
| Shards that failed to refresh | + +## Usage + +<<< ./snippets/refresh.js diff --git a/doc/src/controllers/index/refresh/snippets/refresh.js b/doc/src/controllers/index/refresh/snippets/refresh.js new file mode 100644 index 000000000..97190974a --- /dev/null +++ b/doc/src/controllers/index/refresh/snippets/refresh.js @@ -0,0 +1,11 @@ +try { + const status = await kuzzle.index.refresh('nyc-open-data'); + console.log(status); + /* + { total: 5, successful: 5, failed: 0 } + */ + + console.log(`${status.failed} shards fail to refresh`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/refresh/snippets/refresh.test.yml b/doc/src/controllers/index/refresh/snippets/refresh.test.yml new file mode 100644 index 000000000..2121be65c --- /dev/null +++ b/doc/src/controllers/index/refresh/snippets/refresh.test.yml @@ -0,0 +1,11 @@ +--- +name: index#refresh +description: Forces an Elasticsearch search index update +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: 0 shards fail to refresh + +sdk: js +version: 6 diff --git a/doc/src/controllers/index/set-auto-refresh/index.md b/doc/src/controllers/index/set-auto-refresh/index.md new file mode 100644 index 000000000..4cbd1dc80 --- /dev/null +++ b/doc/src/controllers/index/set-auto-refresh/index.md @@ -0,0 +1,50 @@ +--- +code: true +type: page +title: setAutoRefresh +description: Set the autorefresh flag +--- + +# setAutoRefresh + +The setAutoRefresh action allows to set the autorefresh flag for a data index. + +Each index has an autorefresh flag. +When set to true, each write request trigger a [refresh](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html) action on Elasticsearch. +Without a refresh after a write request, the documents may not be immediately visible in search. + +
+A refresh operation comes with performance costs. +While forcing the autoRefresh can be convenient on a development or test environment, +we recommend that you avoid using it in production or at least carefully monitor its implications before using it. +
+ +
+ +```javascript +setAutoRefresh(index, autoRefresh, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ------------------ | ----------------- | +| `index` |
string
| Index name | +| `autoRefresh` |
boolean
| AutoRefresh value | +| `options` |
number
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` representing the new value of the autorefresh flag. + +## Usage + +<<< ./snippets/setAutoRefresh.js diff --git a/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js b/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js new file mode 100644 index 000000000..75d8736de --- /dev/null +++ b/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js @@ -0,0 +1,9 @@ +try { + const autoRefresh = await kuzzle.index.setAutoRefresh('nyc-open-data', true); + + if (autoRefresh === true) { + console.log(`Autorefresh flag is set to true`); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml b/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml new file mode 100644 index 000000000..3a89cb389 --- /dev/null +++ b/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml @@ -0,0 +1,13 @@ +--- +name: index#setAutoRefresh +description: Set the autorefresh flag for the index +hooks: + before: | + curl -X DELETE kuzzle:7512/nyc-open-data + curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Autorefresh flag is set to true + +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/append/index.md b/doc/src/controllers/ms/append/index.md new file mode 100644 index 000000000..bf8994f93 --- /dev/null +++ b/doc/src/controllers/ms/append/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: append +--- + +# append + +Appends a value to a key. If the key does not exist, it is created. + +[[_Redis documentation_]](https://redis.io/commands/append) + +## Arguments + +```js +append(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
string
| Value to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Returns the updated value length. + +## Usage + +<<< ./snippets/append.js diff --git a/doc/src/controllers/ms/append/snippets/append.js b/doc/src/controllers/ms/append/snippets/append.js new file mode 100644 index 000000000..01c747745 --- /dev/null +++ b/doc/src/controllers/ms/append/snippets/append.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('hw', 'Hello'); + + await kuzzle.ms.append('hw', ' World'); + + // Prints: Hello World + console.log(await kuzzle.ms.get('hw')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/append/snippets/append.test.yml b/doc/src/controllers/ms/append/snippets/append.test.yml new file mode 100644 index 000000000..1b778932d --- /dev/null +++ b/doc/src/controllers/ms/append/snippets/append.test.yml @@ -0,0 +1,9 @@ +name: ms#append +description: Appends a value to a key. If the key does not exist, it is created +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: Hello World +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/bitcount/index.md b/doc/src/controllers/ms/bitcount/index.md new file mode 100644 index 000000000..db719f134 --- /dev/null +++ b/doc/src/controllers/ms/bitcount/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: bitcount +--- + +# bitcount + +Counts the number of set bits (population counting) in a string. + +[[_Redis documentation_]](https://redis.io/commands/bitcount) + +## Arguments + +```js +bitcount(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `end` |
integer
| Count ends at the provided offset | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `start` |
integer
| Count starts at the provided offset | + +## Resolve + +Resolves to the number of set bits. + +## Usage + +<<< ./snippets/bitcount.js diff --git a/doc/src/controllers/ms/bitcount/snippets/bitcount.js b/doc/src/controllers/ms/bitcount/snippets/bitcount.js new file mode 100644 index 000000000..0d598a8df --- /dev/null +++ b/doc/src/controllers/ms/bitcount/snippets/bitcount.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('key', 'foobar'); + + // Prints: 26 + console.log(await kuzzle.ms.bitcount('key')); + + // Prints: 4 + console.log(await kuzzle.ms.bitcount('key', {start: 0, end: 0})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/bitcount/snippets/bitcount.test.yml b/doc/src/controllers/ms/bitcount/snippets/bitcount.test.yml new file mode 100644 index 000000000..887b5762e --- /dev/null +++ b/doc/src/controllers/ms/bitcount/snippets/bitcount.test.yml @@ -0,0 +1,11 @@ +name: ms#bitcount +description: Counts the number of set bits (population counting) in a string +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - 26 + - 4 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/bitop/index.md b/doc/src/controllers/ms/bitop/index.md new file mode 100644 index 000000000..60a5eb03f --- /dev/null +++ b/doc/src/controllers/ms/bitop/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: bitop +--- + +# bitop + +Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key. + +[[_Redis documentation_]](https://redis.io/commands/bitop) + +## Arguments + +```js +bitop(key, operation, keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | ----------------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `operation` |
string
| The bitwise operand to use to combine keys.
Allowed values: `AND`, `NOT`, `OR`, `XOR` | +| `keys` |
string[]
| The list of keys to combine | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the new destination key length. + +## Usage + +<<< ./snippets/bitop.js diff --git a/doc/src/controllers/ms/bitop/snippets/bitop.js b/doc/src/controllers/ms/bitop/snippets/bitop.js new file mode 100644 index 000000000..47bb01c41 --- /dev/null +++ b/doc/src/controllers/ms/bitop/snippets/bitop.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('key1', 'foobar'); + await kuzzle.ms.set('key2', 'abcdef'); + + await kuzzle.ms.bitop('dest', 'AND', ['key1', 'key2']); + + // Prints: `bc`ab + console.log(await kuzzle.ms.get('dest')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/bitop/snippets/bitop.test.yml b/doc/src/controllers/ms/bitop/snippets/bitop.test.yml new file mode 100644 index 000000000..34f2b6513 --- /dev/null +++ b/doc/src/controllers/ms/bitop/snippets/bitop.test.yml @@ -0,0 +1,9 @@ +name: ms#bitop +description: Performs a bitwise operation between multiple keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "`bc`ab" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/bitpos/index.md b/doc/src/controllers/ms/bitpos/index.md new file mode 100644 index 000000000..1c3ba80db --- /dev/null +++ b/doc/src/controllers/ms/bitpos/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: bitpos +--- + +# bitpos + +Returns the position of the first bit set to 1 or 0 in a string, or in a substring. + +[[_Redis documentation_]](https://redis.io/commands/bitpos) + +## Arguments + +```js +bitpos(key, bit, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ---------------------------------------------- | +| `key` |
string
| Key | +| `bit` |
integer
| Bit to look for.
Accepted values: `0`, `1` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `end` |
integer
| Search ends at the provided offset | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `start` |
integer
| Search starts at the provided offset | + +## Resolve + +Resolves to the position of the first bit found matching the searched value. + +## Usage + +<<< ./snippets/bitpos.js diff --git a/doc/src/controllers/ms/bitpos/snippets/bitpos.js b/doc/src/controllers/ms/bitpos/snippets/bitpos.js new file mode 100644 index 000000000..a5250bbbe --- /dev/null +++ b/doc/src/controllers/ms/bitpos/snippets/bitpos.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('key', '\x00\x00\x01'); + + // Prints: 23 + console.log(await kuzzle.ms.bitpos('key', 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/bitpos/snippets/bitpos.test.yml b/doc/src/controllers/ms/bitpos/snippets/bitpos.test.yml new file mode 100644 index 000000000..42aa3d157 --- /dev/null +++ b/doc/src/controllers/ms/bitpos/snippets/bitpos.test.yml @@ -0,0 +1,9 @@ +name: ms#bitpos +description: Returns the position of the first bit set to 1 or 0 in a string, or in a substring +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 23 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/dbsize/index.md b/doc/src/controllers/ms/dbsize/index.md new file mode 100644 index 000000000..24d1c804d --- /dev/null +++ b/doc/src/controllers/ms/dbsize/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: dbsize +--- + +# dbsize + +Returns the number of keys in the application database. + +[[_Redis documentation_]](https://redis.io/commands/dbsize) + +## Arguments + +```js +dbsize([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of found keys. + +## Usage + +<<< ./snippets/dbsize.js diff --git a/doc/src/controllers/ms/dbsize/snippets/dbsize.js b/doc/src/controllers/ms/dbsize/snippets/dbsize.js new file mode 100644 index 000000000..25df85e10 --- /dev/null +++ b/doc/src/controllers/ms/dbsize/snippets/dbsize.js @@ -0,0 +1,6 @@ +try { + const size = await kuzzle.ms.dbsize(); + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/dbsize/snippets/dbsize.test.yml b/doc/src/controllers/ms/dbsize/snippets/dbsize.test.yml new file mode 100644 index 000000000..21811fa67 --- /dev/null +++ b/doc/src/controllers/ms/dbsize/snippets/dbsize.test.yml @@ -0,0 +1,9 @@ +name: ms#dbsize +description: Returns the number of keys in the application database +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: Success +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/decr/index.md b/doc/src/controllers/ms/decr/index.md new file mode 100644 index 000000000..9492718e1 --- /dev/null +++ b/doc/src/controllers/ms/decr/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: decr +--- + +# decr + +Decrements the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/decr) + +## Arguments + +```js +decr(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated key value. + +## Usage + +<<< ./snippets/decr.js diff --git a/doc/src/controllers/ms/decr/snippets/decr.js b/doc/src/controllers/ms/decr/snippets/decr.js new file mode 100644 index 000000000..681cb503a --- /dev/null +++ b/doc/src/controllers/ms/decr/snippets/decr.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('val', 43); + + // Prints: 42 + console.log(await kuzzle.ms.decr('val')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/decr/snippets/decr.test.yml b/doc/src/controllers/ms/decr/snippets/decr.test.yml new file mode 100644 index 000000000..f515ac10c --- /dev/null +++ b/doc/src/controllers/ms/decr/snippets/decr.test.yml @@ -0,0 +1,9 @@ +name: ms#decr +description: Decrements the number stored at `key` by 1 +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 42 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/decrby/index.md b/doc/src/controllers/ms/decrby/index.md new file mode 100644 index 000000000..1a5301d88 --- /dev/null +++ b/doc/src/controllers/ms/decrby/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: decrby +--- + +# decrby + +Decrements the number stored at `key` by a provided integer value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/decrby) + +## Arguments + +```js +decrby(key, decrement, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `decrement` |
integer
| Decrement value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated key value. + +## Usage + +<<< ./snippets/decrby.js diff --git a/doc/src/controllers/ms/decrby/snippets/decrby.js b/doc/src/controllers/ms/decrby/snippets/decrby.js new file mode 100644 index 000000000..49bb332b1 --- /dev/null +++ b/doc/src/controllers/ms/decrby/snippets/decrby.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('val', 12); + + // Prints: 42 + console.log(await kuzzle.ms.decrby('val', -30)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/decrby/snippets/decrby.test.yml b/doc/src/controllers/ms/decrby/snippets/decrby.test.yml new file mode 100644 index 000000000..63ce294a4 --- /dev/null +++ b/doc/src/controllers/ms/decrby/snippets/decrby.test.yml @@ -0,0 +1,9 @@ +name: ms#decrby +description: Decrements the number stored at key by a provided integer value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 42 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/del/index.md b/doc/src/controllers/ms/del/index.md new file mode 100644 index 000000000..ce4ad6873 --- /dev/null +++ b/doc/src/controllers/ms/del/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: del +--- + +# del + +Deletes a list of keys. + +[[_Redis documentation_]](https://redis.io/commands/del) + +## Arguments + +```js +del(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| Keys to delete | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of deleted keys. + +## Usage + +<<< ./snippets/del.js diff --git a/doc/src/controllers/ms/del/snippets/del.js b/doc/src/controllers/ms/del/snippets/del.js new file mode 100644 index 000000000..e6b0ea88e --- /dev/null +++ b/doc/src/controllers/ms/del/snippets/del.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + await kuzzle.ms.del(['foo']); + + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/del/snippets/del.test.yml b/doc/src/controllers/ms/del/snippets/del.test.yml new file mode 100644 index 000000000..fc4ff56b2 --- /dev/null +++ b/doc/src/controllers/ms/del/snippets/del.test.yml @@ -0,0 +1,9 @@ +name: ms#del +description: Deletes a list of keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 0 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/exists/index.md b/doc/src/controllers/ms/exists/index.md new file mode 100644 index 000000000..ce8355dc8 --- /dev/null +++ b/doc/src/controllers/ms/exists/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: exists +--- + +# exists + +Checks if the specified keys exist in the database. + +[[_Redis documentation_]](https://redis.io/commands/exists) + +## Arguments + +```js +exists(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | --------------------------- | +| `keys` |
string[]
| Keys to check for existence | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of existing keys. + +## Usage + +<<< ./snippets/exists.js diff --git a/doc/src/controllers/ms/exists/snippets/exists.js b/doc/src/controllers/ms/exists/snippets/exists.js new file mode 100644 index 000000000..3266a19bb --- /dev/null +++ b/doc/src/controllers/ms/exists/snippets/exists.js @@ -0,0 +1,13 @@ +try { + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); + + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/exists/snippets/exists.test.yml b/doc/src/controllers/ms/exists/snippets/exists.test.yml new file mode 100644 index 000000000..8c0752b08 --- /dev/null +++ b/doc/src/controllers/ms/exists/snippets/exists.test.yml @@ -0,0 +1,11 @@ +name: ms#exists +description: Checks if the specified keys exist in the database +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^1$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/expire/index.md b/doc/src/controllers/ms/expire/index.md new file mode 100644 index 000000000..0c34e8d80 --- /dev/null +++ b/doc/src/controllers/ms/expire/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: expire +--- + +# expire + +Sets a timeout (in seconds) on a key. After the timeout has expired, the key is automatically deleted. + +[[_Redis documentation_]](https://redis.io/commands/expire) + +## Arguments + +```js +expire(key, seconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ---------------------------------------- | +| `key` |
string
| Key | +| `seconds` |
integer
| Number of seconds before the key expires | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation was successful or not. + +## Usage + +<<< ./snippets/expire.js diff --git a/doc/src/controllers/ms/expire/snippets/expire.js b/doc/src/controllers/ms/expire/snippets/expire.js new file mode 100644 index 000000000..ff0720951 --- /dev/null +++ b/doc/src/controllers/ms/expire/snippets/expire.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: -1 + console.log(await kuzzle.ms.ttl('foo')); + + await kuzzle.ms.expire('foo', 10); + + // Prints: 10 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/expire/snippets/expire.test.yml b/doc/src/controllers/ms/expire/snippets/expire.test.yml new file mode 100644 index 000000000..fac040455 --- /dev/null +++ b/doc/src/controllers/ms/expire/snippets/expire.test.yml @@ -0,0 +1,11 @@ +name: ms#expire +description: Sets a timeout (in seconds) on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - -1 + - ^[1-9]+ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/expireat/index.md b/doc/src/controllers/ms/expireat/index.md new file mode 100644 index 000000000..0995e3b00 --- /dev/null +++ b/doc/src/controllers/ms/expireat/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: expireat +--- + +# expireat + +Sets an expiration timestamp on a key. After the timestamp has been reached, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/expireat) + +## Arguments + +```js +expireat(key, timestamp, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------------------------------------------------------------ | +| `key` |
string
| Key | +| `timestamp` |
integer
| Expiration timestamp ([Epoch](https://en.wikipedia.org/wiki/Unix_time) format) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation was successful or not. + +## Usage + +<<< ./snippets/expireat.js diff --git a/doc/src/controllers/ms/expireat/snippets/expireat.js b/doc/src/controllers/ms/expireat/snippets/expireat.js new file mode 100644 index 000000000..c40f69d65 --- /dev/null +++ b/doc/src/controllers/ms/expireat/snippets/expireat.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + // Oct. 12, 2011 + await kuzzle.ms.expireat('foo', 1318425955); + + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/expireat/snippets/expireat.test.yml b/doc/src/controllers/ms/expireat/snippets/expireat.test.yml new file mode 100644 index 000000000..735ea84da --- /dev/null +++ b/doc/src/controllers/ms/expireat/snippets/expireat.test.yml @@ -0,0 +1,11 @@ +name: ms#expireat +description: Sets an expiration timestamp on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^1$ + - ^0$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/flushdb/index.md b/doc/src/controllers/ms/flushdb/index.md new file mode 100644 index 000000000..f0c7cd774 --- /dev/null +++ b/doc/src/controllers/ms/flushdb/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: flushdb +--- + +# flushdb + +Empties the database dedicated to client applications (the reserved space for Kuzzle is unaffected). + +[[_Redis documentation_]](https://redis.io/commands/flushdb) + +## Arguments + +```js +flushdb([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to `undefined` once the operation completes. + +## Usage + +<<< ./snippets/flushdb.js diff --git a/doc/src/controllers/ms/flushdb/snippets/flushdb.js b/doc/src/controllers/ms/flushdb/snippets/flushdb.js new file mode 100644 index 000000000..ceb31b43a --- /dev/null +++ b/doc/src/controllers/ms/flushdb/snippets/flushdb.js @@ -0,0 +1,6 @@ +try { + await kuzzle.ms.flushdb(); + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/flushdb/snippets/flushdb.test.yml b/doc/src/controllers/ms/flushdb/snippets/flushdb.test.yml new file mode 100644 index 000000000..ae2331836 --- /dev/null +++ b/doc/src/controllers/ms/flushdb/snippets/flushdb.test.yml @@ -0,0 +1,9 @@ +name: ms#flushdb +description: Empties the database dedicated to client applications +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: Success +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/geoadd/index.md b/doc/src/controllers/ms/geoadd/index.md new file mode 100644 index 000000000..85899b4f0 --- /dev/null +++ b/doc/src/controllers/ms/geoadd/index.md @@ -0,0 +1,51 @@ +--- +code: true +type: page +title: geoadd +--- + +# geoadd + +Adds geospatial points to the specified key. + +[[_Redis documentation_]](https://redis.io/commands/geoadd) + +## Arguments + +```js +geoadd(key, geopoints, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | ------------------------ | +| `key` |
string
| Key | +| `geopoints` |
object[]
| List of geopoints to add | +| `options` |
object
| Optional query arguments | + +### geopoints + +List of objects, each one of those being a geopoint to be added, with the following properties: + +| Properties | Type | Description | +| ---------- | ----------------- | ----------------------------------------- | +| `lat` |
number
| Latitude | +| `lon` |
number
| Longitude | +| `name` |
string
| Unique point name (used as an identifier) | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of points added. + +## Usage + +<<< ./snippets/geoadd.js diff --git a/doc/src/controllers/ms/geoadd/snippets/geoadd.js b/doc/src/controllers/ms/geoadd/snippets/geoadd.js new file mode 100644 index 000000000..7bd4badde --- /dev/null +++ b/doc/src/controllers/ms/geoadd/snippets/geoadd.js @@ -0,0 +1,19 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + const result = await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: 2 + console.log(result); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/geoadd/snippets/geoadd.test.yml b/doc/src/controllers/ms/geoadd/snippets/geoadd.test.yml new file mode 100644 index 000000000..ab30f799c --- /dev/null +++ b/doc/src/controllers/ms/geoadd/snippets/geoadd.test.yml @@ -0,0 +1,9 @@ +name: ms#geoadd +description: Adds geospatial points to the specified key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 2 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/geodist/index.md b/doc/src/controllers/ms/geodist/index.md new file mode 100644 index 000000000..2e07b878f --- /dev/null +++ b/doc/src/controllers/ms/geodist/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: geodist +--- + +# geodist + +Returns the distance between two geospatial members of a key (see [geoadd](/sdk/js/6/controllers/ms/geoadd)). + +The returned distance is expressed in meters by default. + +[[_Redis documentation_]](https://redis.io/commands/geodist) + +## Arguments + +```js +geodist(key, geopoint1, geopoint2, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ----------------- | -------------------------- | +| `key` |
string
| Key | +| `geopoint1` |
string
| First geopoint identifier | +| `geopoint2` |
string
| Second geopoint identifier | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `unit` |
string ('m')
| The unit used for the returned calculated distance.
Accepted values: `m`, `km`, `mi`, `ft` | + +## Resolve + +Resolves to the calculated distance. + +## Usage + +<<< ./snippets/geodist.js diff --git a/doc/src/controllers/ms/geodist/snippets/geodist.js b/doc/src/controllers/ms/geodist/snippets/geodist.js new file mode 100644 index 000000000..3d0346846 --- /dev/null +++ b/doc/src/controllers/ms/geodist/snippets/geodist.js @@ -0,0 +1,28 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; + +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: 1367.8521 + console.log(await kuzzle.ms.geodist('geofoo', 'HQ', 'other HQ')); + + // Prints: 4487.7038 + console.log(await kuzzle.ms.geodist( + 'geofoo', + 'HQ', + 'other HQ', + {unit: 'ft'} + )); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/geodist/snippets/geodist.test.yml b/doc/src/controllers/ms/geodist/snippets/geodist.test.yml new file mode 100644 index 000000000..8b97f33bb --- /dev/null +++ b/doc/src/controllers/ms/geodist/snippets/geodist.test.yml @@ -0,0 +1,11 @@ +name: ms#geodist +description: Returns the distance between two geospatial members of a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - 1367.8521 + - 4487.7038 +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/geohash/index.md b/doc/src/controllers/ms/geohash/index.md new file mode 100644 index 000000000..f807cbb5d --- /dev/null +++ b/doc/src/controllers/ms/geohash/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: geohash +--- + +# geohash + +Converts a key's geopoints (see [geoadd](/sdk/js/6/controllers/ms/geoadd)) into [geohashes](https://en.wikipedia.org/wiki/Geohash). + +[[_Redis documentation_]](https://redis.io/commands/geohash) + +## Arguments + +```js +geohash(key, geopoints, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | ---------------------------- | +| `key` |
string
| Key | +| `geopoints` |
string[]
| List of geopoints to convert | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of converted geohashes, in the same order than the one provided in the query. + +## Usage + +<<< ./snippets/geohash.js diff --git a/doc/src/controllers/ms/geohash/snippets/geohash.js b/doc/src/controllers/ms/geohash/snippets/geohash.js new file mode 100644 index 000000000..b15d82316 --- /dev/null +++ b/doc/src/controllers/ms/geohash/snippets/geohash.js @@ -0,0 +1,20 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; + +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: [ 'spfb0frz6x0', 'spfb09jv9n0' ] + console.log(await kuzzle.ms.geohash('geofoo', ['HQ', 'other HQ'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/geohash/snippets/geohash.test.yml b/doc/src/controllers/ms/geohash/snippets/geohash.test.yml new file mode 100644 index 000000000..a7c97b3d6 --- /dev/null +++ b/doc/src/controllers/ms/geohash/snippets/geohash.test.yml @@ -0,0 +1,9 @@ +name: ms#geohash +description: Converts a key's geopoints into geohashes +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "[ 'spfb0frz6x0', 'spfb09jv9n0' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/geopos/index.md b/doc/src/controllers/ms/geopos/index.md new file mode 100644 index 000000000..8603ee29c --- /dev/null +++ b/doc/src/controllers/ms/geopos/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: geopos +--- + +# geopos + +Returns the positions of the provided key's members (see [geoadd](/sdk/js/6/controllers/ms/geoadd)). + +[[_Redis documentation_]](https://redis.io/commands/geopos) + +## Arguments + +```js +geopos(key, geopoints, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | --------------------------- | +| `key` |
string
| Key | +| `geopoints` |
string[]
| List of geopoints to return | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the members positions (`[longitude, latitude]`), in the same order than the one provided in the query. + +## Usage + +<<< ./snippets/geopos.js diff --git a/doc/src/controllers/ms/geopos/snippets/geopos.js b/doc/src/controllers/ms/geopos/snippets/geopos.js new file mode 100644 index 000000000..3eb931671 --- /dev/null +++ b/doc/src/controllers/ms/geopos/snippets/geopos.js @@ -0,0 +1,24 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; + +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: + // [ + // [ 3.910904824733734, 43.607392252329916 ], + // [ 3.8971075415611267, 43.600221526170145 ] + // ] + console.log(await kuzzle.ms.geopos('geofoo', ['HQ', 'other HQ'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/geopos/snippets/geopos.test.yml b/doc/src/controllers/ms/geopos/snippets/geopos.test.yml new file mode 100644 index 000000000..322cc82c4 --- /dev/null +++ b/doc/src/controllers/ms/geopos/snippets/geopos.test.yml @@ -0,0 +1,11 @@ +name: ms#geopos +description: Returns the positions of the provided key's members +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ \\[ 3.910904824733734, 43.607392252329916 ]," + - "\\[ 3.8971075415611267, 43.600221526170145 ] ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/georadius/index.md b/doc/src/controllers/ms/georadius/index.md new file mode 100644 index 000000000..c605cb6ec --- /dev/null +++ b/doc/src/controllers/ms/georadius/index.md @@ -0,0 +1,56 @@ +--- +code: true +type: page +title: georadius +--- + +# georadius + +Returns the members (added with [geoadd](/sdk/js/6/controllers/ms/geoadd)) of a given key inside the provided geospatial radius. + +[[_Redis documentation_]](https://redis.io/commands/georadius) + +## Arguments + +```js +georadius(key, lon, lat, dist, unit, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `lon` |
number
| Longitude of the center | +| `lat` |
number
| Latitude of the center | +| `dist` |
number
| Distance from the center | +| `unit` |
string
| Unit of the distance parameter value.
Allowed values: `m`, `km`, `mi`, `ft` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | -------------------------- | -------------------------------------------------------------------------------------- | +| `count` |
integer
| Limit the number of returned geopoints to the provided value | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `sort` |
string
| Sort the result by distance, relative to the center.
Allowed values: `ASC`, `DESC` | +| `withcoord` |
boolean (false)
| Include the position of the matched geopoint in the result | +| `withdist` |
boolean (false)
| Include the calculated distance from the matched geopoint to center | + +## Resolve + +Resolves to an array of matched geopoints. + +Each returned geopoint is an object with the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ----------------------------------------------------------------------------------------------------------- | +| `name` |
string
| Geopoint identifier | +| `coordinates` |
number[]
| Geopoint coordinates in the following format: `[lon, lat]`. Only available if the option `withcoord` is set | +| `distance` |
number
| Distance from the center. Only available if the option `withdist` is set | + +## Usage + +<<< ./snippets/georadius.js diff --git a/doc/src/controllers/ms/georadius/snippets/georadius.js b/doc/src/controllers/ms/georadius/snippets/georadius.js new file mode 100644 index 000000000..0dba84211 --- /dev/null +++ b/doc/src/controllers/ms/georadius/snippets/georadius.js @@ -0,0 +1,61 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: [ { name: 'other HQ' }, { name: 'HQ' } ] + console.log(await kuzzle.ms.georadius( + 'geofoo', + 3.948711, + 43.5764455, + 20, + 'km' + )); + + // Prints: + // [ + // { name: 'other HQ', distance: 4.9271 }, + // { name: 'HQ', distance: 4.596 } + // ] + console.log(await kuzzle.ms.georadius( + 'geofoo', + 3.948711, + 43.5764455, + 20, + 'km', + {withdist: true, sort: 'desc'} + )); + + // Prints: + // [ + // { + // name: 'HQ', + // distance: 4.596, + // coordinates: [ 3.910904824733734, 43.607392252329916 ] + // }, + // { + // name: 'other HQ', + // distance: 4.9271, + // coordinates: [ 3.8971075415611267, 43.600221526170145 ] + // } + // ] + console.log(await kuzzle.ms.georadius( + 'geofoo', + 3.948711, + 43.5764455, + 20, + 'km', + {withcoord: true, withdist: true, sort: 'asc'} + )); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/georadius/snippets/georadius.test.yml b/doc/src/controllers/ms/georadius/snippets/georadius.test.yml new file mode 100644 index 000000000..c3ca8f98b --- /dev/null +++ b/doc/src/controllers/ms/georadius/snippets/georadius.test.yml @@ -0,0 +1,18 @@ +name: ms#georadius +description: Returns the members of a given key inside the provided geospatial radius +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { name: 'other HQ' }, { name: 'HQ' } " + - "\\[ { name: 'other HQ', distance: 4.9271 }," + - " { name: 'HQ', distance: 4.596 } ]" + - "\\[ { name: 'HQ'," + - " distance: 4.596," + - " coordinates: \\[ 3.910904824733734, 43.607392252329916 ] }," + - " { name: 'other HQ'," + - " distance: 4.9271," + - " coordinates: \\[ 3.8971075415611267, 43.600221526170145 ] } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/georadiusbymember/index.md b/doc/src/controllers/ms/georadiusbymember/index.md new file mode 100644 index 000000000..797c931de --- /dev/null +++ b/doc/src/controllers/ms/georadiusbymember/index.md @@ -0,0 +1,55 @@ +--- +code: true +type: page +title: georadiusbymember +--- + +# georadiusbymember + +Returns the members (added with [geoadd](/sdk/js/6/controllers/ms/geoadd)) of a given key inside the provided geospatial radius, centered around one of a key's member. + +[[_Redis documentation_]](https://redis.io/commands/georadiusbymember) + +## Arguments + +```js +georadiusbymember(key, geopoint, dist, unit, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | ------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `geopoint` |
string
| Name of the geopoint to use as the center | +| `dist` |
number
| Distance from the center | +| `unit` |
string
| Unit of the distance parameter value.
Allowed values: `m`, `km`, `mi`, `ft` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | -------------------------- | -------------------------------------------------------------------------------------- | +| `count` |
integer
| Limit the number of returned geopoints to the provided value | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `sort` |
string
| Sort the result by distance, relative to the center.
Allowed values: `ASC`, `DESC` | +| `withcoord` |
boolean (false)
| Include the position of the matched geopoint in the result | +| `withdist` |
boolean (false)
| Include the calculated distance from the matched geopoint to center | + +## Resolve + +Resolves to an array of matched geopoints. + +Each returned geopoint is an object with the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ----------------------------------------------------------------------------------------------------------- | +| `name` |
string
| Geopoint identifier | +| `coordinates` |
number[]
| Geopoint coordinates in the following format: `[lon, lat]`. Only available if the option `withcoord` is set | +| `distance` |
number
| Distance from the center. Only available if the option `withdist` is set | + +## Usage + +<<< ./snippets/georadiusbymember.js diff --git a/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.js b/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.js new file mode 100644 index 000000000..6cb4a07b5 --- /dev/null +++ b/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.js @@ -0,0 +1,58 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: [ { name: 'other HQ' }, { name: 'HQ' } ] + console.log(await kuzzle.ms.georadiusbymember( + 'geofoo', + 'HQ', + 1500, + 'm' + )); + + // Prints: + // [ + // { name: 'other HQ', distance: 1367.8521 }, + // { name: 'HQ', distance: 0 } + // ] + console.log(await kuzzle.ms.georadiusbymember( + 'geofoo', + 'HQ', + 1500, + 'm', + {withdist: true, sort: 'desc'} + )); + + // Prints: + // [ + // { + // name: 'HQ', + // distance: 0, + // coordinates: [ 3.910904824733734, 43.607392252329916 ] + // }, + // { + // name: 'other HQ', + // distance: 1367.8521, + // coordinates: [ 3.8971075415611267, 43.600221526170145 ] + // } + // ] + console.log(await kuzzle.ms.georadiusbymember( + 'geofoo', + 'HQ', + 1500, + 'm', + {withcoord: true, withdist: true, sort: 'asc'} + )); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml b/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml new file mode 100644 index 000000000..a86177ce7 --- /dev/null +++ b/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml @@ -0,0 +1,18 @@ +name: ms#georadiusbymember +description: Returns the members of a given key inside a radius centered around a key's member +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { name: '(other |)HQ' }, { name: '(other |)HQ' } ]" + - "\\[ { name: 'other HQ', distance: 1367.8521 }," + - " { name: 'HQ', distance: 0 } ]" + - "\\[ { name: 'HQ'," + - " distance: 0," + - " coordinates: \\[ 3.910904824733734, 43.607392252329916 ] }," + - " { name: 'other HQ'," + - " distance: 1367.8521," + - " coordinates: \\[ 3.8971075415611267, 43.600221526170145 ] } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/get/index.md b/doc/src/controllers/ms/get/index.md new file mode 100644 index 000000000..c128a9317 --- /dev/null +++ b/doc/src/controllers/ms/get/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: get +--- + +# get + +Gets the value of a key. + +[[_Redis documentation_]](https://redis.io/commands/get) + +## Arguments + +```js +get(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the key's value. + +## Usage + +<<< ./snippets/get.js diff --git a/doc/src/controllers/ms/get/snippets/get.js b/doc/src/controllers/ms/get/snippets/get.js new file mode 100644 index 000000000..a96b3fd23 --- /dev/null +++ b/doc/src/controllers/ms/get/snippets/get.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 'bar' + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/get/snippets/get.test.yml b/doc/src/controllers/ms/get/snippets/get.test.yml new file mode 100644 index 000000000..ede9c73c5 --- /dev/null +++ b/doc/src/controllers/ms/get/snippets/get.test.yml @@ -0,0 +1,9 @@ +name: ms#get +description: Gets the value of a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: bar +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/getbit/index.md b/doc/src/controllers/ms/getbit/index.md new file mode 100644 index 000000000..7a2da9a1d --- /dev/null +++ b/doc/src/controllers/ms/getbit/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: getbit +--- + +# getbit + +Returns the bit value at the provided offset, in the string value stored in a key. + +[[_Redis documentation_]](https://redis.io/commands/getbit) + +## Arguments + +```js +getbit(key, offset, options]) + +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `offset` |
integer
| Bit offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the bit at the provided offset (`0` or `1`). + +## Usage + +<<< ./snippets/getbit.js diff --git a/doc/src/controllers/ms/getbit/snippets/getbit.js b/doc/src/controllers/ms/getbit/snippets/getbit.js new file mode 100644 index 000000000..9c3755030 --- /dev/null +++ b/doc/src/controllers/ms/getbit/snippets/getbit.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('foo', '\x01'); + + // Prints: 0 + console.log(await kuzzle.ms.getbit('foo', 2)); + + // Prints: 1 + console.log(await kuzzle.ms.getbit('foo', 7)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/getbit/snippets/getbit.test.yml b/doc/src/controllers/ms/getbit/snippets/getbit.test.yml new file mode 100644 index 000000000..ea8ca01aa --- /dev/null +++ b/doc/src/controllers/ms/getbit/snippets/getbit.test.yml @@ -0,0 +1,11 @@ +name: ms#getbit +description: Returns the bit value at the provided offset +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^1$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/getrange/index.md b/doc/src/controllers/ms/getrange/index.md new file mode 100644 index 000000000..735bbe6e3 --- /dev/null +++ b/doc/src/controllers/ms/getrange/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: getrange +--- + +# getrange + +Returns a substring of a key's value. + +[[_Redis documentation_]](https://redis.io/commands/getrange) + +## Arguments + +```js +getrange(key, start, end, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `start` |
integer
| Range start | +| `end` |
integer
| Range end | +| `options` |
object
| Optional query arguments | + +The arguments `start` and `end` can be negative. In that case, the offset is calculated from the end of the string, going backward. For instance, -3 is the third character from the end of the string. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the extracted substring. + +## Usage + +<<< ./snippets/getrange.js diff --git a/doc/src/controllers/ms/getrange/snippets/getrange.js b/doc/src/controllers/ms/getrange/snippets/getrange.js new file mode 100644 index 000000000..653f100c4 --- /dev/null +++ b/doc/src/controllers/ms/getrange/snippets/getrange.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('foo', 'foobar'); + + // Prints: 'oba' + console.log(await kuzzle.ms.getrange('foo', 2, 4)); + + // Prints: 'bar' + console.log(await kuzzle.ms.getrange('foo', -3, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/getrange/snippets/getrange.test.yml b/doc/src/controllers/ms/getrange/snippets/getrange.test.yml new file mode 100644 index 000000000..052d7892c --- /dev/null +++ b/doc/src/controllers/ms/getrange/snippets/getrange.test.yml @@ -0,0 +1,11 @@ +name: ms#getrange +description: Returns a substring of a key's value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^oba$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/getset/index.md b/doc/src/controllers/ms/getset/index.md new file mode 100644 index 000000000..2db4e8667 --- /dev/null +++ b/doc/src/controllers/ms/getset/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: getset +--- + +# getset + +Sets a new value for a key, and returns its previously stored value. + +[[_Redis documentation_]](https://redis.io/commands/getset) + +## Arguments + +```js +getset(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
\*
| New key value. | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the previously set value, or `null` if the key didn't exist prior to this operation. + +## Usage + +<<< ./snippets/getset.js diff --git a/doc/src/controllers/ms/getset/snippets/getset.js b/doc/src/controllers/ms/getset/snippets/getset.js new file mode 100644 index 000000000..c94e699ff --- /dev/null +++ b/doc/src/controllers/ms/getset/snippets/getset.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 'bar' + console.log(await kuzzle.ms.getset('foo', 'qux')); + + // Prints: 'qux' + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/getset/snippets/getset.test.yml b/doc/src/controllers/ms/getset/snippets/getset.test.yml new file mode 100644 index 000000000..1ae03ae64 --- /dev/null +++ b/doc/src/controllers/ms/getset/snippets/getset.test.yml @@ -0,0 +1,11 @@ +name: ms#getset +description: Sets a new value for a key, and returns its previously stored value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^bar$ + - ^qux$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hdel/index.md b/doc/src/controllers/ms/hdel/index.md new file mode 100644 index 000000000..38c1f83ca --- /dev/null +++ b/doc/src/controllers/ms/hdel/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hdel +--- + +# hdel + +Removes fields from a hash. + +[[_Redis documentation_]](https://redis.io/commands/hdel) + +## Arguments + +```js +hdel(key, fields, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Hash key | +| `fields` |
string[]
| Field keys to delete | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of deleted fields. + +## Usage + +<<< ./snippets/hdel.js diff --git a/doc/src/controllers/ms/hdel/snippets/hdel.js b/doc/src/controllers/ms/hdel/snippets/hdel.js new file mode 100644 index 000000000..bf39b7875 --- /dev/null +++ b/doc/src/controllers/ms/hdel/snippets/hdel.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.hset('hashfoo', 'field1', 'val'); + await kuzzle.ms.hset('hashfoo', 'field2', 'val'); + + // Prints: 2 + console.log(await kuzzle.ms.hlen('hashfoo')); + + await kuzzle.ms.hdel('hashfoo', ['field2']); + + // Prints: 1 + console.log(await kuzzle.ms.hlen('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hdel/snippets/hdel.test.yml b/doc/src/controllers/ms/hdel/snippets/hdel.test.yml new file mode 100644 index 000000000..b460b4995 --- /dev/null +++ b/doc/src/controllers/ms/hdel/snippets/hdel.test.yml @@ -0,0 +1,11 @@ +name: ms#hdel +description: Removes fields from a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - ^1$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hexists/index.md b/doc/src/controllers/ms/hexists/index.md new file mode 100644 index 000000000..fd1473b39 --- /dev/null +++ b/doc/src/controllers/ms/hexists/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hexists +--- + +# hexists + +Checks if a field exists in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hexists) + +## Arguments + +```js +hexists(key, field, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the checked field exists or not. + +## Usage + +<<< ./snippets/hexists.js diff --git a/doc/src/controllers/ms/hexists/snippets/hexists.js b/doc/src/controllers/ms/hexists/snippets/hexists.js new file mode 100644 index 000000000..f4c7702cd --- /dev/null +++ b/doc/src/controllers/ms/hexists/snippets/hexists.js @@ -0,0 +1,11 @@ +try { + // Prints: false + console.log(await kuzzle.ms.hexists('hashfoo', 'foo')); + + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: true + console.log(await kuzzle.ms.hexists('hashfoo', 'foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hexists/snippets/hexists.test.yml b/doc/src/controllers/ms/hexists/snippets/hexists.test.yml new file mode 100644 index 000000000..7d599a8f7 --- /dev/null +++ b/doc/src/controllers/ms/hexists/snippets/hexists.test.yml @@ -0,0 +1,11 @@ +name: ms#hexists +description: Checks if a field exists in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^false$ + - ^true$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hget/index.md b/doc/src/controllers/ms/hget/index.md new file mode 100644 index 000000000..141228e71 --- /dev/null +++ b/doc/src/controllers/ms/hget/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hget +--- + +# hget + +Returns the field's value of a hash. + +[[_Redis documentation_]](https://redis.io/commands/hget) + +## Arguments + +```js +hget(key, field, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Returns the field's value. + +## Usage + +<<< ./snippets/hget.js diff --git a/doc/src/controllers/ms/hget/snippets/hget.js b/doc/src/controllers/ms/hget/snippets/hget.js new file mode 100644 index 000000000..1ba799358 --- /dev/null +++ b/doc/src/controllers/ms/hget/snippets/hget.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: 'bar' + console.log(await kuzzle.ms.hget('hashfoo', 'foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hget/snippets/hget.test.yml b/doc/src/controllers/ms/hget/snippets/hget.test.yml new file mode 100644 index 000000000..d020ee976 --- /dev/null +++ b/doc/src/controllers/ms/hget/snippets/hget.test.yml @@ -0,0 +1,9 @@ +name: ms#hget +description: Returns the field's value of a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hgetall/index.md b/doc/src/controllers/ms/hgetall/index.md new file mode 100644 index 000000000..99de3f6bd --- /dev/null +++ b/doc/src/controllers/ms/hgetall/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hgetall +--- + +# hgetall + +Returns all fields and values of a hash. + +[[_Redis documentation_]](https://redis.io/commands/hgetall) + +## Arguments + +```js +hgetall(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representation of the hash. + +## Usage + +<<< ./snippets/hgetall.js diff --git a/doc/src/controllers/ms/hgetall/snippets/hgetall.js b/doc/src/controllers/ms/hgetall/snippets/hgetall.js new file mode 100644 index 000000000..bf19115fc --- /dev/null +++ b/doc/src/controllers/ms/hgetall/snippets/hgetall.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.hset('hashfoo', 'field1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'field2', 'val2'); + + // Prints: { field1: 'val1', field2: 'val2' } + console.log(await kuzzle.ms.hgetall('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hgetall/snippets/hgetall.test.yml b/doc/src/controllers/ms/hgetall/snippets/hgetall.test.yml new file mode 100644 index 000000000..372468a4e --- /dev/null +++ b/doc/src/controllers/ms/hgetall/snippets/hgetall.test.yml @@ -0,0 +1,9 @@ +name: ms#hgetall +description: Returns all fields and values of a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "{ field1: 'val1', field2: 'val2' }" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hincrby/index.md b/doc/src/controllers/ms/hincrby/index.md new file mode 100644 index 000000000..d280835d7 --- /dev/null +++ b/doc/src/controllers/ms/hincrby/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: hincrby +--- + +# hincrby + +Increments the number stored in a hash field by the provided integer value. + +[[_Redis documentation_]](https://redis.io/commands/hincrby) + +## Arguments + +```js +hincrby(key, field, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `increment` |
integer
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated value of the hash's field. + +## Usage + +<<< ./snippets/hincrby.js diff --git a/doc/src/controllers/ms/hincrby/snippets/hincrby.js b/doc/src/controllers/ms/hincrby/snippets/hincrby.js new file mode 100644 index 000000000..ce4190e4b --- /dev/null +++ b/doc/src/controllers/ms/hincrby/snippets/hincrby.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'answer', 100); + + // Prints: 42 + console.log(await kuzzle.ms.hincrby('hashfoo', 'answer', -58)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hincrby/snippets/hincrby.test.yml b/doc/src/controllers/ms/hincrby/snippets/hincrby.test.yml new file mode 100644 index 000000000..3fce3c9b1 --- /dev/null +++ b/doc/src/controllers/ms/hincrby/snippets/hincrby.test.yml @@ -0,0 +1,9 @@ +name: ms#hincrby +description: Increments the number stored in a hash field by the provided integer value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^42$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hincrbyfloat/index.md b/doc/src/controllers/ms/hincrbyfloat/index.md new file mode 100644 index 000000000..f72b5f865 --- /dev/null +++ b/doc/src/controllers/ms/hincrbyfloat/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: hincrbyfloat +--- + +# hincrbyfloat + +Increments the number stored in a hash field by the provided float value. + +[[_Redis documentation_]](https://redis.io/commands/hincrbyfloat) + +## Arguments + +```js +hincrbyfloat(key, field, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `increment` |
number
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated value of the hash's field. + +## Usage + +<<< ./snippets/hincrbyfloat.js diff --git a/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js b/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js new file mode 100644 index 000000000..d64d30df2 --- /dev/null +++ b/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'almost_pi', 3); + + // Prints: 3.14159 + console.log(await kuzzle.ms.hincrbyfloat('hashfoo', 'almost_pi', 0.14159)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml b/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml new file mode 100644 index 000000000..9fc6064bc --- /dev/null +++ b/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml @@ -0,0 +1,9 @@ +name: ms#hincrbyfloat +description: Increments the number stored in a hash field by the provided float value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3.14159$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hkeys/index.md b/doc/src/controllers/ms/hkeys/index.md new file mode 100644 index 000000000..11d1e5063 --- /dev/null +++ b/doc/src/controllers/ms/hkeys/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hkeys +--- + +# hkeys + +Returns all field names contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hkeys) + +## Arguments + +```js +hkeys(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of hash field names. + +## Usage + +<<< ./snippets/hkeys.js diff --git a/doc/src/controllers/ms/hkeys/snippets/hkeys.js b/doc/src/controllers/ms/hkeys/snippets/hkeys.js new file mode 100644 index 000000000..799a493a4 --- /dev/null +++ b/doc/src/controllers/ms/hkeys/snippets/hkeys.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.hset('hashfoo', 'never', 'foo'); + await kuzzle.ms.hset('hashfoo', 'gonna', 'bar'); + await kuzzle.ms.hset('hashfoo', 'give you up', 'baz'); + + // Prints: ['never', 'gonna', 'give you up'] + console.log(await kuzzle.ms.hkeys('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hkeys/snippets/hkeys.test.yml b/doc/src/controllers/ms/hkeys/snippets/hkeys.test.yml new file mode 100644 index 000000000..91f00c124 --- /dev/null +++ b/doc/src/controllers/ms/hkeys/snippets/hkeys.test.yml @@ -0,0 +1,9 @@ +name: ms#hkeys +description: Returns all field names contained in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: \[ 'never', 'gonna', 'give you up' ] +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hlen/index.md b/doc/src/controllers/ms/hlen/index.md new file mode 100644 index 000000000..06421b8f7 --- /dev/null +++ b/doc/src/controllers/ms/hlen/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hlen +--- + +# hlen + +Returns the number of fields contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hlen) + +## Arguments + +```js +hlen(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of fields stored in a hash. + +## Usage + +<<< ./snippets/hlen.js diff --git a/doc/src/controllers/ms/hlen/snippets/hlen.js b/doc/src/controllers/ms/hlen/snippets/hlen.js new file mode 100644 index 000000000..4f0ff81ac --- /dev/null +++ b/doc/src/controllers/ms/hlen/snippets/hlen.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: 3 + console.log(await kuzzle.ms.hlen('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hlen/snippets/hlen.test.yml b/doc/src/controllers/ms/hlen/snippets/hlen.test.yml new file mode 100644 index 000000000..48c6a46b9 --- /dev/null +++ b/doc/src/controllers/ms/hlen/snippets/hlen.test.yml @@ -0,0 +1,9 @@ +name: ms#hlen +description: Returns the number of fields contained in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hmget/index.md b/doc/src/controllers/ms/hmget/index.md new file mode 100644 index 000000000..756ad89bd --- /dev/null +++ b/doc/src/controllers/ms/hmget/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hmget +--- + +# hmget + +Returns the values of the specified hash's fields. + +[[_Redis documentation_]](https://redis.io/commands/hmget) + +## Arguments + +```js +hmget(key, fields, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Hash key | +| `fields` |
string[]
| Field names | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of requested field values, in the same order than in the query. + +## Usage + +<<< ./snippets/hmget.js diff --git a/doc/src/controllers/ms/hmget/snippets/hmget.js b/doc/src/controllers/ms/hmget/snippets/hmget.js new file mode 100644 index 000000000..75883c886 --- /dev/null +++ b/doc/src/controllers/ms/hmget/snippets/hmget.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: [ 'val3', 'val1' ] + console.log(await kuzzle.ms.hmget('hashfoo', ['key3', 'key1'])); + +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hmget/snippets/hmget.test.yml b/doc/src/controllers/ms/hmget/snippets/hmget.test.yml new file mode 100644 index 000000000..3a9848b28 --- /dev/null +++ b/doc/src/controllers/ms/hmget/snippets/hmget.test.yml @@ -0,0 +1,9 @@ +name: ms#hmget +description: Returns the values of the specified hash's fields +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: \[ 'val3', 'val1' ] +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hmset/index.md b/doc/src/controllers/ms/hmset/index.md new file mode 100644 index 000000000..757f061b1 --- /dev/null +++ b/doc/src/controllers/ms/hmset/index.md @@ -0,0 +1,50 @@ +--- +code: true +type: page +title: hmset +--- + +# hmset + +Sets multiple fields at once in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hmset) + +## Arguments + +```js +hmset(key, entries, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | -------------------------------- | +| `key` |
string
| Hash key | +| `entries` |
object[]
| List of field-value pairs to set | +| `options` |
object
| Optional query arguments | + +### entries + +The `entries` array lists the fields to set in the hash. Each entry object has the following properties: + +| Properties | Type | Description | +| ---------- | ----------------- | ----------- | +| `field` |
string
| Field name | +| `value` |
string
| Field value | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the fields have been set. + +## Usage + +<<< ./snippets/hmset.js diff --git a/doc/src/controllers/ms/hmset/snippets/hmset.js b/doc/src/controllers/ms/hmset/snippets/hmset.js new file mode 100644 index 000000000..81ebbdc55 --- /dev/null +++ b/doc/src/controllers/ms/hmset/snippets/hmset.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.hmset( + 'hashfoo', + [ + {field: 'key1', value: 'val1'}, + {field: 'key2', value: 'val2'}, + {field: 'key3', value: 'val3'} + ] + ); + + // Prints: { key1: 'val1', key2: 'val2', key3: 'val3' } + console.log(await kuzzle.ms.hgetall('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hmset/snippets/hmset.test.yml b/doc/src/controllers/ms/hmset/snippets/hmset.test.yml new file mode 100644 index 000000000..fbda2f343 --- /dev/null +++ b/doc/src/controllers/ms/hmset/snippets/hmset.test.yml @@ -0,0 +1,9 @@ +name: ms#hmset +description: Sets multiple fields at once in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: { key1: 'val1', key2: 'val2', key3: 'val3' } +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hscan/index.md b/doc/src/controllers/ms/hscan/index.md new file mode 100644 index 000000000..5112e513e --- /dev/null +++ b/doc/src/controllers/ms/hscan/index.md @@ -0,0 +1,53 @@ +--- +code: true +type: page +title: hscan +--- + +# hscan + +Iterates incrementally over fields contained in a hash, using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/hscan) + +## Arguments + +```js +hscan(key, cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Hash key | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | ----------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of field-value pairs, alternating field names and values | + +## Usage + +<<< ./snippets/hscan.js diff --git a/doc/src/controllers/ms/hscan/snippets/hscan.js b/doc/src/controllers/ms/hscan/snippets/hscan.js new file mode 100644 index 000000000..7aca23b5e --- /dev/null +++ b/doc/src/controllers/ms/hscan/snippets/hscan.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: + // { + // cursor: '0', + // values: [ 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' ] + // } + console.log(await kuzzle.ms.hscan('hashfoo', 0)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hscan/snippets/hscan.test.yml b/doc/src/controllers/ms/hscan/snippets/hscan.test.yml new file mode 100644 index 000000000..ac0824180 --- /dev/null +++ b/doc/src/controllers/ms/hscan/snippets/hscan.test.yml @@ -0,0 +1,11 @@ +name: ms#hscan +description: Iterates incrementally over fields contained in a hash, using a cursor +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0'," + - "values: \\[ 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' ] }" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hset/index.md b/doc/src/controllers/ms/hset/index.md new file mode 100644 index 000000000..d45888150 --- /dev/null +++ b/doc/src/controllers/ms/hset/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: hset +--- + +# hset + +Sets a field and its value in a hash. + +If the key does not exist, a new key holding a hash is created. + +If the field already exists, its value is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/hset) + +## Arguments + +```js +hset(key, field, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `value` |
string
| Field value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the field has been set. + +## Usage + +<<< ./snippets/hset.js diff --git a/doc/src/controllers/ms/hset/snippets/hset.js b/doc/src/controllers/ms/hset/snippets/hset.js new file mode 100644 index 000000000..f5416da3f --- /dev/null +++ b/doc/src/controllers/ms/hset/snippets/hset.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: { foo: 'bar' } + console.log(await kuzzle.ms.hgetall('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hset/snippets/hset.test.yml b/doc/src/controllers/ms/hset/snippets/hset.test.yml new file mode 100644 index 000000000..f8f074f45 --- /dev/null +++ b/doc/src/controllers/ms/hset/snippets/hset.test.yml @@ -0,0 +1,9 @@ +name: ms#hset +description: Sets a field and its value in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "{ foo: 'bar' }" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hsetnx/index.md b/doc/src/controllers/ms/hsetnx/index.md new file mode 100644 index 000000000..f49525e41 --- /dev/null +++ b/doc/src/controllers/ms/hsetnx/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: hsetnx +--- + +# hsetnx + +Sets a field and its value in a hash, only if the field does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/hsetnx) + +## Arguments + +```js +hsetnx(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +## Usage + +<<< ./snippets/hsetnx.js diff --git a/doc/src/controllers/ms/hsetnx/snippets/hsetnx.js b/doc/src/controllers/ms/hsetnx/snippets/hsetnx.js new file mode 100644 index 000000000..3d35c494a --- /dev/null +++ b/doc/src/controllers/ms/hsetnx/snippets/hsetnx.js @@ -0,0 +1,13 @@ +try { + // Prints: true + console.log(await kuzzle.ms.hsetnx('hashfoo', 'foo', 'bar')); + + // Prints: false + console.log(await kuzzle.ms.hsetnx('hashfoo', 'foo', 'qux')); + + // Prints: bar + console.log(await kuzzle.ms.hget('hashfoo', 'foo')); + +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hsetnx/snippets/hsetnx.test.yml b/doc/src/controllers/ms/hsetnx/snippets/hsetnx.test.yml new file mode 100644 index 000000000..7742ae0c6 --- /dev/null +++ b/doc/src/controllers/ms/hsetnx/snippets/hsetnx.test.yml @@ -0,0 +1,12 @@ +name: ms#hsetnx +description: Sets a field and its value in a hash, only if the field does not already exist +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^true$ + - ^false$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hstrlen/index.md b/doc/src/controllers/ms/hstrlen/index.md new file mode 100644 index 000000000..23f2ce826 --- /dev/null +++ b/doc/src/controllers/ms/hstrlen/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hstrlen +--- + +# hstrlen + +Returns the string length of a field's value in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hstrlen) + +## Arguments + +```js +hstrlen(key, field, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `field` |
string
| Field name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the field value length. + +## Usage + +<<< ./snippets/hstrlen.js diff --git a/doc/src/controllers/ms/hstrlen/snippets/hstrlen.js b/doc/src/controllers/ms/hstrlen/snippets/hstrlen.js new file mode 100644 index 000000000..ff3e5e7bd --- /dev/null +++ b/doc/src/controllers/ms/hstrlen/snippets/hstrlen.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: 3 + console.log(await kuzzle.ms.hstrlen('hashfoo', 'foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hstrlen/snippets/hstrlen.test.yml b/doc/src/controllers/ms/hstrlen/snippets/hstrlen.test.yml new file mode 100644 index 000000000..ef71bdf52 --- /dev/null +++ b/doc/src/controllers/ms/hstrlen/snippets/hstrlen.test.yml @@ -0,0 +1,9 @@ +name: ms#hstrlen +description: Returns the string length of a field's value in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/hvals/index.md b/doc/src/controllers/ms/hvals/index.md new file mode 100644 index 000000000..7efa03a56 --- /dev/null +++ b/doc/src/controllers/ms/hvals/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hvals +--- + +# hvals + +Returns all values contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hvals) + +## Arguments + +```js +hvals(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of hash's field values. + +## Usage + +<<< ./snippets/hvals.js diff --git a/doc/src/controllers/ms/hvals/snippets/hvals.js b/doc/src/controllers/ms/hvals/snippets/hvals.js new file mode 100644 index 000000000..4d3159555 --- /dev/null +++ b/doc/src/controllers/ms/hvals/snippets/hvals.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: [ 'val1', 'val2', 'val3' ] + console.log(await kuzzle.ms.hvals('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/hvals/snippets/hvals.test.yml b/doc/src/controllers/ms/hvals/snippets/hvals.test.yml new file mode 100644 index 000000000..efe75d69d --- /dev/null +++ b/doc/src/controllers/ms/hvals/snippets/hvals.test.yml @@ -0,0 +1,9 @@ +name: ms#hvals +description: Returns all values contained in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'val1', 'val2', 'val3' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/incr/index.md b/doc/src/controllers/ms/incr/index.md new file mode 100644 index 000000000..81ac08daa --- /dev/null +++ b/doc/src/controllers/ms/incr/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: incr +--- + +# incr + +Increments the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incr) + +## Arguments + +```js +incr(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the incremented key value. + +## Usage + +<<< ./snippets/incr.js diff --git a/doc/src/controllers/ms/incr/snippets/incr.js b/doc/src/controllers/ms/incr/snippets/incr.js new file mode 100644 index 000000000..833c8b1b3 --- /dev/null +++ b/doc/src/controllers/ms/incr/snippets/incr.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 41); + + // Prints: 42 + console.log(await kuzzle.ms.incr('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/incr/snippets/incr.test.yml b/doc/src/controllers/ms/incr/snippets/incr.test.yml new file mode 100644 index 000000000..8eb956a22 --- /dev/null +++ b/doc/src/controllers/ms/incr/snippets/incr.test.yml @@ -0,0 +1,9 @@ +name: ms#incr +description: Increments the number stored at key by 1 +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^42$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/incrby/index.md b/doc/src/controllers/ms/incrby/index.md new file mode 100644 index 000000000..fc17f6264 --- /dev/null +++ b/doc/src/controllers/ms/incrby/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: incrby +--- + +# incrby + +Increments the number stored at `key` by the provided integer value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incrby) + +## Arguments + +```js +incrby(key, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `increment` |
integer
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the incremented key value. + +## Usage + +<<< ./snippets/incrby.js diff --git a/doc/src/controllers/ms/incrby/snippets/incrby.js b/doc/src/controllers/ms/incrby/snippets/incrby.js new file mode 100644 index 000000000..9fbf7e5a0 --- /dev/null +++ b/doc/src/controllers/ms/incrby/snippets/incrby.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 100); + + // Prints: 42 + console.log(await kuzzle.ms.incrby('foo', -58)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/incrby/snippets/incrby.test.yml b/doc/src/controllers/ms/incrby/snippets/incrby.test.yml new file mode 100644 index 000000000..66b93f139 --- /dev/null +++ b/doc/src/controllers/ms/incrby/snippets/incrby.test.yml @@ -0,0 +1,9 @@ +name: ms#incrby +description: Increments the number stored at `key` by the provided integer value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^42$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/incrbyfloat/index.md b/doc/src/controllers/ms/incrbyfloat/index.md new file mode 100644 index 000000000..fca7286f8 --- /dev/null +++ b/doc/src/controllers/ms/incrbyfloat/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: incrbyfloat +--- + +# incrbyfloat + +Increments the number stored at `key` by the provided float value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incrbyfloat) + +## Arguments + +```js +incrbyfloat(key, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `increment` |
number
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the incremented value. + +## Usage + +<<< ./snippets/incrbyfloat.js diff --git a/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.js b/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.js new file mode 100644 index 000000000..c518c2614 --- /dev/null +++ b/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('almost pi', 3); + + // Prints: 3.14159 + console.log(await kuzzle.ms.incrbyfloat('almost pi', 0.14159)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml b/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml new file mode 100644 index 000000000..f9695c2f5 --- /dev/null +++ b/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml @@ -0,0 +1,9 @@ +name: ms#incrbyfloat +description: Increments the number stored at key by the provided float value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3.14159$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/index.md b/doc/src/controllers/ms/index.md new file mode 100644 index 000000000..02d0feef7 --- /dev/null +++ b/doc/src/controllers/ms/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: ms +description: memory storage controller documentation +--- diff --git a/doc/src/controllers/ms/keys/index.md b/doc/src/controllers/ms/keys/index.md new file mode 100644 index 000000000..53433d409 --- /dev/null +++ b/doc/src/controllers/ms/keys/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: keys +--- + +# keys + +Returns all keys matching the provided pattern. + +[[_Redis documentation_]](https://redis.io/commands/keys) + +## Arguments + +```js +keys(pattern, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ----------------- | +| `pattern` |
string
| Match pattern | +| | `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of key identifiers. + +## Usage + +<<< ./snippets/keys.js diff --git a/doc/src/controllers/ms/keys/snippets/keys.js b/doc/src/controllers/ms/keys/snippets/keys.js new file mode 100644 index 000000000..bcf66a5d7 --- /dev/null +++ b/doc/src/controllers/ms/keys/snippets/keys.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + await kuzzle.ms.set('Suddenly', 'Bananas'); + await kuzzle.ms.set('Hello', 'World'); + + // Prints: [ 'foo', 'Hello' ] + console.log(await kuzzle.ms.keys('*o')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/keys/snippets/keys.test.yml b/doc/src/controllers/ms/keys/snippets/keys.test.yml new file mode 100644 index 000000000..ec079ebad --- /dev/null +++ b/doc/src/controllers/ms/keys/snippets/keys.test.yml @@ -0,0 +1,9 @@ +name: ms#keys +description: Returns all keys matching the provided pattern +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ '(Hello|foo)', '(Hello|foo)' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lindex/index.md b/doc/src/controllers/ms/lindex/index.md new file mode 100644 index 000000000..2841425a3 --- /dev/null +++ b/doc/src/controllers/ms/lindex/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: lindex +--- + +# lindex + +Returns the element at the provided index in a list. + +[[_Redis documentation_]](https://redis.io/commands/lindex) + +## Arguments + +```js +lindex(key, index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| List key | +| `index` |
integer
| List index | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the stored value at the provided list index. + +## Usage + +<<< ./snippets/lindex.js diff --git a/doc/src/controllers/ms/lindex/snippets/lindex.js b/doc/src/controllers/ms/lindex/snippets/lindex.js new file mode 100644 index 000000000..5effdd332 --- /dev/null +++ b/doc/src/controllers/ms/lindex/snippets/lindex.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: bar + console.log(await kuzzle.ms.lindex('listfoo', 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lindex/snippets/lindex.test.yml b/doc/src/controllers/ms/lindex/snippets/lindex.test.yml new file mode 100644 index 000000000..8abf7ad84 --- /dev/null +++ b/doc/src/controllers/ms/lindex/snippets/lindex.test.yml @@ -0,0 +1,9 @@ +name: ms#lindex +description: Returns the element at the provided index in a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/linsert/index.md b/doc/src/controllers/ms/linsert/index.md new file mode 100644 index 000000000..5bba89e36 --- /dev/null +++ b/doc/src/controllers/ms/linsert/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: linsert +--- + +# linsert + +Inserts a value in a list, either before or after a pivot value. + +[[_Redis documentation_]](https://redis.io/commands/linsert) + +## Arguments + +```js +linsert(key, position, pivot, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | --------------------------------------------------------------------- | +| `key` |
string
| List key | +| `position` |
string
| Position relative to the pivot.
Allowed values: `before`, `after` | +| `pivot` |
string
| Existing list value to use as a pivot | +| `value` |
string
| Value to insert | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated length of the list. + +## Usage + +<<< ./snippets/linsert.js diff --git a/doc/src/controllers/ms/linsert/snippets/linsert.js b/doc/src/controllers/ms/linsert/snippets/linsert.js new file mode 100644 index 000000000..1c73644d8 --- /dev/null +++ b/doc/src/controllers/ms/linsert/snippets/linsert.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + await kuzzle.ms.linsert('listfoo', 'before', 'bar', 'qux'); + + // Prints: [ 'foo', 'qux', 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/linsert/snippets/linsert.test.yml b/doc/src/controllers/ms/linsert/snippets/linsert.test.yml new file mode 100644 index 000000000..ffa21f82c --- /dev/null +++ b/doc/src/controllers/ms/linsert/snippets/linsert.test.yml @@ -0,0 +1,9 @@ +name: ms#linsert +description: Inserts a value in a list, either before or after a pivot value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo', 'qux', 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/llen/index.md b/doc/src/controllers/ms/llen/index.md new file mode 100644 index 000000000..be28549f7 --- /dev/null +++ b/doc/src/controllers/ms/llen/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: llen +--- + +# llen + +Returns the length of a list. + +[[_Redis documentation_]](https://redis.io/commands/llen) + +## Arguments + +```js +llen(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the length of the list. + +## Usage + +<<< ./snippets/llen.js diff --git a/doc/src/controllers/ms/llen/snippets/llen.js b/doc/src/controllers/ms/llen/snippets/llen.js new file mode 100644 index 000000000..7ff06fa91 --- /dev/null +++ b/doc/src/controllers/ms/llen/snippets/llen.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: 3 + console.log(await kuzzle.ms.llen('listfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/llen/snippets/llen.test.yml b/doc/src/controllers/ms/llen/snippets/llen.test.yml new file mode 100644 index 000000000..65112883a --- /dev/null +++ b/doc/src/controllers/ms/llen/snippets/llen.test.yml @@ -0,0 +1,9 @@ +name: ms#llen +description: Returns the length of a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lpop/index.md b/doc/src/controllers/ms/lpop/index.md new file mode 100644 index 000000000..dc2533a33 --- /dev/null +++ b/doc/src/controllers/ms/lpop/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: lpop +--- + +# lpop + +Removes and returns the first element of a list. + +[[_Redis documentation_]](https://redis.io/commands/lpop) + +## Arguments + +```js +lpop(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the value extracted from the list. + +## Usage + +<<< ./snippets/lpop.js diff --git a/doc/src/controllers/ms/lpop/snippets/lpop.js b/doc/src/controllers/ms/lpop/snippets/lpop.js new file mode 100644 index 000000000..1e411615d --- /dev/null +++ b/doc/src/controllers/ms/lpop/snippets/lpop.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: foo + console.log(await kuzzle.ms.lpop('listfoo')); + + // Prints: [ 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lpop/snippets/lpop.test.yml b/doc/src/controllers/ms/lpop/snippets/lpop.test.yml new file mode 100644 index 000000000..c812c4378 --- /dev/null +++ b/doc/src/controllers/ms/lpop/snippets/lpop.test.yml @@ -0,0 +1,11 @@ +name: ms#lpop +description: Removes and returns the first element of a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^foo$ + - "\\[ 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lpush/index.md b/doc/src/controllers/ms/lpush/index.md new file mode 100644 index 000000000..abe0e6fc1 --- /dev/null +++ b/doc/src/controllers/ms/lpush/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: lpush +--- + +# lpush + +Prepends the specified values to a list. + +If the key does not exist, it is created holding an empty list before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/lpush) + +## Arguments + +```js +lpush(key, values, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| List key | +| `values` |
string[]
| Values to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated length of the list. + +## Usage + +<<< ./snippets/lpush.js diff --git a/doc/src/controllers/ms/lpush/snippets/lpush.js b/doc/src/controllers/ms/lpush/snippets/lpush.js new file mode 100644 index 000000000..e8a8534f2 --- /dev/null +++ b/doc/src/controllers/ms/lpush/snippets/lpush.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foobar']); + + // Prints: 3 + console.log(await kuzzle.ms.lpush('listfoo', ['World', 'Hello'])); + + // Prints: [ 'Hello', 'World', 'foobar' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lpush/snippets/lpush.test.yml b/doc/src/controllers/ms/lpush/snippets/lpush.test.yml new file mode 100644 index 000000000..0d671ed18 --- /dev/null +++ b/doc/src/controllers/ms/lpush/snippets/lpush.test.yml @@ -0,0 +1,11 @@ +name: ms#lpush +description: Prepends the specified values to a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^3$ + - "\\[ 'Hello', 'World', 'foobar' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lpushx/index.md b/doc/src/controllers/ms/lpushx/index.md new file mode 100644 index 000000000..37606192d --- /dev/null +++ b/doc/src/controllers/ms/lpushx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: lpushx +--- + +# lpushx + +Prepends the specified value to a list, only if the key already exists and if it holds a list. + +[[_Redis documentation_]](https://redis.io/commands/lpushx) + +## Arguments + +```js +lpushx(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Existing list key | +| `value` |
string
| Value to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated list length. + +## Usage + +<<< ./snippets/lpushx.js diff --git a/doc/src/controllers/ms/lpushx/snippets/lpushx.js b/doc/src/controllers/ms/lpushx/snippets/lpushx.js new file mode 100644 index 000000000..0adf26657 --- /dev/null +++ b/doc/src/controllers/ms/lpushx/snippets/lpushx.js @@ -0,0 +1,17 @@ +try { + // Prints: 0 + console.log(await kuzzle.ms.lpushx('listfoo', 'foo')); + + // Prints: [] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); + + await kuzzle.ms.lpush('listfoo', ['bar']); + + // Prints: 2 + console.log(await kuzzle.ms.lpushx('listfoo', 'foo')); + + // Prints: [ 'foo', 'bar' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lpushx/snippets/lpushx.test.yml b/doc/src/controllers/ms/lpushx/snippets/lpushx.test.yml new file mode 100644 index 000000000..029a61412 --- /dev/null +++ b/doc/src/controllers/ms/lpushx/snippets/lpushx.test.yml @@ -0,0 +1,13 @@ +name: ms#lpushx +description: Prepends the specified value to an existing list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - "\\[]" + - ^2$ + - "\\[ 'foo', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lrange/index.md b/doc/src/controllers/ms/lrange/index.md new file mode 100644 index 000000000..1997c0299 --- /dev/null +++ b/doc/src/controllers/ms/lrange/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: lrange +--- + +# lrange + +Returns the list elements between the `start` and `stop` positions. + +Offsets start at `0`, and the range is inclusive. + +[[_Redis documentation_]](https://redis.io/commands/lrange) + +## Arguments + +```js +lrange(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | -------------------------- | +| `key` |
string
| List key | +| `start` |
integer
| Starting index (inclusive) | +| `stop` |
integer
| Ending index (inclusive) | +| `options` |
object
| Optional query arguments | + +The `start` and `stop` arguments can be negative. In that case, the offset is calculated from the end of the list, going backward. For instance, -3 is the third element from the end of the list. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of list elements. + +## Usage + +<<< ./snippets/lrange.js diff --git a/doc/src/controllers/ms/lrange/snippets/lrange.js b/doc/src/controllers/ms/lrange/snippets/lrange.js new file mode 100644 index 000000000..f7b57bfe5 --- /dev/null +++ b/doc/src/controllers/ms/lrange/snippets/lrange.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + // Prints: [ 'b', 'c', 'd' ] + console.log(await kuzzle.ms.lrange('listfoo', 1, 3)); + + // Prints: [ d', 'e' ] + console.log(await kuzzle.ms.lrange('listfoo', 3, -2)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lrange/snippets/lrange.test.yml b/doc/src/controllers/ms/lrange/snippets/lrange.test.yml new file mode 100644 index 000000000..0c47e421a --- /dev/null +++ b/doc/src/controllers/ms/lrange/snippets/lrange.test.yml @@ -0,0 +1,11 @@ +name: ms#lrange +description: Returns the list elements between the start and stop positions +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ 'b', 'c', 'd' ]" + - "\\[ 'd', 'e' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lrem/index.md b/doc/src/controllers/ms/lrem/index.md new file mode 100644 index 000000000..87f7c3bc1 --- /dev/null +++ b/doc/src/controllers/ms/lrem/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: lrem +--- + +# lrem + +Removes the first occurences of an element from a list. + +[[_Redis documentation_]](https://redis.io/commands/lrem) + +## Arguments + +```js +lrem(key, count, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ---------------------------------------------- | +| `key` |
string
| List key | +| `count` |
integer
| Number of the first found occurences to remove | +| `value` |
string
| Value to remove | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed elements. + +## Usage + +<<< ./snippets/lrem.js diff --git a/doc/src/controllers/ms/lrem/snippets/lrem.js b/doc/src/controllers/ms/lrem/snippets/lrem.js new file mode 100644 index 000000000..0775173d5 --- /dev/null +++ b/doc/src/controllers/ms/lrem/snippets/lrem.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'foo', 'baz', 'foo']); + + // Prints: 2 + console.log(await kuzzle.ms.lrem('listfoo', 2, 'foo')); + + // Prints: [ 'bar', 'baz', 'foo' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lrem/snippets/lrem.test.yml b/doc/src/controllers/ms/lrem/snippets/lrem.test.yml new file mode 100644 index 000000000..dd43df76d --- /dev/null +++ b/doc/src/controllers/ms/lrem/snippets/lrem.test.yml @@ -0,0 +1,11 @@ +name: ms#lrem +description: Removes the first occurences of an element from a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - "\\[ 'bar', 'baz', 'foo' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/lset/index.md b/doc/src/controllers/ms/lset/index.md new file mode 100644 index 000000000..004a8281c --- /dev/null +++ b/doc/src/controllers/ms/lset/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: lset +--- + +# lset + +Sets the list element at `index` with the provided value. + +[[_Redis documentation_]](https://redis.io/commands/lset) + +## Arguments + +```js +lset(key, index, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ----------------------------------------------------------------------------------------------- | +| `key` |
string
| List key | +| `index` |
integer
| Index of the list (lists are 0-indexed). If negative, it goes backward from the end of the list | +| `value` |
string
| Value to set | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the new value is set. + +## Usage + +<<< ./snippets/lset.js diff --git a/doc/src/controllers/ms/lset/snippets/lset.js b/doc/src/controllers/ms/lset/snippets/lset.js new file mode 100644 index 000000000..1d8e24dad --- /dev/null +++ b/doc/src/controllers/ms/lset/snippets/lset.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.rpush('listfoo', ['qux', 'bar', 'baz']); + + await kuzzle.ms.lset('listfoo', 0, 'foo'); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/lset/snippets/lset.test.yml b/doc/src/controllers/ms/lset/snippets/lset.test.yml new file mode 100644 index 000000000..8102ca92f --- /dev/null +++ b/doc/src/controllers/ms/lset/snippets/lset.test.yml @@ -0,0 +1,9 @@ +name: ms#lset +description: Sets the list element at index with the provided value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo', 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/ltrim/index.md b/doc/src/controllers/ms/ltrim/index.md new file mode 100644 index 000000000..daee7ddb7 --- /dev/null +++ b/doc/src/controllers/ms/ltrim/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: ltrim +--- + +# ltrim + +Trims an existing list so that it will contain only the specified range of elements specified. + +[[_Redis documentation_]](https://redis.io/commands/ltrim) + +## Arguments + +```js +ltrim(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | -------------------------- | +| `key` |
string
| List key | +| `start` |
integer
| Starting index (inclusive) | +| `stop` |
integer
| Ending index (inclusive) | +| `options` |
object
| Optional query arguments | + +The `start` and `stop` arguments can be negative. In that case, the offset is calculated from the end of the list, going backward. For instance, -3 is the third element from the end of the list. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation is finished. + +## Usage + +<<< ./snippets/ltrim.js diff --git a/doc/src/controllers/ms/ltrim/snippets/ltrim.js b/doc/src/controllers/ms/ltrim/snippets/ltrim.js new file mode 100644 index 000000000..70ecb7d93 --- /dev/null +++ b/doc/src/controllers/ms/ltrim/snippets/ltrim.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.rpush('listfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + await kuzzle.ms.ltrim('listfoo', 3, -2); + + // Prints [ 'd', 'e' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/ltrim/snippets/ltrim.test.yml b/doc/src/controllers/ms/ltrim/snippets/ltrim.test.yml new file mode 100644 index 000000000..96629d68e --- /dev/null +++ b/doc/src/controllers/ms/ltrim/snippets/ltrim.test.yml @@ -0,0 +1,9 @@ +name: ms#ltrim +description: Trims an existing list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'd', 'e' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/mget/index.md b/doc/src/controllers/ms/mget/index.md new file mode 100644 index 000000000..99488fafa --- /dev/null +++ b/doc/src/controllers/ms/mget/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: mget +--- + +# mget + +Returns the values of the provided keys. + +[[_Redis documentation_]](https://redis.io/commands/mget) + +## Arguments + +```js +mget(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of keys to get | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of corresponding key values, in the same order than the one provided in the query. + +## Usage + +<<< ./snippets/mget.js diff --git a/doc/src/controllers/ms/mget/snippets/mget.js b/doc/src/controllers/ms/mget/snippets/mget.js new file mode 100644 index 000000000..46bfef49f --- /dev/null +++ b/doc/src/controllers/ms/mget/snippets/mget.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + await kuzzle.ms.set('hello', 'world'); + + // Prints: [ 'world', 'bar' ] + console.log(await kuzzle.ms.mget(['hello', 'foo'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/mget/snippets/mget.test.yml b/doc/src/controllers/ms/mget/snippets/mget.test.yml new file mode 100644 index 000000000..23195d61f --- /dev/null +++ b/doc/src/controllers/ms/mget/snippets/mget.test.yml @@ -0,0 +1,9 @@ +name: ms#mget +description: Returns the values of the provided keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'world', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/mset/index.md b/doc/src/controllers/ms/mset/index.md new file mode 100644 index 000000000..ddd5cf64f --- /dev/null +++ b/doc/src/controllers/ms/mset/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: mset +--- + +# mset + +Sets the provided keys to their respective values. If a key does not exist, it is created. Otherwise, the key's value is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/mset) + +## Arguments + +```js +mset(entries, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------ | +| `entries` |
object[]
| List of key-value pairs to set | +| `options` |
object
| Optional query arguments | + +### entries + +The `entries` argument is an array of objects. Each object is a key-value pair, defined with the following properties: + +| Property | Type | Description | +| -------- | ----------------- | ----------- | +| `key` |
string
| Key | +| `value` |
\*
| Value | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves successfully once the keys are set. + +## Usage + +<<< ./snippets/mset.js diff --git a/doc/src/controllers/ms/mset/snippets/mset.js b/doc/src/controllers/ms/mset/snippets/mset.js new file mode 100644 index 000000000..579c5a54f --- /dev/null +++ b/doc/src/controllers/ms/mset/snippets/mset.js @@ -0,0 +1,15 @@ +try { + // Prints: 0 + console.log(await kuzzle.ms.exists(['key1', 'key2', 'key3'])); + + await kuzzle.ms.mset([ + { key: 'key1', value: 'val1' }, + { key: 'key2', value: 'val2' }, + { key: 'key3', value: 'val3' } + ]); + + // Prints: 3 + console.log(await kuzzle.ms.exists(['key1', 'key2', 'key3'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/mset/snippets/mset.test.yml b/doc/src/controllers/ms/mset/snippets/mset.test.yml new file mode 100644 index 000000000..8effcbefc --- /dev/null +++ b/doc/src/controllers/ms/mset/snippets/mset.test.yml @@ -0,0 +1,11 @@ +name: ms#mset +description: Sets the provided keys to their respective values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^3$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/msetnx/index.md b/doc/src/controllers/ms/msetnx/index.md new file mode 100644 index 000000000..64cc99b2a --- /dev/null +++ b/doc/src/controllers/ms/msetnx/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: msetnx +--- + +# msetnx + +Sets the provided keys to their respective values, only if they do not exist. If a key exists, then the whole operation is aborted and no key is set. + +[[_Redis documentation_]](https://redis.io/commands/msetnx) + +## Arguments + +```js +msetnx(entries, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------ | +| `entries` |
object[]
| List of key-value pairs to set | +| `options` |
object
| Optional query arguments | + +### entries + +The `entries` argument is an array of objects. Each object is a key-value pair, defined with the following properties: + +| Property | Type | Description | +| -------- | ----------------- | ----------- | +| `key` |
string
| Key | +| `value` |
\*
| Value | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the keys have been set or not. + +## Usage + +<<< ./snippets/msetnx.js diff --git a/doc/src/controllers/ms/msetnx/snippets/msetnx.js b/doc/src/controllers/ms/msetnx/snippets/msetnx.js new file mode 100644 index 000000000..70a76ee8c --- /dev/null +++ b/doc/src/controllers/ms/msetnx/snippets/msetnx.js @@ -0,0 +1,19 @@ +const entries = [ + { key: 'hello', value: 'world' }, + { key: 'foo', value: 'bar' } +]; + +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: false + // (the entire operation aborted) + console.log(await kuzzle.ms.msetnx(entries)); + + await kuzzle.ms.del('foo'); + + // Prints: true + console.log(await kuzzle.ms.msetnx(entries)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/msetnx/snippets/msetnx.test.yml b/doc/src/controllers/ms/msetnx/snippets/msetnx.test.yml new file mode 100644 index 000000000..f73ac5b14 --- /dev/null +++ b/doc/src/controllers/ms/msetnx/snippets/msetnx.test.yml @@ -0,0 +1,11 @@ +name: ms#msetnx +description: Sets the provided keys to their respective values, only if they do not exist +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^false$ + - ^true$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/object/index.md b/doc/src/controllers/ms/object/index.md new file mode 100644 index 000000000..9c87e3bcc --- /dev/null +++ b/doc/src/controllers/ms/object/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: object +--- + +# object + +Inspects the low-level properties of a key. + +[[_Redis documentation_]](https://redis.io/commands/object) + +## Arguments + +```js +object(key, subcommand, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | ---------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `subcommand` |
string
| Object property to inspect.
Allowed values: `encoding`, `idletime`, `refcount` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the inspected property value. + +## Usage + +<<< ./snippets/object.js diff --git a/doc/src/controllers/ms/object/snippets/object.js b/doc/src/controllers/ms/object/snippets/object.js new file mode 100644 index 000000000..beef89a13 --- /dev/null +++ b/doc/src/controllers/ms/object/snippets/object.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.sadd('foo', ['bar', 'baz']); + + // Prints: hashtable + console.log(await kuzzle.ms.object('foo', 'encoding')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/object/snippets/object.test.yml b/doc/src/controllers/ms/object/snippets/object.test.yml new file mode 100644 index 000000000..ec96be4b7 --- /dev/null +++ b/doc/src/controllers/ms/object/snippets/object.test.yml @@ -0,0 +1,9 @@ +name: ms#object +description: Inspects the low-level properties of a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^hashtable$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/persist/index.md b/doc/src/controllers/ms/persist/index.md new file mode 100644 index 000000000..19963bcc9 --- /dev/null +++ b/doc/src/controllers/ms/persist/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: persist +--- + +# persist + +Removes the expiration delay or timestamp from a key, making it persistent. + +[[_Redis documentation_]](https://redis.io/commands/persist) + +## Arguments + +```js +persist(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the key is persisted. + +## Usage + +<<< ./snippets/persist.js diff --git a/doc/src/controllers/ms/persist/snippets/persist.js b/doc/src/controllers/ms/persist/snippets/persist.js new file mode 100644 index 000000000..aba174638 --- /dev/null +++ b/doc/src/controllers/ms/persist/snippets/persist.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.setex('foo', 'bar', 60); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); + + await kuzzle.ms.persist('foo'); + + // Prints: -1 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/persist/snippets/persist.test.yml b/doc/src/controllers/ms/persist/snippets/persist.test.yml new file mode 100644 index 000000000..5a3b014a3 --- /dev/null +++ b/doc/src/controllers/ms/persist/snippets/persist.test.yml @@ -0,0 +1,11 @@ +name: ms#persist +description: Removes the expiration delay or timestamp from a key, making it persistent +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^[0-9]+$ + - "-1" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/pexpire/index.md b/doc/src/controllers/ms/pexpire/index.md new file mode 100644 index 000000000..92a540532 --- /dev/null +++ b/doc/src/controllers/ms/pexpire/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: pexpire +--- + +# pexpire + +Sets a timeout (in milliseconds) on a key. After the timeout has expired, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/pexpire) + +## Arguments + +```js +pexpire(key, milliseconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| -------------- | ------------------ | ----------------------------------------------------- | +| `key` |
string
| Key | +| `milliseconds` |
integer
| Number of milliseconds after which the key is deleted | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean, telling whether the operation succeeded or not. + +## Usage + +<<< ./snippets/pexpire.js diff --git a/doc/src/controllers/ms/pexpire/snippets/pexpire.js b/doc/src/controllers/ms/pexpire/snippets/pexpire.js new file mode 100644 index 000000000..6cb30e4d7 --- /dev/null +++ b/doc/src/controllers/ms/pexpire/snippets/pexpire.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: -1 + console.log(await kuzzle.ms.ttl('foo')); + + await kuzzle.ms.pexpire('foo', 60000); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/pexpire/snippets/pexpire.test.yml b/doc/src/controllers/ms/pexpire/snippets/pexpire.test.yml new file mode 100644 index 000000000..caf2552ea --- /dev/null +++ b/doc/src/controllers/ms/pexpire/snippets/pexpire.test.yml @@ -0,0 +1,11 @@ +name: ms#pexpire +description: Sets a timeout (in milliseconds) on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^-1$ + - ^[0-9]{1,2}$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/pexpireat/index.md b/doc/src/controllers/ms/pexpireat/index.md new file mode 100644 index 000000000..ff31c6941 --- /dev/null +++ b/doc/src/controllers/ms/pexpireat/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: pexpireat +--- + +# pexpireat + +Sets an expiration timestamp (in Epoch-milis) on a key. After the timestamp has been reached, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/pexpireat) + +## Arguments + +```js +pexpireat(key, timestamp, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ----------------------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `timestamp` |
integer
| Expiration timestamp ([Epoch](https://en.wikipedia.org/wiki/Unix_time) format, in milliseconds) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation was successful or not. + +## Usage + +<<< ./snippets/pexpireat.js diff --git a/doc/src/controllers/ms/pexpireat/snippets/pexpireat.js b/doc/src/controllers/ms/pexpireat/snippets/pexpireat.js new file mode 100644 index 000000000..3a40c7fec --- /dev/null +++ b/doc/src/controllers/ms/pexpireat/snippets/pexpireat.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + // Oct. 12, 2011 + await kuzzle.ms.pexpireat('foo', 1318425955000); + + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/pexpireat/snippets/pexpireat.test.yml b/doc/src/controllers/ms/pexpireat/snippets/pexpireat.test.yml new file mode 100644 index 000000000..d2f23f5e8 --- /dev/null +++ b/doc/src/controllers/ms/pexpireat/snippets/pexpireat.test.yml @@ -0,0 +1,11 @@ +name: ms#pexpireat +description: Sets an expiration timestamp on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^1$ + - ^0$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/pfadd/index.md b/doc/src/controllers/ms/pfadd/index.md new file mode 100644 index 000000000..32bc0b613 --- /dev/null +++ b/doc/src/controllers/ms/pfadd/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: pfadd +--- + +# pfadd + +Adds elements to a [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure. + +[[_Redis documentation_]](https://redis.io/commands/pfadd) + +## Arguments + +```js +pfadd(key, elements, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| HyperLogLog key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Returns a boolean telling whether the addition altered the HyperLogLog structure or not. + +## Usage + +<<< ./snippets/pfadd.js diff --git a/doc/src/controllers/ms/pfadd/snippets/pfadd.js b/doc/src/controllers/ms/pfadd/snippets/pfadd.js new file mode 100644 index 000000000..26c01e1bb --- /dev/null +++ b/doc/src/controllers/ms/pfadd/snippets/pfadd.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.pfadd('hllfoo', ['foo', 'bar', 'baz', 'qux']); + + // Prints: 4 + console.log(await kuzzle.ms.pfcount('hllfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/pfadd/snippets/pfadd.test.yml b/doc/src/controllers/ms/pfadd/snippets/pfadd.test.yml new file mode 100644 index 000000000..a471b2507 --- /dev/null +++ b/doc/src/controllers/ms/pfadd/snippets/pfadd.test.yml @@ -0,0 +1,9 @@ +name: ms#pfadd +description: Adds elements to a HyperLogLog data structure +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^4$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/pfcount/index.md b/doc/src/controllers/ms/pfcount/index.md new file mode 100644 index 000000000..e6e8245eb --- /dev/null +++ b/doc/src/controllers/ms/pfcount/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: pfcount +--- + +# pfcount + +Returns the probabilistic cardinality of a [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure, or of the merged HyperLogLog structures if more than 1 is provided (see [pfadd](/sdk/js/6/controllers/ms/pfadd)). + +[[_Redis documentation_]](https://redis.io/commands/pfcount) + +## Arguments + +```js +pfcount(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of HyperLogLog keys | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the merged HyperLogLog structures cardinality. + +## Usage + +<<< ./snippets/pfcount.js diff --git a/doc/src/controllers/ms/pfcount/snippets/pfcount.js b/doc/src/controllers/ms/pfcount/snippets/pfcount.js new file mode 100644 index 000000000..53871f22e --- /dev/null +++ b/doc/src/controllers/ms/pfcount/snippets/pfcount.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.pfadd('hllfoo', ['foo', 'bar', 'baz']); + await kuzzle.ms.pfadd('hllfoo2', ['hello', 'world', 'foo']); + + // Prints: 5 + console.log(await kuzzle.ms.pfcount(['hllfoo', 'hllfoo2'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/pfcount/snippets/pfcount.test.yml b/doc/src/controllers/ms/pfcount/snippets/pfcount.test.yml new file mode 100644 index 000000000..e172ba101 --- /dev/null +++ b/doc/src/controllers/ms/pfcount/snippets/pfcount.test.yml @@ -0,0 +1,9 @@ +name: ms#pfcount +description: Returns the probabilistic cardinality of a HyperLogLog data structure +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^5$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/pfmerge/index.md b/doc/src/controllers/ms/pfmerge/index.md new file mode 100644 index 000000000..ed883f3f0 --- /dev/null +++ b/doc/src/controllers/ms/pfmerge/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: pfmerge +--- + +# pfmerge + +Merges multiple [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structures into an unique HyperLogLog structure, approximating the cardinality of the union of the source structures. + +[[_Redis documentation_]](https://redis.io/commands/pfmerge) + +## Arguments + +```js +pfmerge(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | --------------------------------- | +| `dest` |
string
| Destination key | +| `sources` |
string[]
| List of HyperLogLog keys to merge | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/pfmerge.js diff --git a/doc/src/controllers/ms/pfmerge/snippets/pfmerge.js b/doc/src/controllers/ms/pfmerge/snippets/pfmerge.js new file mode 100644 index 000000000..3e186cba6 --- /dev/null +++ b/doc/src/controllers/ms/pfmerge/snippets/pfmerge.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.pfadd('hllfoo', ['foo', 'bar', 'baz']); + await kuzzle.ms.pfadd('hllfoo2', ['hello', 'world', 'foo']); + + await kuzzle.ms.pfmerge('hllmerged', ['hllfoo', 'hllfoo2']); + + // Prints: 5 + console.log(await kuzzle.ms.pfcount(['hllmerged'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/pfmerge/snippets/pfmerge.test.yml b/doc/src/controllers/ms/pfmerge/snippets/pfmerge.test.yml new file mode 100644 index 000000000..aa7772bda --- /dev/null +++ b/doc/src/controllers/ms/pfmerge/snippets/pfmerge.test.yml @@ -0,0 +1,9 @@ +name: ms#pfmerge +description: Merges multiple HyperLogLog data structures +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^5$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/ping/index.md b/doc/src/controllers/ms/ping/index.md new file mode 100644 index 000000000..fb757401c --- /dev/null +++ b/doc/src/controllers/ms/ping/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: ping +--- + +# ping + +Pings the memory storage database. + +[[_Redis documentation_]](https://redis.io/commands/ping) + +## Arguments + +```js +ping([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the string `PONG`. + +## Usage + +<<< ./snippets/ping.js diff --git a/doc/src/controllers/ms/ping/snippets/ping.js b/doc/src/controllers/ms/ping/snippets/ping.js new file mode 100644 index 000000000..0290c406a --- /dev/null +++ b/doc/src/controllers/ms/ping/snippets/ping.js @@ -0,0 +1,6 @@ +try { + // Prints: PONG + console.log(await kuzzle.ms.ping()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/ping/snippets/ping.test.yml b/doc/src/controllers/ms/ping/snippets/ping.test.yml new file mode 100644 index 000000000..2de8803ee --- /dev/null +++ b/doc/src/controllers/ms/ping/snippets/ping.test.yml @@ -0,0 +1,9 @@ +name: ms#ping +description: Pings the memory storage database +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^PONG$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/psetex/index.md b/doc/src/controllers/ms/psetex/index.md new file mode 100644 index 000000000..587999708 --- /dev/null +++ b/doc/src/controllers/ms/psetex/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: psetex +--- + +# psetex + +Sets a key with the provided value, and an expiration delay expressed in milliseconds. If the key does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/psetex) + +## Arguments + +```js +psetex(key, value, milliseconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| -------------- | ------------------ | ----------------------------------------------------- | +| `key` |
string
| Key | +| `value` |
string
| Value | +| `milliseconds` |
integer
| Number of milliseconds after which the key is deleted | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/psetex.js diff --git a/doc/src/controllers/ms/psetex/snippets/psetex.js b/doc/src/controllers/ms/psetex/snippets/psetex.js new file mode 100644 index 000000000..f23cc7ffc --- /dev/null +++ b/doc/src/controllers/ms/psetex/snippets/psetex.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.psetex('foo', 'bar', 60000); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/psetex/snippets/psetex.test.yml b/doc/src/controllers/ms/psetex/snippets/psetex.test.yml new file mode 100644 index 000000000..e18aafc99 --- /dev/null +++ b/doc/src/controllers/ms/psetex/snippets/psetex.test.yml @@ -0,0 +1,11 @@ +name: ms#psetex +description: Sets a key with the provided value, and an expiration delay expressed in milliseconds +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^[0-9]{1,2}$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/pttl/index.md b/doc/src/controllers/ms/pttl/index.md new file mode 100644 index 000000000..477790477 --- /dev/null +++ b/doc/src/controllers/ms/pttl/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: pttl +--- + +# pttl + +Returns the remaining time to live of a key, in milliseconds. + +[[_Redis documentation_]](https://redis.io/commands/pttl) + +## Arguments + +```js +pttl(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the remaining TTL, in milliseconds. + +## Usage + +<<< ./snippets/pttl.js diff --git a/doc/src/controllers/ms/pttl/snippets/pttl.js b/doc/src/controllers/ms/pttl/snippets/pttl.js new file mode 100644 index 000000000..acec88d99 --- /dev/null +++ b/doc/src/controllers/ms/pttl/snippets/pttl.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.psetex('foo', 'bar', 60000); + + // Prints: 60000 + console.log(await kuzzle.ms.pttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/pttl/snippets/pttl.test.yml b/doc/src/controllers/ms/pttl/snippets/pttl.test.yml new file mode 100644 index 000000000..f7881e2fd --- /dev/null +++ b/doc/src/controllers/ms/pttl/snippets/pttl.test.yml @@ -0,0 +1,9 @@ +name: ms#pttl +description: Returns the remaining time to live of a key, in milliseconds +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^[0-9]+$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/randomkey/index.md b/doc/src/controllers/ms/randomkey/index.md new file mode 100644 index 000000000..b3eea2ef2 --- /dev/null +++ b/doc/src/controllers/ms/randomkey/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: randomkey +--- + +# randomkey + +Returns a key identifier from the memory storage, at random. + +[[_Redis documentation_]](https://redis.io/commands/randomkey) + +## Arguments + +```js +randomkey([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a key identifier, at random. + +## Usage + +<<< ./snippets/randomkey.js diff --git a/doc/src/controllers/ms/randomkey/snippets/randomkey.js b/doc/src/controllers/ms/randomkey/snippets/randomkey.js new file mode 100644 index 000000000..4be04bc03 --- /dev/null +++ b/doc/src/controllers/ms/randomkey/snippets/randomkey.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('foo', 'val'); + await kuzzle.ms.set('bar', 'val'); + await kuzzle.ms.set('baz', 'val'); + + // Prints one of the following: foo, bar or baz + console.log(await kuzzle.ms.randomkey()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/randomkey/snippets/randomkey.test.yml b/doc/src/controllers/ms/randomkey/snippets/randomkey.test.yml new file mode 100644 index 000000000..93c2f889c --- /dev/null +++ b/doc/src/controllers/ms/randomkey/snippets/randomkey.test.yml @@ -0,0 +1,9 @@ +name: ms#randomkey +description: Returns a key identifier from the memory storage, at random +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^(foo|bar|baz)$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/rename/index.md b/doc/src/controllers/ms/rename/index.md new file mode 100644 index 000000000..abff9ad35 --- /dev/null +++ b/doc/src/controllers/ms/rename/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: rename +--- + +# rename + +Renames a key. + +If the new key name is already used, then it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/rename) + +## Arguments + +```js +rename(src, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Key to rename | +| `dest` |
string
| New key name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/rename.js diff --git a/doc/src/controllers/ms/rename/snippets/rename.js b/doc/src/controllers/ms/rename/snippets/rename.js new file mode 100644 index 000000000..d5da37409 --- /dev/null +++ b/doc/src/controllers/ms/rename/snippets/rename.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('foo', 'World'); + + await kuzzle.ms.rename('foo', 'Hello'); + + // Prints: World + console.log(await kuzzle.ms.get('Hello')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/rename/snippets/rename.test.yml b/doc/src/controllers/ms/rename/snippets/rename.test.yml new file mode 100644 index 000000000..e11268290 --- /dev/null +++ b/doc/src/controllers/ms/rename/snippets/rename.test.yml @@ -0,0 +1,9 @@ +name: ms#rename +description: Renames a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^World$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/renamenx/index.md b/doc/src/controllers/ms/renamenx/index.md new file mode 100644 index 000000000..48edab3a6 --- /dev/null +++ b/doc/src/controllers/ms/renamenx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: renamenx +--- + +# renamenx + +Renames a key, only if the new name is not already used. + +[[_Redis documentation_]](https://redis.io/commands/renamenx) + +## Arguments + +```js +renamenx(src, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Key to rename | +| `dest` |
string
| New key name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation succeeded or not. + +## Usage + +<<< ./snippets/renamenx.js diff --git a/doc/src/controllers/ms/renamenx/snippets/renamenx.js b/doc/src/controllers/ms/renamenx/snippets/renamenx.js new file mode 100644 index 000000000..f0e9cf95e --- /dev/null +++ b/doc/src/controllers/ms/renamenx/snippets/renamenx.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.set('foo', 'val'); + await kuzzle.ms.set('bar', 'val'); + + // Prints: false + // (the key "bar" already exists) + console.log(await kuzzle.ms.renamenx('foo', 'bar')); + + // Prints: true + console.log(await kuzzle.ms.renamenx('foo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/renamenx/snippets/renamenx.test.yml b/doc/src/controllers/ms/renamenx/snippets/renamenx.test.yml new file mode 100644 index 000000000..737877950 --- /dev/null +++ b/doc/src/controllers/ms/renamenx/snippets/renamenx.test.yml @@ -0,0 +1,11 @@ +name: ms#renamenx +description: Renames a key, only if the new name is not already used +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^false$ + - ^true$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/rpop/index.md b/doc/src/controllers/ms/rpop/index.md new file mode 100644 index 000000000..fb8f554ad --- /dev/null +++ b/doc/src/controllers/ms/rpop/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: rpop +--- + +# rpop + +Removes the last element of a list and returns it. + +[[_Redis documentation_]](https://redis.io/commands/rpop) + +## Arguments + +```js +rpop(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the removed element. + +## Usage + +<<< ./snippets/rpop.js diff --git a/doc/src/controllers/ms/rpop/snippets/rpop.js b/doc/src/controllers/ms/rpop/snippets/rpop.js new file mode 100644 index 000000000..906b67e2c --- /dev/null +++ b/doc/src/controllers/ms/rpop/snippets/rpop.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: 'baz' + console.log(await kuzzle.ms.rpop('listfoo')); + + // Prints: [ 'foo', 'bar' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/rpop/snippets/rpop.test.yml b/doc/src/controllers/ms/rpop/snippets/rpop.test.yml new file mode 100644 index 000000000..77caeb66e --- /dev/null +++ b/doc/src/controllers/ms/rpop/snippets/rpop.test.yml @@ -0,0 +1,11 @@ +name: ms#rpop +description: Removes the last element of a list and returns it +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^baz$ + - "\\[ 'foo', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/rpoplpush/index.md b/doc/src/controllers/ms/rpoplpush/index.md new file mode 100644 index 000000000..a46882b6e --- /dev/null +++ b/doc/src/controllers/ms/rpoplpush/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: rpoplpush +--- + +# rpoplpush + +Removes the last element of a list, and pushes it back at the start of another list. + +[[_Redis documentation_]](https://redis.io/commands/rpoplpush) + +## Arguments + +```js +rpoplpush(src, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Source key | +| `dest` |
string
| Destination key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the value of the moved element. + +## Usage + +<<< ./snippets/rpoplpush.js diff --git a/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.js b/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.js new file mode 100644 index 000000000..b5ed73dca --- /dev/null +++ b/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.rpush('foo', ['rick', 'astley', 'never']); + await kuzzle.ms.rpush('bar', ['gonna', 'give', 'you', 'up']); + + // Prints: never + console.log(await kuzzle.ms.rpoplpush('foo', 'bar')); + + // Prints: [ 'never', 'gonna', 'give', 'you', 'up' ] + console.log(await kuzzle.ms.lrange('bar', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml b/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml new file mode 100644 index 000000000..b41b74666 --- /dev/null +++ b/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml @@ -0,0 +1,11 @@ +name: ms#rpoplpush +description: Removes the last element of a list, and pushes it back at the start of another list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^never$ + - "\\[ 'never', 'gonna', 'give', 'you', 'up' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/rpush/index.md b/doc/src/controllers/ms/rpush/index.md new file mode 100644 index 000000000..becc1860e --- /dev/null +++ b/doc/src/controllers/ms/rpush/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: rpush +--- + +# rpush + +Appends values at the end of a list. + +If the destination list does not exist, it is created holding an empty list before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/rpush) + +## Arguments + +```js +rpush(key, values, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| List key | +| `values` |
string[]
| List of values to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated list length. + +## Usage + +<<< ./snippets/rpush.js diff --git a/doc/src/controllers/ms/rpush/snippets/rpush.js b/doc/src/controllers/ms/rpush/snippets/rpush.js new file mode 100644 index 000000000..d6cd12b16 --- /dev/null +++ b/doc/src/controllers/ms/rpush/snippets/rpush.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/rpush/snippets/rpush.test.yml b/doc/src/controllers/ms/rpush/snippets/rpush.test.yml new file mode 100644 index 000000000..d68827600 --- /dev/null +++ b/doc/src/controllers/ms/rpush/snippets/rpush.test.yml @@ -0,0 +1,9 @@ +name: ms#rpush +description: Appends values at the end of a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo', 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/rpushx/index.md b/doc/src/controllers/ms/rpushx/index.md new file mode 100644 index 000000000..f9604b8c1 --- /dev/null +++ b/doc/src/controllers/ms/rpushx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: rpushx +--- + +# rpushx + +Appends a value at the end of a list, only if the destination key already exists, and if it holds a list. + +[[_Redis documentation_]](https://redis.io/commands/rpushx) + +## Arguments + +```js +rpushx(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `value` |
string
| Value to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated list length. + +## Usage + +<<< ./snippets/rpushx.js diff --git a/doc/src/controllers/ms/rpushx/snippets/rpushx.js b/doc/src/controllers/ms/rpushx/snippets/rpushx.js new file mode 100644 index 000000000..00875bb69 --- /dev/null +++ b/doc/src/controllers/ms/rpushx/snippets/rpushx.js @@ -0,0 +1,12 @@ +try { + // Prints: 0 + // ("listfoo" does not exist: the operation fails) + console.log(await kuzzle.ms.rpushx('listfoo', 'qux')); + + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: 4 + console.log(await kuzzle.ms.rpushx('listfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/rpushx/snippets/rpushx.test.yml b/doc/src/controllers/ms/rpushx/snippets/rpushx.test.yml new file mode 100644 index 000000000..af30e7bb7 --- /dev/null +++ b/doc/src/controllers/ms/rpushx/snippets/rpushx.test.yml @@ -0,0 +1,11 @@ +name: ms#rpushx +description: Appends a value at the end of an existing list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^4$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sadd/index.md b/doc/src/controllers/ms/sadd/index.md new file mode 100644 index 000000000..cf3f528d0 --- /dev/null +++ b/doc/src/controllers/ms/sadd/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: sadd +--- + +# sadd + +Adds members to a set of unique values stored at `key`. + +If the destination set does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/sadd) + +## Arguments + +```js +sadd(key, values, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Set key | +| `values` |
string[]
| Values to add | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of successfully added members. + +## Usage + +<<< ./snippets/sadd.js diff --git a/doc/src/controllers/ms/sadd/snippets/sadd.js b/doc/src/controllers/ms/sadd/snippets/sadd.js new file mode 100644 index 000000000..0af225de5 --- /dev/null +++ b/doc/src/controllers/ms/sadd/snippets/sadd.js @@ -0,0 +1,12 @@ +try { + // Prints: 2 + console.log(await kuzzle.ms.sadd('setfoo', ['foo', 'bar'])); + + // Prints: 1 + console.log(await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz'])); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.smembers('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sadd/snippets/sadd.test.yml b/doc/src/controllers/ms/sadd/snippets/sadd.test.yml new file mode 100644 index 000000000..a66e0e5d4 --- /dev/null +++ b/doc/src/controllers/ms/sadd/snippets/sadd.test.yml @@ -0,0 +1,12 @@ +name: ms#sadd +description: Adds members to a set of unique values stored at key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - ^1$ + - "\\[ '(foo|bar|baz)', '(foo|bar|baz)', '(foo|bar|baz)' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/scan/index.md b/doc/src/controllers/ms/scan/index.md new file mode 100644 index 000000000..9ba928872 --- /dev/null +++ b/doc/src/controllers/ms/scan/index.md @@ -0,0 +1,52 @@ +--- +code: true +type: page +title: scan +--- + +# scan + +Iterates incrementally over the set of keys in the database using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/scan) + +## Arguments + +```js +scan(cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | ----------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of keys | + +## Usage + +<<< ./snippets/scan.js diff --git a/doc/src/controllers/ms/scan/snippets/scan.js b/doc/src/controllers/ms/scan/snippets/scan.js new file mode 100644 index 000000000..1eb7f8c56 --- /dev/null +++ b/doc/src/controllers/ms/scan/snippets/scan.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.set('key1', 'val1'); + await kuzzle.ms.set('key2', 'val2'); + await kuzzle.ms.set('key3', 'val3'); + + // Prints: + // { + // cursor: '0', + // values: [ 'key1', 'key2', 'key3' ] + // } + console.log(await kuzzle.ms.scan(0)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/scan/snippets/scan.test.yml b/doc/src/controllers/ms/scan/snippets/scan.test.yml new file mode 100644 index 000000000..94f14acf7 --- /dev/null +++ b/doc/src/controllers/ms/scan/snippets/scan.test.yml @@ -0,0 +1,11 @@ +name: ms#scan +description: Iterates incrementally over the set of keys in the database using a cursor +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0', values: \\[ 'key[123]', 'key[123]', 'key[123]' ] }" + +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/scard/index.md b/doc/src/controllers/ms/scard/index.md new file mode 100644 index 000000000..f7b7aca95 --- /dev/null +++ b/doc/src/controllers/ms/scard/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: scard +--- + +# scard + +Returns the number of members stored in a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/scard) + +## Arguments + +```js +scard(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the set length. + +## Usage + +<<< ./snippets/scard.js diff --git a/doc/src/controllers/ms/scard/snippets/scard.js b/doc/src/controllers/ms/scard/snippets/scard.js new file mode 100644 index 000000000..66850ad3e --- /dev/null +++ b/doc/src/controllers/ms/scard/snippets/scard.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'foo', 'bar', 'baz']); + + // Prints: 3 + console.log(await kuzzle.ms.scard('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/scard/snippets/scard.test.yml b/doc/src/controllers/ms/scard/snippets/scard.test.yml new file mode 100644 index 000000000..233e97519 --- /dev/null +++ b/doc/src/controllers/ms/scard/snippets/scard.test.yml @@ -0,0 +1,9 @@ +name: ms#scard +description: Returns the number of members stored in a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sdiff/index.md b/doc/src/controllers/ms/sdiff/index.md new file mode 100644 index 000000000..06f361efe --- /dev/null +++ b/doc/src/controllers/ms/sdiff/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: sdiff +--- + +# sdiff + +Returns the difference between a reference set and a list of other sets. + +[[_Redis documentation_]](https://redis.io/commands/sdiff) + +## Arguments + +```js +sdiff(ref, sets, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ---------------------------------------- | +| `ref` |
string
| Set key of reference | +| `sets` |
string[]
| List of sets to compare to the reference | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of differences. + +## Usage + +<<< ./snippets/sdiff.js diff --git a/doc/src/controllers/ms/sdiff/snippets/sdiff.js b/doc/src/controllers/ms/sdiff/snippets/sdiff.js new file mode 100644 index 000000000..81554c2b2 --- /dev/null +++ b/doc/src/controllers/ms/sdiff/snippets/sdiff.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.sadd('ref', ['foo', 'bar', 'baz']); + + await kuzzle.ms.sadd('set1', ['foo', 'hello']); + await kuzzle.ms.sadd('set2', ['bar', 'world']); + + // Prints: [ 'baz' ] + console.log(await kuzzle.ms.sdiff('ref', ['set1', 'set2'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sdiff/snippets/sdiff.test.yml b/doc/src/controllers/ms/sdiff/snippets/sdiff.test.yml new file mode 100644 index 000000000..f828fae8b --- /dev/null +++ b/doc/src/controllers/ms/sdiff/snippets/sdiff.test.yml @@ -0,0 +1,9 @@ +name: ms#sdiff +description: Returns the difference between a reference set and a list of other sets +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sdiffstore/index.md b/doc/src/controllers/ms/sdiffstore/index.md new file mode 100644 index 000000000..5fb7807b3 --- /dev/null +++ b/doc/src/controllers/ms/sdiffstore/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: sdiffstore +--- + +# sdiffstore + +Computes the difference between a reference set of unique values, and other sets. The differences are then stored in the provided destination key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sdiffstore) + +## Arguments + +```js +sdiffstore(ref, sets, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ---------------------------------------- | +| `ref` |
string
| Set key of reference | +| `sets` |
string[]
| List of sets to compare to the reference | +| `dest` |
string
| Destination key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of values stored at the new key. + +## Usage + +<<< ./snippets/sdiffstore.js diff --git a/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.js b/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.js new file mode 100644 index 000000000..cffbb2826 --- /dev/null +++ b/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.sadd('ref', ['foo', 'bar', 'baz']); + + await kuzzle.ms.sadd('set1', ['foo', 'hello']); + await kuzzle.ms.sadd('set2', ['bar', 'world']); + + await kuzzle.ms.sdiffstore('ref', ['set1', 'set2'], 'diffs'); + + // Prints: [ 'baz' ] + console.log(await kuzzle.ms.smembers('diffs')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml b/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml new file mode 100644 index 000000000..fdbc89b7f --- /dev/null +++ b/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml @@ -0,0 +1,9 @@ +name: ms#sdiffstore +description: Stores the difference between a reference set and a list of other sets in a new key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/set/index.md b/doc/src/controllers/ms/set/index.md new file mode 100644 index 000000000..35300d86b --- /dev/null +++ b/doc/src/controllers/ms/set/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: set +--- + +# set + +Creates a key holding the provided value, or overwrites it if it already exists. + +[[_Redis documentation_]](https://redis.io/commands/set) + +## Arguments + +```js +set(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
\*
| Value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | -------------------------- | ---------------------------------------------------------------------------- | +| `ex` |
integer
| Adds an expiration delay to the key, in seconds | +| `nx` |
boolean (false)
| If true, do not set the key if it already exists | +| `px` |
integer
| Adds an expiration delay to the key, in milliseconds | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `xx` |
boolean (false)
| If true, sets the key only if it already exists | + +Note: the `ex` and `px` options are mutually exclusive; setting both options ends up in a `BadRequestError` error. Same thing goes for `nx` and `xx`. + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/set.js diff --git a/doc/src/controllers/ms/set/snippets/set.js b/doc/src/controllers/ms/set/snippets/set.js new file mode 100644 index 000000000..3f26ee695 --- /dev/null +++ b/doc/src/controllers/ms/set/snippets/set.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/set/snippets/set.test.yml b/doc/src/controllers/ms/set/snippets/set.test.yml new file mode 100644 index 000000000..48ccb56e6 --- /dev/null +++ b/doc/src/controllers/ms/set/snippets/set.test.yml @@ -0,0 +1,9 @@ +name: ms#set +description: Creates a key holding the provided value, or overwrites it if it already exists +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/setex/index.md b/doc/src/controllers/ms/setex/index.md new file mode 100644 index 000000000..239c83543 --- /dev/null +++ b/doc/src/controllers/ms/setex/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: setex +--- + +# setex + +Sets a value and a time to live (in seconds) on a key. If the key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/setex) + +## Arguments + +```js +setex(key, value, seconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------------------------------ | +| `key` |
string
| Key | +| `value` |
string
| Value | +| `seconds` |
integer
| Number of seconds after which the key is deleted | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/setex.js diff --git a/doc/src/controllers/ms/setex/snippets/setex.js b/doc/src/controllers/ms/setex/snippets/setex.js new file mode 100644 index 000000000..a51b2eedc --- /dev/null +++ b/doc/src/controllers/ms/setex/snippets/setex.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.setex('foo', 'bar', 60); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/setex/snippets/setex.test.yml b/doc/src/controllers/ms/setex/snippets/setex.test.yml new file mode 100644 index 000000000..2e27369b8 --- /dev/null +++ b/doc/src/controllers/ms/setex/snippets/setex.test.yml @@ -0,0 +1,11 @@ +name: ms#setex +description: Sets a value and a time to live (in seconds) on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^[0-9]{1,2}$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/setnx/index.md b/doc/src/controllers/ms/setnx/index.md new file mode 100644 index 000000000..d1babbb69 --- /dev/null +++ b/doc/src/controllers/ms/setnx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: setnx +--- + +# setnx + +Sets a value on a key, only if it does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/setnx) + +## Arguments + +```js +setnx(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
string
| Value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling if the operation succeeded or not. + +## Usage + +<<< ./snippets/setnx.js diff --git a/doc/src/controllers/ms/setnx/snippets/setnx.js b/doc/src/controllers/ms/setnx/snippets/setnx.js new file mode 100644 index 000000000..62128914b --- /dev/null +++ b/doc/src/controllers/ms/setnx/snippets/setnx.js @@ -0,0 +1,12 @@ +try { + // Prints: true + console.log(await kuzzle.ms.setnx('foo', 'bar')); + + // Prints: false + console.log(await kuzzle.ms.setnx('foo', 'qux')); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/setnx/snippets/setnx.test.yml b/doc/src/controllers/ms/setnx/snippets/setnx.test.yml new file mode 100644 index 000000000..7611aab3b --- /dev/null +++ b/doc/src/controllers/ms/setnx/snippets/setnx.test.yml @@ -0,0 +1,12 @@ +name: ms#setnx +description: Sets a value on a key, only if it does not already exist +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^true$ + - ^false$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sinter/index.md b/doc/src/controllers/ms/sinter/index.md new file mode 100644 index 000000000..5c439a2f1 --- /dev/null +++ b/doc/src/controllers/ms/sinter/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: sinter +--- + +# sinter + +Returns the intersection of the provided sets of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sinter) + +## Arguments + +```js +sinter(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ----------------------------- | +| `keys` |
string[]
| List of set keys to intersect | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of intersected values. + +## Usage + +<<< ./snippets/sinter.js diff --git a/doc/src/controllers/ms/sinter/snippets/sinter.js b/doc/src/controllers/ms/sinter/snippets/sinter.js new file mode 100644 index 000000000..a6e4edaa2 --- /dev/null +++ b/doc/src/controllers/ms/sinter/snippets/sinter.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.sadd('set1', ['foo', 'bar', 'hello']); + await kuzzle.ms.sadd('set2', ['world', 'baz', 'foo']); + + // Prints: [ 'foo' ] + console.log(await kuzzle.ms.sinter(['set1', 'set2'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sinter/snippets/sinter.test.yml b/doc/src/controllers/ms/sinter/snippets/sinter.test.yml new file mode 100644 index 000000000..f1cda41f4 --- /dev/null +++ b/doc/src/controllers/ms/sinter/snippets/sinter.test.yml @@ -0,0 +1,9 @@ +name: ms#sinter +description: Returns the intersection of the provided sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sinterstore/index.md b/doc/src/controllers/ms/sinterstore/index.md new file mode 100644 index 000000000..1299b6d77 --- /dev/null +++ b/doc/src/controllers/ms/sinterstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: sinterstore +--- + +# sinterstore + +Computes the intersection of the provided sets of unique values, and stores the result in a destination key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sinterstore) + +## Arguments + +```js +sinterstore(dest, keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ----------------------------- | +| `dest` |
string
| Destination key | +| `keys` |
string[]
| List of set keys to intersect | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of stored values. + +## Usage + +<<< ./snippets/sinterstore.js diff --git a/doc/src/controllers/ms/sinterstore/snippets/sinterstore.js b/doc/src/controllers/ms/sinterstore/snippets/sinterstore.js new file mode 100644 index 000000000..ddd7da447 --- /dev/null +++ b/doc/src/controllers/ms/sinterstore/snippets/sinterstore.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.sadd('set1', ['foo', 'bar', 'hello']); + await kuzzle.ms.sadd('set2', ['world', 'baz', 'foo']); + + // Prints: 1 + console.log(await kuzzle.ms.sinterstore('dest', ['set1', 'set2'])); + + // Prints: [ 'foo' ] + console.log(await kuzzle.ms.smembers('dest')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sinterstore/snippets/sinterstore.test.yml b/doc/src/controllers/ms/sinterstore/snippets/sinterstore.test.yml new file mode 100644 index 000000000..6563fb0ab --- /dev/null +++ b/doc/src/controllers/ms/sinterstore/snippets/sinterstore.test.yml @@ -0,0 +1,11 @@ +name: ms#sinterstore +description: Stores the intersection of the provided sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^1$ + - "\\[ 'foo' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sismember/index.md b/doc/src/controllers/ms/sismember/index.md new file mode 100644 index 000000000..dee827912 --- /dev/null +++ b/doc/src/controllers/ms/sismember/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: sismember +--- + +# sismember + +Checks if a value is a member of a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sismember) + +## Arguments + +```js +sismember(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `value` |
string
| Value to check | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling if the value is in the set or not. + +## Usage + +<<< ./snippets/sismember.js diff --git a/doc/src/controllers/ms/sismember/snippets/sismember.js b/doc/src/controllers/ms/sismember/snippets/sismember.js new file mode 100644 index 000000000..4ff009cc3 --- /dev/null +++ b/doc/src/controllers/ms/sismember/snippets/sismember.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: true + console.log(await kuzzle.ms.sismember('setfoo', 'bar')); + + // Prints: false + console.log(await kuzzle.ms.sismember('setfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sismember/snippets/sismember.test.yml b/doc/src/controllers/ms/sismember/snippets/sismember.test.yml new file mode 100644 index 000000000..944f3a6cc --- /dev/null +++ b/doc/src/controllers/ms/sismember/snippets/sismember.test.yml @@ -0,0 +1,11 @@ +name: ms#sismember +description: Checks if a value is a member of a set of unique values. +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^true$ + - ^false$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/smembers/index.md b/doc/src/controllers/ms/smembers/index.md new file mode 100644 index 000000000..d1273c0d0 --- /dev/null +++ b/doc/src/controllers/ms/smembers/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: smembers +--- + +# smembers + +Returns the members of a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/smembers) + +## Arguments + +```js +smembers(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of the set's members. + +## Usage + +<<< ./snippets/smembers.js diff --git a/doc/src/controllers/ms/smembers/snippets/smembers.js b/doc/src/controllers/ms/smembers/snippets/smembers.js new file mode 100644 index 000000000..1f94a3f2d --- /dev/null +++ b/doc/src/controllers/ms/smembers/snippets/smembers.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.sadd('listfoo', ['foo', 'bar', 'baz']); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.smembers('listfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/smembers/snippets/smembers.test.yml b/doc/src/controllers/ms/smembers/snippets/smembers.test.yml new file mode 100644 index 000000000..5c4cae961 --- /dev/null +++ b/doc/src/controllers/ms/smembers/snippets/smembers.test.yml @@ -0,0 +1,9 @@ +name: ms#smembers +description: Returns the members of a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ '(foo|bar|baz)', '(foo|bar|baz)', '(foo|bar|baz)' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/smove/index.md b/doc/src/controllers/ms/smove/index.md new file mode 100644 index 000000000..942d77bd6 --- /dev/null +++ b/doc/src/controllers/ms/smove/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: smove +--- + +# smove + +Moves a member from a set of unique values to another. + +[[_Redis documentation_]](https://redis.io/commands/smove) + +## Arguments + +```js +smove(src, dest, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Source set key | +| `dest` |
string
| Destination set key | +| `member` |
string
| Member to move | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation succeeded or not. + +## Usage + +<<< ./snippets/smove.js diff --git a/doc/src/controllers/ms/smove/snippets/smove.js b/doc/src/controllers/ms/smove/snippets/smove.js new file mode 100644 index 000000000..06ddc9be0 --- /dev/null +++ b/doc/src/controllers/ms/smove/snippets/smove.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.sadd('set1', ['foo', 'bar', 'baz']); + await kuzzle.ms.sadd('set2', ['qux']); + + await kuzzle.ms.smove('set1', 'set2', 'foo'); + + // Prints: [ 'bar', 'baz' ] + console.log(await kuzzle.ms.smembers('set1')); + + // Prints: [ 'foo', 'qux' ] + console.log(await kuzzle.ms.smembers('set2')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/smove/snippets/smove.test.yml b/doc/src/controllers/ms/smove/snippets/smove.test.yml new file mode 100644 index 000000000..abbf09ca1 --- /dev/null +++ b/doc/src/controllers/ms/smove/snippets/smove.test.yml @@ -0,0 +1,11 @@ +name: ms#smove +description: Moves a member from a set of unique values to another +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ '(bar|baz)', '(bar|baz)' ]" + - "\\[ '(foo|qux)', '(foo|qux)' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sort/index.md b/doc/src/controllers/ms/sort/index.md new file mode 100644 index 000000000..e3641baa8 --- /dev/null +++ b/doc/src/controllers/ms/sort/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: sort +--- + +# sort + +Sorts and returns elements contained in a list, a set of unique values or a sorted set. +By default, sorting is numeric and elements are compared by their value, interpreted as double precision floating point number. + +[[_Redis documentation_]](https://redis.io/commands/sort) + +## Arguments + +```js +sort(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | --------------------------- | +| `key` |
string
| List, set or sorted set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `alpha` |
boolean (false)
| Performs an alphanumerical sort instead of a numeric one | +| `by` |
string
| Instead of sorting by values, sorts by values contained in external keys, using the provided pattern completed by values of the list/set/sorted set to sort | +| `direction` |
string ('ASC')
| Sorts in ascendant or descendant order.
Allowed values: `ASC`, `DESC` | +| `get` |
string[]
| Instead of returning the sorted values directly, returns the values contained in external keys, using patterns completed by the sorted values | +| `limit` |
integer[]
| Limits the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the sorted elements. + +## Usage + +<<< ./snippets/sort.js diff --git a/doc/src/controllers/ms/sort/snippets/sort.js b/doc/src/controllers/ms/sort/snippets/sort.js new file mode 100644 index 000000000..7228c23eb --- /dev/null +++ b/doc/src/controllers/ms/sort/snippets/sort.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.sadd('setfoo', [1, 2, 3, 4, 5, 6, 7]); + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz', 'qux']); + + // Prints: [ '7', '6', '5', '4', '3', '2', '1' ] + console.log(await kuzzle.ms.sort('setfoo', {direction: 'DESC'})); + + // Prints: [ 'bar', 'baz', 'foo', 'qux' ] + console.log(await kuzzle.ms.sort('listfoo', {alpha: true})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sort/snippets/sort.test.yml b/doc/src/controllers/ms/sort/snippets/sort.test.yml new file mode 100644 index 000000000..10a6a0b7e --- /dev/null +++ b/doc/src/controllers/ms/sort/snippets/sort.test.yml @@ -0,0 +1,11 @@ +name: ms#sort +description: Sorts and returns elements contained in a list, a set or a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ '7', '6', '5', '4', '3', '2', '1' ]" + - "\\[ 'bar', 'baz', 'foo', 'qux' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/spop/index.md b/doc/src/controllers/ms/spop/index.md new file mode 100644 index 000000000..d54920635 --- /dev/null +++ b/doc/src/controllers/ms/spop/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: spop +--- + +# spop + +Removes and returns one or more elements at random from a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/spop) + +## Arguments + +```js +spop(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (1)
| The number of elements to pop | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of removed elements. + +## Usage + +<<< ./snippets/spop.js diff --git a/doc/src/controllers/ms/spop/snippets/spop.js b/doc/src/controllers/ms/spop/snippets/spop.js new file mode 100644 index 000000000..0b9c8886a --- /dev/null +++ b/doc/src/controllers/ms/spop/snippets/spop.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.sadd('setfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + // Prints one of the elements of setfoo, at random + console.log(await kuzzle.ms.spop('setfoo')); + + // Prints three of the remaining elements of setfoo, at random + console.log(await kuzzle.ms.spop('setfoo', {count: 3})); + + // Prints: 2 + console.log(await kuzzle.ms.scard('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/spop/snippets/spop.test.yml b/doc/src/controllers/ms/spop/snippets/spop.test.yml new file mode 100644 index 000000000..6fdcdadec --- /dev/null +++ b/doc/src/controllers/ms/spop/snippets/spop.test.yml @@ -0,0 +1,12 @@ +name: ms#spop +description: Removes one or more elements at random from a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "^\\[ '[a-f]' ]" + - "^\\[ '[a-f]', '[a-f]', '[a-f]' ]" + - ^2$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/srandmember/index.md b/doc/src/controllers/ms/srandmember/index.md new file mode 100644 index 000000000..c668e4894 --- /dev/null +++ b/doc/src/controllers/ms/srandmember/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: srandmember +--- + +# srandmember + +Returns one or more members of a set of unique values, at random. + +[[_Redis documentation_]](https://redis.io/commands/srandmember) + +## Arguments + +```js +srandmember(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | -------- | ------------------------ | +| `key` | `string` | Set key | +| `options` | `object` | Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `count` | `integer (1)` | If positive, returns `count` elements at random from the set, without repetition.
If negative, returns `abs(count)` elements, and the same element can be chosen multiple times | +| `queuable` | `boolean (true)` | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +## Usage + +<<< ./snippets/srandmember.js diff --git a/doc/src/controllers/ms/srandmember/snippets/srandmember.js b/doc/src/controllers/ms/srandmember/snippets/srandmember.js new file mode 100644 index 000000000..f3a62c5bf --- /dev/null +++ b/doc/src/controllers/ms/srandmember/snippets/srandmember.js @@ -0,0 +1,12 @@ +try { + + await kuzzle.ms.sadd('setfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + // Prints one of the elements of setfoo, at random + console.log(await kuzzle.ms.srandmember('setfoo')); + + // Prints three elements of setfoo, at random + console.log(await kuzzle.ms.srandmember('setfoo', {count: 3})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/srandmember/snippets/srandmember.test.yml b/doc/src/controllers/ms/srandmember/snippets/srandmember.test.yml new file mode 100644 index 000000000..ff393adee --- /dev/null +++ b/doc/src/controllers/ms/srandmember/snippets/srandmember.test.yml @@ -0,0 +1,11 @@ +name: ms#srandmember +description: Returns one or more members of a set of unique values, at random +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "^\\[ '[a-f]' ]" + - "^\\[ '[a-f]', '[a-f]', '[a-f]' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/srem/index.md b/doc/src/controllers/ms/srem/index.md new file mode 100644 index 000000000..d88c22c69 --- /dev/null +++ b/doc/src/controllers/ms/srem/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: srem +--- + +# srem + +Removes members from a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/srem) + +## Arguments + +```js +srem(key, members, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------- | +| `key` |
string
| Set key | +| `members` |
string[]
| List of members to remove | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed members. + +## Usage + +<<< ./snippets/srem.js diff --git a/doc/src/controllers/ms/srem/snippets/srem.js b/doc/src/controllers/ms/srem/snippets/srem.js new file mode 100644 index 000000000..2d984c745 --- /dev/null +++ b/doc/src/controllers/ms/srem/snippets/srem.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: 2 + console.log(await kuzzle.ms.srem('setfoo', ['bar', 'baz'])); + + // Prints: ['foo'] + console.log(await kuzzle.ms.smembers('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/srem/snippets/srem.test.yml b/doc/src/controllers/ms/srem/snippets/srem.test.yml new file mode 100644 index 000000000..788fb56b0 --- /dev/null +++ b/doc/src/controllers/ms/srem/snippets/srem.test.yml @@ -0,0 +1,11 @@ +name: ms#srem +description: Removes members from a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - "\\[ 'foo' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sscan/index.md b/doc/src/controllers/ms/sscan/index.md new file mode 100644 index 000000000..a862588a9 --- /dev/null +++ b/doc/src/controllers/ms/sscan/index.md @@ -0,0 +1,53 @@ +--- +code: true +type: page +title: sscan +--- + +# sscan + +Iterates incrementally over members contained in a set of unique values, using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/sscan) + +## Arguments + +```js +sscan(key, cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Set key | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | ----------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of found members | + +## Usage + +<<< ./snippets/sscan.js diff --git a/doc/src/controllers/ms/sscan/snippets/sscan.js b/doc/src/controllers/ms/sscan/snippets/sscan.js new file mode 100644 index 000000000..05121a1f9 --- /dev/null +++ b/doc/src/controllers/ms/sscan/snippets/sscan.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: + // { + // cursor: '0', + // values: [ bar', 'baz' ] + // } + console.log(await kuzzle.ms.sscan('setfoo', 0, {match: 'ba*'})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sscan/snippets/sscan.test.yml b/doc/src/controllers/ms/sscan/snippets/sscan.test.yml new file mode 100644 index 000000000..30984934a --- /dev/null +++ b/doc/src/controllers/ms/sscan/snippets/sscan.test.yml @@ -0,0 +1,11 @@ +name: ms#sscan +description: Iterates incrementally over members contained in a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0', values: \\[ 'ba[rz]', 'ba[rz]' ] }" + +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/strlen/index.md b/doc/src/controllers/ms/strlen/index.md new file mode 100644 index 000000000..f08e8a8aa --- /dev/null +++ b/doc/src/controllers/ms/strlen/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: strlen +--- + +# strlen + +Returns the length of a value. + +[[_Redis documentation_]](https://redis.io/commands/strlen) + +## Arguments + +```js +strlen(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the value's length. + +## Usage + +<<< ./snippets/strlen.js diff --git a/doc/src/controllers/ms/strlen/snippets/strlen.js b/doc/src/controllers/ms/strlen/snippets/strlen.js new file mode 100644 index 000000000..1fd6d1890 --- /dev/null +++ b/doc/src/controllers/ms/strlen/snippets/strlen.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'abcdef'); + + // Prints: 6 + console.log(await kuzzle.ms.strlen('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/strlen/snippets/strlen.test.yml b/doc/src/controllers/ms/strlen/snippets/strlen.test.yml new file mode 100644 index 000000000..de4defc7b --- /dev/null +++ b/doc/src/controllers/ms/strlen/snippets/strlen.test.yml @@ -0,0 +1,9 @@ +name: ms#strlen +description: Returns the length of a value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^6$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sunion/index.md b/doc/src/controllers/ms/sunion/index.md new file mode 100644 index 000000000..d7e68457f --- /dev/null +++ b/doc/src/controllers/ms/sunion/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: sunion +--- + +# sunion + +Returns the union of sets of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sunion) + +## Arguments + +```js +sunion(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of set keys | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the result of the union between the provided sets. + +## Usage + +<<< ./snippets/sunion.js diff --git a/doc/src/controllers/ms/sunion/snippets/sunion.js b/doc/src/controllers/ms/sunion/snippets/sunion.js new file mode 100644 index 000000000..3e414c706 --- /dev/null +++ b/doc/src/controllers/ms/sunion/snippets/sunion.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.sadd('set1', ['a', 'b', 'c']); + await kuzzle.ms.sadd('set2', ['d', 'e', 'f']); + await kuzzle.ms.sadd('set3', ['g', 'h', 'i']); + + // Prints: [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' ] + console.log(await kuzzle.ms.sunion(['set1', 'set2', 'set3'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sunion/snippets/sunion.test.yml b/doc/src/controllers/ms/sunion/snippets/sunion.test.yml new file mode 100644 index 000000000..14b73c511 --- /dev/null +++ b/doc/src/controllers/ms/sunion/snippets/sunion.test.yml @@ -0,0 +1,9 @@ +name: ms#sunion +description: Returns the union of sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ ('[a-i]', ){8}'[a-i]' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/sunionstore/index.md b/doc/src/controllers/ms/sunionstore/index.md new file mode 100644 index 000000000..7557d9759 --- /dev/null +++ b/doc/src/controllers/ms/sunionstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: sunionstore +--- + +# sunionstore + +Computes the union of multiple sets of unique values and stores it in a new set. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sunionstore) + +## Arguments + +```js +sunionstore(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Union target key | +| `sources` |
string[]
| List of set keys | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of values added to the destination key. + +## Usage + +<<< ./snippets/sunionstore.js diff --git a/doc/src/controllers/ms/sunionstore/snippets/sunionstore.js b/doc/src/controllers/ms/sunionstore/snippets/sunionstore.js new file mode 100644 index 000000000..59f60e382 --- /dev/null +++ b/doc/src/controllers/ms/sunionstore/snippets/sunionstore.js @@ -0,0 +1,16 @@ +try { + await kuzzle.ms.sadd('set1', ['a', 'b', 'c']); + await kuzzle.ms.sadd('set2', ['d', 'e', 'f']); + await kuzzle.ms.sadd('set3', ['g', 'h', 'i']); + + // Prints: 9 + console.log(await kuzzle.ms.sunionstore( + 'setdest', + ['set1', 'set2', 'set3'] + )); + + // Prints: [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' ] + console.log(await kuzzle.ms.smembers('setdest')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/sunionstore/snippets/sunionstore.test.yml b/doc/src/controllers/ms/sunionstore/snippets/sunionstore.test.yml new file mode 100644 index 000000000..9f42d0202 --- /dev/null +++ b/doc/src/controllers/ms/sunionstore/snippets/sunionstore.test.yml @@ -0,0 +1,11 @@ +name: ms#sunionstore +description: Stores the union of multiple sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^9$ + - "\\[ ('[a-i]', ){8}'[a-i]' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/time/index.md b/doc/src/controllers/ms/time/index.md new file mode 100644 index 000000000..e3ec5552d --- /dev/null +++ b/doc/src/controllers/ms/time/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: time +--- + +# time + +Returns the current server time. + +[[_Redis documentation_]](https://redis.io/commands/time) + +## Arguments + +```js +time([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the time as a two items array: + +- a timestamp in [Epoch time](https://en.wikipedia.org/wiki/Unix_time) +- the number of microseconds already elapsed in the current second + +## Usage + +<<< ./snippets/time.js diff --git a/doc/src/controllers/ms/time/snippets/time.js b/doc/src/controllers/ms/time/snippets/time.js new file mode 100644 index 000000000..9c8fe916f --- /dev/null +++ b/doc/src/controllers/ms/time/snippets/time.js @@ -0,0 +1,8 @@ +try { + // Prints: [ 1542890183, 868983 ] + // ...but only if the current time on your server is: + // [GMT] Nov. 22, 2018 12:36:23 PM + console.log(await kuzzle.ms.time()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/time/snippets/time.test.yml b/doc/src/controllers/ms/time/snippets/time.test.yml new file mode 100644 index 000000000..3f1a9b33b --- /dev/null +++ b/doc/src/controllers/ms/time/snippets/time.test.yml @@ -0,0 +1,10 @@ +name: ms#time +description: Returns the current server time +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ \\d{10}, \\d+ ]$" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/touch/index.md b/doc/src/controllers/ms/touch/index.md new file mode 100644 index 000000000..da004fb23 --- /dev/null +++ b/doc/src/controllers/ms/touch/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: touch +--- + +# touch + +Alters the last access time of the provided keys. A key is ignored if it does not exist. + +[[_Redis documentation_]](https://redis.io/commands/touch) + +## Arguments + +```js +touch(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of keys to alter | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of altered keys. + +## Usage + +<<< ./snippets/touch.js diff --git a/doc/src/controllers/ms/touch/snippets/touch.js b/doc/src/controllers/ms/touch/snippets/touch.js new file mode 100644 index 000000000..a834a7c45 --- /dev/null +++ b/doc/src/controllers/ms/touch/snippets/touch.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + await kuzzle.ms.set('baz', 'qux'); + + // Prints: 2 + console.log(await kuzzle.ms.touch(['foo', 'baz', 'thedroidsIamlookingfor'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/touch/snippets/touch.test.yml b/doc/src/controllers/ms/touch/snippets/touch.test.yml new file mode 100644 index 000000000..8da644f65 --- /dev/null +++ b/doc/src/controllers/ms/touch/snippets/touch.test.yml @@ -0,0 +1,9 @@ +name: ms#touch +description: Alters the last access time of the provided keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^2$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/ttl/index.md b/doc/src/controllers/ms/ttl/index.md new file mode 100644 index 000000000..d9340adeb --- /dev/null +++ b/doc/src/controllers/ms/ttl/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: ttl +--- + +# ttl + +Returns the remaining time to live of a key, in seconds. + +[[_Redis documentation_]](https://redis.io/commands/ttl) + +## Arguments + +```js +ttl(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the remaining key TTL, in seconds, or to a negative value if the key does not exist or if it is persistent. + +## Usage + +<<< ./snippets/ttl.js diff --git a/doc/src/controllers/ms/ttl/snippets/ttl.js b/doc/src/controllers/ms/ttl/snippets/ttl.js new file mode 100644 index 000000000..d5253719e --- /dev/null +++ b/doc/src/controllers/ms/ttl/snippets/ttl.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'bar', {ex: 60}); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/ttl/snippets/ttl.test.yml b/doc/src/controllers/ms/ttl/snippets/ttl.test.yml new file mode 100644 index 000000000..0b6ac875b --- /dev/null +++ b/doc/src/controllers/ms/ttl/snippets/ttl.test.yml @@ -0,0 +1,9 @@ +name: ms#ttl +description: Returns the remaining time to live of a key, in seconds +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^\d{1,2}$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/type/index.md b/doc/src/controllers/ms/type/index.md new file mode 100644 index 000000000..c055f6eac --- /dev/null +++ b/doc/src/controllers/ms/type/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: type +--- + +# type + +Returns the type of the value held by a key. + +[[_Redis documentation_]](https://redis.io/commands/type) + +## Arguments + +```js +type(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to one of the following: `hash`, `list`, `string`, `set`, `zset` + +## Usage + +<<< ./snippets/type.js diff --git a/doc/src/controllers/ms/type/snippets/type.js b/doc/src/controllers/ms/type/snippets/type.js new file mode 100644 index 000000000..a19c9f25f --- /dev/null +++ b/doc/src/controllers/ms/type/snippets/type.js @@ -0,0 +1,16 @@ +try { + await kuzzle.ms.set('foo', 123); + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: string + console.log(await kuzzle.ms.type('foo')); + + // Prints: list + console.log(await kuzzle.ms.type('listfoo')); + + // Prints: set + console.log(await kuzzle.ms.type('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/type/snippets/type.test.yml b/doc/src/controllers/ms/type/snippets/type.test.yml new file mode 100644 index 000000000..cb36f7b49 --- /dev/null +++ b/doc/src/controllers/ms/type/snippets/type.test.yml @@ -0,0 +1,12 @@ +name: ms#type +description: Returns the type of the value held by a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^string$ + - ^list$ + - ^set$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zadd/index.md b/doc/src/controllers/ms/zadd/index.md new file mode 100644 index 000000000..58bad292e --- /dev/null +++ b/doc/src/controllers/ms/zadd/index.md @@ -0,0 +1,60 @@ +--- +code: true +type: page +title: zadd +--- + +# zadd + +Adds elements to a sorted set. + +If the key does not exist, it is created, holding an empty sorted set. + +If the key already exists but does not hold a sorted set, an error is returned. + +If a member to insert is already in the sorted set, its score is updated and the member is reinserted at the right position in the set. + +[[_Redis documentation_]](https://redis.io/commands/zadd) + +## Arguments + +```js +zadd(key, elements, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ------------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `elements` |
object[]
| Elements to add | +| `options` |
object
| Optional query arguments | + +### elements + +The `elements` array lists the elements to add to the sorted set. Each element object has the following properties: + +| Properties | Type | Description | +| ---------- | ----------------- | ------------ | +| `member` |
string
| Member value | +| `score` |
string
| Member score | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `ch` |
boolean (false)
| If true, instead of returning the number of added elements, returns the number of changes performed | +| `incr` |
boolean (false)
| If true, instead of adding elements, increments the existing member with the provided `score`. Only one element can be specified if this option is set | +| `nx` |
boolean (false)
| If true, only adds new elements, without altering existing ones | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `xx` |
boolean (false)
| If true, ignores new elements, alters only existing ones | + +## Resolve + +Resolves to the number of added elements or, if the `ch` option is set, resolves to the number of changes performed. + +## Usage + +<<< ./snippets/zadd.js diff --git a/doc/src/controllers/ms/zadd/snippets/zadd.js b/doc/src/controllers/ms/zadd/snippets/zadd.js new file mode 100644 index 000000000..49d1b24ea --- /dev/null +++ b/doc/src/controllers/ms/zadd/snippets/zadd.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'bar', score: 4 }, + // { member: 'foo', score: 42 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zadd/snippets/zadd.test.yml b/doc/src/controllers/ms/zadd/snippets/zadd.test.yml new file mode 100644 index 000000000..688ccce02 --- /dev/null +++ b/doc/src/controllers/ms/zadd/snippets/zadd.test.yml @@ -0,0 +1,12 @@ +name: ms#zadd +description: Adds elements to a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - " { member: 'bar', score: 4 }," + - " { member: 'foo', score: 42 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zcard/index.md b/doc/src/controllers/ms/zcard/index.md new file mode 100644 index 000000000..ad9afa03d --- /dev/null +++ b/doc/src/controllers/ms/zcard/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: zcard +--- + +# zcard + +Returns the number of elements held by a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zcard) + +## Arguments + +```js +zcard(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of elements in the sorted set. + +## Usage + +<<< ./snippets/zcard.js diff --git a/doc/src/controllers/ms/zcard/snippets/zcard.js b/doc/src/controllers/ms/zcard/snippets/zcard.js new file mode 100644 index 000000000..34b296ab9 --- /dev/null +++ b/doc/src/controllers/ms/zcard/snippets/zcard.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints 3 + console.log(await kuzzle.ms.zcard('ssetfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zcard/snippets/zcard.test.yml b/doc/src/controllers/ms/zcard/snippets/zcard.test.yml new file mode 100644 index 000000000..3879d59ef --- /dev/null +++ b/doc/src/controllers/ms/zcard/snippets/zcard.test.yml @@ -0,0 +1,9 @@ +name: ms#zcard +description: Returns the number of elements held by a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zcount/index.md b/doc/src/controllers/ms/zcount/index.md new file mode 100644 index 000000000..388156a2d --- /dev/null +++ b/doc/src/controllers/ms/zcount/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zcount +--- + +# zcount + +Returns the number of elements held by a sorted set with a score within the provided range. + +[[_Redis documentation_]](https://redis.io/commands/zcount) + +## Arguments + +```js +zcount(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYSCORE](https://redis.io/commands/zrangebyscore#exclusive-intervals-and-infinity) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +## Usage + +<<< ./snippets/zcount.js diff --git a/doc/src/controllers/ms/zcount/snippets/zcount.js b/doc/src/controllers/ms/zcount/snippets/zcount.js new file mode 100644 index 000000000..72b60f2ec --- /dev/null +++ b/doc/src/controllers/ms/zcount/snippets/zcount.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 2 + // Counts elements with a score lower than 42 (excluded) + console.log(await kuzzle.ms.zcount('ssetfoo', '-inf', '(42')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zcount/snippets/zcount.test.yml b/doc/src/controllers/ms/zcount/snippets/zcount.test.yml new file mode 100644 index 000000000..f0e2cc704 --- /dev/null +++ b/doc/src/controllers/ms/zcount/snippets/zcount.test.yml @@ -0,0 +1,9 @@ +name: ms#zcount +description: Counts elements in a sorted set within a score range +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^2$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zincrby/index.md b/doc/src/controllers/ms/zincrby/index.md new file mode 100644 index 000000000..53e502d86 --- /dev/null +++ b/doc/src/controllers/ms/zincrby/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zincrby +--- + +# zincrby + +Increments the score of a sorted set member by the provided value. + +[[_Redis documentation_]](https://redis.io/commands/zincrby) + +## Arguments + +```js +zincrby(key, member, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ---------------------------------------- | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `increment` |
integer
| Increment to apply to the member's score | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated member's score. + +## Usage + +<<< ./snippets/zincrby.js diff --git a/doc/src/controllers/ms/zincrby/snippets/zincrby.js b/doc/src/controllers/ms/zincrby/snippets/zincrby.js new file mode 100644 index 000000000..2b6008aee --- /dev/null +++ b/doc/src/controllers/ms/zincrby/snippets/zincrby.js @@ -0,0 +1,17 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zincrby('ssetfoo', 'bar', 1333); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'foo', score: 42 }, + // { member: 'bar', score: 1337 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zincrby/snippets/zincrby.test.yml b/doc/src/controllers/ms/zincrby/snippets/zincrby.test.yml new file mode 100644 index 000000000..0d968a143 --- /dev/null +++ b/doc/src/controllers/ms/zincrby/snippets/zincrby.test.yml @@ -0,0 +1,12 @@ +name: ms#zincrby +description: Increments the score of a sorted set member by the provided value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - "\\{ member: 'foo', score: 42 }," + - "\\{ member: 'bar', score: 1337 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zinterstore/index.md b/doc/src/controllers/ms/zinterstore/index.md new file mode 100644 index 000000000..800e26f73 --- /dev/null +++ b/doc/src/controllers/ms/zinterstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: zinterstore +--- + +# zinterstore + +Computes the intersection of the provided sorted sets, and stores the result in a new sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zinterstore) + +## Arguments + +```js +zinterstore(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------------ | +| `dest` |
string
| Target sorted set key | +| `sources` |
string[]
| List of sorted set keys to intersect | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `aggregate` |
string ("sum")
| Specifies how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `weights` |
integer[]
| List of multiplication factors to apply to sources sets, before aggregation. | + +## Resolve + +Resolves to the number of members added to the destination sorted set. + +## Usage + +<<< ./snippets/zinterstore.js diff --git a/doc/src/controllers/ms/zinterstore/snippets/zinterstore.js b/doc/src/controllers/ms/zinterstore/snippets/zinterstore.js new file mode 100644 index 000000000..791344201 --- /dev/null +++ b/doc/src/controllers/ms/zinterstore/snippets/zinterstore.js @@ -0,0 +1,34 @@ +try { + await kuzzle.ms.zadd('sset1', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zadd('sset2', [ + {member: 'foo', score: '-29'}, + {member: 'baz', score: '300'} + ]); + + // Sums scores of intersected values + await kuzzle.ms.zinterstore('destsum', ['sset1', 'sset2']); + + // Stores the minimum possible scores of intersected values + await kuzzle.ms.zinterstore( + 'destmin', + ['sset1', 'sset2'], + {aggregate: 'min'} + ); + + // Prints: + // [ { member: 'foo', score: 13 }, + // { member: 'baz', score: 27.85 } ] + console.log(await kuzzle.ms.zrange('destsum', 0, -1)); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'foo', score: -29 } ] + console.log(await kuzzle.ms.zrange('destmin', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zinterstore/snippets/zinterstore.test.yml b/doc/src/controllers/ms/zinterstore/snippets/zinterstore.test.yml new file mode 100644 index 000000000..6ac996ae8 --- /dev/null +++ b/doc/src/controllers/ms/zinterstore/snippets/zinterstore.test.yml @@ -0,0 +1,13 @@ +name: ms#zinterstore +description: Stores the intersection of the provided sorted sets +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'foo', score: 13 }," + - " { member: 'baz', score: 27.85\\d* } ]" + - "\\[ { member: 'baz', score: -272.15 }" + - " { member: 'foo', score: -29 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zlexcount/index.md b/doc/src/controllers/ms/zlexcount/index.md new file mode 100644 index 000000000..a3e3a8cf2 --- /dev/null +++ b/doc/src/controllers/ms/zlexcount/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zlexcount +--- + +# zlexcount + +Counts elements in a sorted set where all members have equal score, using lexicographical ordering. + +[[_Redis documentation_]](https://redis.io/commands/zlexcount) + +## Arguments + +```js +zlexcount(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of elements in the provided range. + +## Usage + +<<< ./snippets/zlexcount.js diff --git a/doc/src/controllers/ms/zlexcount/snippets/zlexcount.js b/doc/src/controllers/ms/zlexcount/snippets/zlexcount.js new file mode 100644 index 000000000..0be03e8eb --- /dev/null +++ b/doc/src/controllers/ms/zlexcount/snippets/zlexcount.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + // Prints: 2 + // Lexicographically counts elements with a maximum value of 'f' (excluded), + // without a minimum value + console.log(await kuzzle.ms.zlexcount('ssetfoo', '-', '(f')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zlexcount/snippets/zlexcount.test.yml b/doc/src/controllers/ms/zlexcount/snippets/zlexcount.test.yml new file mode 100644 index 000000000..d6e40d7c6 --- /dev/null +++ b/doc/src/controllers/ms/zlexcount/snippets/zlexcount.test.yml @@ -0,0 +1,9 @@ +name: ms#zlexcount +description: Counts elements in a sorted set using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^2$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrange/index.md b/doc/src/controllers/ms/zrange/index.md new file mode 100644 index 000000000..b0f3d3d75 --- /dev/null +++ b/doc/src/controllers/ms/zrange/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zrange +--- + +# zrange + +Returns elements depending on their position in the sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zrange) + +## Arguments + +```js +zrange(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `key` |
string
| Sorted set key | +| `start` |
integer
| Starting index offset (inclusive) | +| `stop` |
integer
| Ending index offset (inclusive) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a list of element objects. + +## Usage + +<<< ./snippets/zrange.js diff --git a/doc/src/controllers/ms/zrange/snippets/zrange.js b/doc/src/controllers/ms/zrange/snippets/zrange.js new file mode 100644 index 000000000..e76070db7 --- /dev/null +++ b/doc/src/controllers/ms/zrange/snippets/zrange.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'bar', score: 4 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrange/snippets/zrange.test.yml b/doc/src/controllers/ms/zrange/snippets/zrange.test.yml new file mode 100644 index 000000000..ad7b75181 --- /dev/null +++ b/doc/src/controllers/ms/zrange/snippets/zrange.test.yml @@ -0,0 +1,11 @@ +name: ms#zrange +description: Returns elements depending on their position in the sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - "{ member: 'bar', score: 4 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrangebylex/index.md b/doc/src/controllers/ms/zrangebylex/index.md new file mode 100644 index 000000000..d33aa47c7 --- /dev/null +++ b/doc/src/controllers/ms/zrangebylex/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: zrangebylex +--- + +# zrangebylex + +Returns elements within a provided interval, in a sorted set where all members have equal score, using lexicographical ordering. + +[[_Redis documentation_]](https://redis.io/commands/zrangebylex) + +## Arguments + +```js +zrangebylex(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of matched elements. + +## Usage + +<<< ./snippets/zrangebylex.js diff --git a/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.js b/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.js new file mode 100644 index 000000000..e52f9081b --- /dev/null +++ b/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + // Prints: [ 'bar', 'baz' ] + // Lexicographically gets elements with a maximum value of 'f' (excluded), + // without a minimum value + console.log(await kuzzle.ms.zrangebylex('ssetfoo', '-', '(f')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml b/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml new file mode 100644 index 000000000..0877b44f6 --- /dev/null +++ b/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml @@ -0,0 +1,9 @@ +name: ms#zrangebylex +description: Returns elements within a provided interval, using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrangebyscore/index.md b/doc/src/controllers/ms/zrangebyscore/index.md new file mode 100644 index 000000000..4a796e21b --- /dev/null +++ b/doc/src/controllers/ms/zrangebyscore/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: zrangebyscore +--- + +# zrangebyscore + +Returns all sorted set elements with a score within a provided range. + +The elements are considered to be ordered from low to high scores. + +[[_Redis documentation_]](https://redis.io/commands/zrangebyscore) + +## Arguments + +```js +zrangebyscore(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum score value | +| `max` |
string
| Maximum score value | +| `options` |
object
| Optional query arguments | + +By default, `min` and `max` are inclusive. Check the full Redis documentation for other options. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of elements in the provided score range. + +## Usage + +<<< ./snippets/zrangebyscore.js diff --git a/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.js b/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.js new file mode 100644 index 000000000..883a68ef5 --- /dev/null +++ b/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'bar', score: 4 } ] + console.log(await kuzzle.ms.zrangebyscore('ssetfoo', '-inf', '(42')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml b/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml new file mode 100644 index 000000000..25e845808 --- /dev/null +++ b/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml @@ -0,0 +1,11 @@ +name: ms#zrangebyscore +description: Returns all sorted set elements with a score within a provided range +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - "{ member: 'bar', score: 4 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrank/index.md b/doc/src/controllers/ms/zrank/index.md new file mode 100644 index 000000000..ae68b82de --- /dev/null +++ b/doc/src/controllers/ms/zrank/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zrank +--- + +# zrank + +Returns the position of an element in a sorted set, with scores sorted in ascending order. The index returned is 0-based (the lowest score member has an index of 0). + +[[_Redis documentation_]](https://redis.io/commands/zrank) + +## Arguments + +```js +zrank(key, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the index of the found member in the sorted set, or to `null` if the member is not found. + +## Usage + +<<< ./snippets/zrank.js diff --git a/doc/src/controllers/ms/zrank/snippets/zrank.js b/doc/src/controllers/ms/zrank/snippets/zrank.js new file mode 100644 index 000000000..f92571cf8 --- /dev/null +++ b/doc/src/controllers/ms/zrank/snippets/zrank.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 2 + console.log(await kuzzle.ms.zrank('ssetfoo', 'foo')); + + // Prints: null + console.log(await kuzzle.ms.zrank('ssetfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrank/snippets/zrank.test.yml b/doc/src/controllers/ms/zrank/snippets/zrank.test.yml new file mode 100644 index 000000000..7c003c8ec --- /dev/null +++ b/doc/src/controllers/ms/zrank/snippets/zrank.test.yml @@ -0,0 +1,11 @@ +name: ms#zrank +description: Returns the position of an element in a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - ^null$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrem/index.md b/doc/src/controllers/ms/zrem/index.md new file mode 100644 index 000000000..1778ca68d --- /dev/null +++ b/doc/src/controllers/ms/zrem/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zrem +--- + +# zrem + +Removes members from a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zrem) + +## Arguments + +```js +zrem(key, members, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `members` |
string[]
| Member values to remove | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed members. + +## Usage + +<<< ./snippets/zrem.js diff --git a/doc/src/controllers/ms/zrem/snippets/zrem.js b/doc/src/controllers/ms/zrem/snippets/zrem.js new file mode 100644 index 000000000..75893c159 --- /dev/null +++ b/doc/src/controllers/ms/zrem/snippets/zrem.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zrem('ssetfoo', ['foo', 'bar']); + + // Prints: [ { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrem/snippets/zrem.test.yml b/doc/src/controllers/ms/zrem/snippets/zrem.test.yml new file mode 100644 index 000000000..b3dc91706 --- /dev/null +++ b/doc/src/controllers/ms/zrem/snippets/zrem.test.yml @@ -0,0 +1,9 @@ +name: ms#zrem +description: Removes members from a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ { member: 'baz', score: -272.15 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zremrangebylex/index.md b/doc/src/controllers/ms/zremrangebylex/index.md new file mode 100644 index 000000000..e73a28459 --- /dev/null +++ b/doc/src/controllers/ms/zremrangebylex/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zremrangebylex +--- + +# zremrangebylex + +Removes members within a provided range, from a sorted set where all elements have the same score, using lexicographical ordering. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebylex) + +## Arguments + +```js +zremrangebylex(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed members. + +## Usage + +<<< ./snippets/zremrangebylex.js diff --git a/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.js b/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.js new file mode 100644 index 000000000..97fb5a232 --- /dev/null +++ b/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + await kuzzle.ms.zremrangebylex('ssetfoo', '[baz', '+'); + + // Prints: [ 'bar' ] + console.log(await kuzzle.ms.zrangebylex('ssetfoo', '-', '+')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml b/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml new file mode 100644 index 000000000..a33d40996 --- /dev/null +++ b/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml @@ -0,0 +1,9 @@ +name: ms#zremrangebylex +description: Removes members within a provided range, using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'bar' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zremrangebyrank/index.md b/doc/src/controllers/ms/zremrangebyrank/index.md new file mode 100644 index 000000000..c2b8b7dad --- /dev/null +++ b/doc/src/controllers/ms/zremrangebyrank/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zremrangebyrank +--- + +# zremrangebyrank + +Removes members from a sorted set, with their position in the set within a provided index range. + +Positions are 0-based, meaning the first member of the set has a position of 0. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebyrank) + +## Arguments + +```js +zremrangebyrank(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `key` |
string
| Sorted set key | +| `start` |
integer
| Starting index offset (inclusive) | +| `stop` |
integer
| Ending index offset (inclusive) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed elements. + +## Usage + +<<< ./snippets/zremrangebyrank.js diff --git a/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js b/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js new file mode 100644 index 000000000..61c724559 --- /dev/null +++ b/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zremrangebyrank('ssetfoo', 1, 2); + + // Prints: [ { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml b/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml new file mode 100644 index 000000000..3dc0390ab --- /dev/null +++ b/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml @@ -0,0 +1,9 @@ +name: ms#zremrangebyrank +description: Removes members from a sorted setn by position +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ { member: 'baz', score: -272.15 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zremrangebyscore/index.md b/doc/src/controllers/ms/zremrangebyscore/index.md new file mode 100644 index 000000000..51f0ef8fd --- /dev/null +++ b/doc/src/controllers/ms/zremrangebyscore/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zremrangebyscore +--- + +# zremrangebyscore + +Removes members from a sorted set, with a score between the provided interval. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebylex) + +## Arguments + +```js +zremrangebyscore(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum score value | +| `max` |
string
| Maximum score value | +| `options` |
object
| Optional query arguments | + +By default, `min` and `max` are inclusive. Check the full Redis documentation for other options. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed elements. + +## Usage + +<<< ./snippets/zremrangebyscore.js diff --git a/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js b/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js new file mode 100644 index 000000000..3b81af9ba --- /dev/null +++ b/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zremrangebyscore('ssetfoo', '0', '+inf'); + + // Prints: [ { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml b/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml new file mode 100644 index 000000000..bd0924e7e --- /dev/null +++ b/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml @@ -0,0 +1,9 @@ +name: ms#zremrangebyscore +description: Removes members from a sorted set, by score +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ { member: 'baz', score: -272.15 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrevrange/index.md b/doc/src/controllers/ms/zrevrange/index.md new file mode 100644 index 000000000..3c22ff3b2 --- /dev/null +++ b/doc/src/controllers/ms/zrevrange/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zrevrange +--- + +# zrevrange + +Identical to [zrange](/sdk/js/6/controllers/ms/zrange), except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrange) + +## Arguments + +```js +zrevrange(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `key` |
string
| Sorted set key | +| `start` |
integer
| Starting index offset (inclusive) | +| `stop` |
integer
| Ending index offset (inclusive) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a list of element objects. + +## Usage + +<<< ./snippets/zrevrange.js diff --git a/doc/src/controllers/ms/zrevrange/snippets/zrevrange.js b/doc/src/controllers/ms/zrevrange/snippets/zrevrange.js new file mode 100644 index 000000000..19025699b --- /dev/null +++ b/doc/src/controllers/ms/zrevrange/snippets/zrevrange.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'foo', score: 42 }, + // { member: 'bar', score: 4 } ] + console.log(await kuzzle.ms.zrevrange('ssetfoo', 0, 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrevrange/snippets/zrevrange.test.yml b/doc/src/controllers/ms/zrevrange/snippets/zrevrange.test.yml new file mode 100644 index 000000000..a155183b1 --- /dev/null +++ b/doc/src/controllers/ms/zrevrange/snippets/zrevrange.test.yml @@ -0,0 +1,10 @@ +name: ms#zrevrange +description: Returns elements depending on their position in the sorted set, in descending order +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'foo', score: 42 }, { member: 'bar', score: 4 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrevrangebylex/index.md b/doc/src/controllers/ms/zrevrangebylex/index.md new file mode 100644 index 000000000..3ded3eb72 --- /dev/null +++ b/doc/src/controllers/ms/zrevrangebylex/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: zrevrangebylex +--- + +# zrevrangebylex + +Identical to [zrangebylex](/core/1/api/api-reference/controller-memory-storage/zrangebylex/) except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrangebylex) + +## Arguments + +```js +zrevrangebylex(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of matched elements. + +## Usage + +<<< ./snippets/zrevrangebylex.js diff --git a/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js b/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js new file mode 100644 index 000000000..a056f7261 --- /dev/null +++ b/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + // Prints: [ 'baz', 'bar' ] + // Lexicographically gets elements with a maximum value of 'f' (excluded), + // without a minimum value + console.log(await kuzzle.ms.zrevrangebylex('ssetfoo', '-', '(f')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml b/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml new file mode 100644 index 000000000..895a059e0 --- /dev/null +++ b/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml @@ -0,0 +1,9 @@ +name: ms#zrevrangebylex +description: Returns elements within a provided interval, using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'baz', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrevrangebyscore/index.md b/doc/src/controllers/ms/zrevrangebyscore/index.md new file mode 100644 index 000000000..28cf60125 --- /dev/null +++ b/doc/src/controllers/ms/zrevrangebyscore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: zrevrangebyscore +--- + +# zrevrangebyscore + +Identical to [zrangebyscore](/core/1/api/api-reference/controller-memory-storage/zrangebyscore/), except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrangebyscore) + +## Arguments + +```js +zrevrangebyscore(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum score value | +| `max` |
string
| Maximum score value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of elements in the provided score range, in descending order. + +## Usage + +<<< ./snippets/zrevrangebyscore.js diff --git a/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js b/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js new file mode 100644 index 000000000..37b591750 --- /dev/null +++ b/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'bar', score: 4 }, + // { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrevrangebyscore('ssetfoo', '-inf', '(42')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml b/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml new file mode 100644 index 000000000..f44188795 --- /dev/null +++ b/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml @@ -0,0 +1,12 @@ +name: ms#zrevrangebyscore +description: Returns all sorted set elements with a score within a provided range in descending order +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'bar', score: 4 }," + - "{ member: 'baz', score: -272.15 } ]" + +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zrevrank/index.md b/doc/src/controllers/ms/zrevrank/index.md new file mode 100644 index 000000000..312aa3a41 --- /dev/null +++ b/doc/src/controllers/ms/zrevrank/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zrevrank +--- + +# zrevrank + +Returns the position of an element in a sorted set, with scores in descending order. The index returned is 0-based (the lowest score member has an index of 0). + +[[_Redis documentation_]](https://redis.io/commands/zrevrank) + +## Arguments + +```js +zrevrank(key, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the index of the found member in the sorted set, or to `null` if the member is not found. + +## Usage + +<<< ./snippets/zrevrank.js diff --git a/doc/src/controllers/ms/zrevrank/snippets/zrevrank.js b/doc/src/controllers/ms/zrevrank/snippets/zrevrank.js new file mode 100644 index 000000000..9e7442449 --- /dev/null +++ b/doc/src/controllers/ms/zrevrank/snippets/zrevrank.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 0 + console.log(await kuzzle.ms.zrevrank('ssetfoo', 'foo')); + + // Prints: null + console.log(await kuzzle.ms.zrank('ssetfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zrevrank/snippets/zrevrank.test.yml b/doc/src/controllers/ms/zrevrank/snippets/zrevrank.test.yml new file mode 100644 index 000000000..7265aa01a --- /dev/null +++ b/doc/src/controllers/ms/zrevrank/snippets/zrevrank.test.yml @@ -0,0 +1,12 @@ +name: ms#zrevrank +description: Returns the position of an element in a sorted set, in reverse order +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^null$ + +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zscan/index.md b/doc/src/controllers/ms/zscan/index.md new file mode 100644 index 000000000..78be305d6 --- /dev/null +++ b/doc/src/controllers/ms/zscan/index.md @@ -0,0 +1,53 @@ +--- +code: true +type: page +title: zscan +--- + +# zscan + +Iterates incrementally over members contained in a sorted set, using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/sscan) + +## Arguments + +```js +zscan(key, cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Sorted set key | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | --------------------------------------------------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of member-score pairs. The array entries alternate between member values and their associated scores | + +## Usage + +<<< ./snippets/zscan.js diff --git a/doc/src/controllers/ms/zscan/snippets/zscan.js b/doc/src/controllers/ms/zscan/snippets/zscan.js new file mode 100644 index 000000000..6e8e7304b --- /dev/null +++ b/doc/src/controllers/ms/zscan/snippets/zscan.js @@ -0,0 +1,16 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // { + // cursor: '0', + // values: [ 'baz', '-272.15', 'bar', '4', 'foo', '42' ] + // } + console.log(await kuzzle.ms.zscan('ssetfoo', 0)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zscan/snippets/zscan.test.yml b/doc/src/controllers/ms/zscan/snippets/zscan.test.yml new file mode 100644 index 000000000..9a58a6608 --- /dev/null +++ b/doc/src/controllers/ms/zscan/snippets/zscan.test.yml @@ -0,0 +1,11 @@ +name: ms#zscan +description: Iterates incrementally over fields contained in a sorted set, using a cursor +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0'," + - "values: \\[ 'baz', '-272.1\\d{1,}', 'bar', '4', 'foo', '42' ] }" +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zscore/index.md b/doc/src/controllers/ms/zscore/index.md new file mode 100644 index 000000000..707d9535f --- /dev/null +++ b/doc/src/controllers/ms/zscore/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zscore +--- + +# zscore + +Returns the score of an element in a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zscore) + +## Arguments + +```js +zscore(key, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the member's score. + +## Usage + +<<< ./snippets/zscore.js diff --git a/doc/src/controllers/ms/zscore/snippets/zscore.js b/doc/src/controllers/ms/zscore/snippets/zscore.js new file mode 100644 index 000000000..6826cd3e1 --- /dev/null +++ b/doc/src/controllers/ms/zscore/snippets/zscore.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 42 + console.log(await kuzzle.ms.zscore('ssetfoo', 'foo')); + + // Prints: 4 + console.log(await kuzzle.ms.zscore('ssetfoo', 'bar')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zscore/snippets/zscore.test.yml b/doc/src/controllers/ms/zscore/snippets/zscore.test.yml new file mode 100644 index 000000000..6cb2d2a1d --- /dev/null +++ b/doc/src/controllers/ms/zscore/snippets/zscore.test.yml @@ -0,0 +1,11 @@ +name: ms#zscore +description: Returns the score of an element in a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^42$ + - ^4$ +sdk: js +version: 6 diff --git a/doc/src/controllers/ms/zunionstore/index.md b/doc/src/controllers/ms/zunionstore/index.md new file mode 100644 index 000000000..fb5e5693c --- /dev/null +++ b/doc/src/controllers/ms/zunionstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: zunionstore +--- + +# zunionstore + +Computes the union of the provided sorted sets, and stores the result in a new sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zunionstore) + +## Arguments + +```js +zunionstore(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------- | +| `dest` |
string
| Target sorted set key | +| `sources` |
string[]
| List of sorted set keys to join | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `aggregate` |
string ("sum")
| Specifies how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `weights` |
integer[]
| List of multiplication factors to apply to sources sets, before aggregation. | + +## Resolve + +Resolves to the number of members added to the destination sorted set. + +## Usage + +<<< ./snippets/zunionstore.js diff --git a/doc/src/controllers/ms/zunionstore/snippets/zunionstore.js b/doc/src/controllers/ms/zunionstore/snippets/zunionstore.js new file mode 100644 index 000000000..327e9bd2f --- /dev/null +++ b/doc/src/controllers/ms/zunionstore/snippets/zunionstore.js @@ -0,0 +1,35 @@ +try { + await kuzzle.ms.zadd('sset1', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'} + ]); + + await kuzzle.ms.zadd('sset2', [ + {member: 'foo', score: '-29'}, + {member: 'baz', score: '300'} + ]); + + // Sums scores of joined values + await kuzzle.ms.zunionstore('destsum', ['sset1', 'sset2']); + + // Stores the minimum possible scores of joined values + await kuzzle.ms.zunionstore( + 'destmin', + ['sset1', 'sset2'], + {aggregate: 'min'} + ); + + // Prints: + // [ { member: 'bar', score: 4 }, + // { member: 'foo', score: 13 }, + // { member: 'baz', score: 300 } ] + console.log(await kuzzle.ms.zrange('destsum', 0, -1)); + + // Prints: + // [ { member: 'foo', score: -29 }, + // { member: 'bar', score: 4 }, + // { member: 'baz', score: 300 } ] + console.log(await kuzzle.ms.zrange('destmin', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/ms/zunionstore/snippets/zunionstore.test.yml b/doc/src/controllers/ms/zunionstore/snippets/zunionstore.test.yml new file mode 100644 index 000000000..e171869cb --- /dev/null +++ b/doc/src/controllers/ms/zunionstore/snippets/zunionstore.test.yml @@ -0,0 +1,15 @@ +name: ms#zunionstore +description: Stores the union of the provided sorted sets +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'bar', score: 4 }," + - " { member: 'foo', score: 13 }," + - " { member: 'baz', score: 300 } ]" + - "\\[ { member: 'foo', score: -29 }," + - " { member: 'bar', score: 4 }," + - " { member: 'baz', score: 300 } ]" +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/count/index.md b/doc/src/controllers/realtime/count/index.md new file mode 100644 index 000000000..6787eb0b2 --- /dev/null +++ b/doc/src/controllers/realtime/count/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: count +description: Count subscribers for a subscription room +--- + +# count + +Returns the number of other connections sharing the same subscription. + +## Arguments + +```javascript +count(roomId, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | -------------------- | +| `roomId` |
string
| Subscription room ID | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Option | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +Resolves to a number represensting active connections using the same provided subscription room. + +## Usage + +<<< ./snippets/count.js diff --git a/doc/src/controllers/realtime/count/snippets/count.js b/doc/src/controllers/realtime/count/snippets/count.js new file mode 100644 index 000000000..f6f305e57 --- /dev/null +++ b/doc/src/controllers/realtime/count/snippets/count.js @@ -0,0 +1,14 @@ +try { + const roomId = await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + {}, + () => {} + ); + + const count = await kuzzle.realtime.count(roomId); + + console.log(`Currently ${count} active subscription`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/realtime/count/snippets/count.test.yml b/doc/src/controllers/realtime/count/snippets/count.test.yml new file mode 100644 index 000000000..b0ba611a2 --- /dev/null +++ b/doc/src/controllers/realtime/count/snippets/count.test.yml @@ -0,0 +1,10 @@ +name: realtime#count +description: Count subscribers for a subscription room +hooks: + before: + after: +template: default +expected: Currently 1 active subscription + +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/index.md b/doc/src/controllers/realtime/index.md new file mode 100644 index 000000000..e1753df1d --- /dev/null +++ b/doc/src/controllers/realtime/index.md @@ -0,0 +1,8 @@ +--- +code: true +type: branch +title: realtime +description: Realtime Controller +--- + +# Realtime Controller diff --git a/doc/src/controllers/realtime/publish/index.md b/doc/src/controllers/realtime/publish/index.md new file mode 100644 index 000000000..0ccc0ced4 --- /dev/null +++ b/doc/src/controllers/realtime/publish/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: publish +description: Publish a real-time message +--- + +# publish + +Sends a real-time message to Kuzzle. The message will be dispatched to all clients with subscriptions matching the index, the collection and the message content. + +The index and collection are indicative and serve only to distinguish the rooms. They are not required to exist in the database + +**Note:** real-time messages are not persisted in the database. + +
+ +```javascript +publish(index, collection, message, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `message` |
object
| Message to send | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Option | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +A boolean indicating if the message was successfully published. + +## Usage + +<<< ./snippets/publish.js diff --git a/doc/src/controllers/realtime/publish/snippets/publish.js b/doc/src/controllers/realtime/publish/snippets/publish.js new file mode 100644 index 000000000..854c5ccb0 --- /dev/null +++ b/doc/src/controllers/realtime/publish/snippets/publish.js @@ -0,0 +1,13 @@ +const message = { realtime: 'rule the web' }; + +try { + await kuzzle.realtime.publish( + 'i-dont-exist', + 'in-database', + message + ); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/realtime/publish/snippets/publish.test.yml b/doc/src/controllers/realtime/publish/snippets/publish.test.yml new file mode 100644 index 000000000..b95fffd27 --- /dev/null +++ b/doc/src/controllers/realtime/publish/snippets/publish.test.yml @@ -0,0 +1,10 @@ +name: realtime#publish +description: Publish a realtime message +hooks: + before: + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/subscribe/index.md b/doc/src/controllers/realtime/subscribe/index.md new file mode 100644 index 000000000..3bf31333d --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/index.md @@ -0,0 +1,64 @@ +--- +code: true +type: page +title: subscribe +description: Subscribe to real-time notifications +--- + +# subscribe + +Subscribes by providing a set of filters: messages, document changes and, optionally, user events matching the provided filters will generate [real-time notifications](/core/1/api/essentials/notifications), sent to you in real-time by Kuzzle. + +
+ +```javascript +subscribe(index, collection, filters, callback, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ------------------- | ------------------------------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `filters` |
object
| Set of filters following [Koncorde syntax](/core/1/koncorde/) | +| `callback` |
function
| Callback function to handle notifications | +| `options` |
object
| Query options | + +### callback + +Callback function that will be called each time a new notifications is received. +The callback will receive the [notifications object](/sdk/js/6/essentials/realtime-notifications/) as only argument. + +### options + +Additional subscription options. + +| Property | Type
(default) | Description | +| ----------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `scope` |
string

(`all`) | Subscribe to document entering or leaving the scope
Possible values: `all`, `in`, `out`, `none` | +| `users` |
string

(`none`) | Subscribe to users entering or leaving the room
Possible values: `all`, `in`, `out`, `none` | +| `subscribeToSelf` |
boolean

(`true`) | Subscribe to notifications fired by our own queries | +| `volatile` |
object

(`null`) | subscription information, used in [user join/leave notifications](/core/1/api/essentials/volatile-data/) | + +## Resolves + +Resolves to a string containing the room ID + +## Usage + +_Simple subscription to document notifications_ + +<<< ./snippets/document-notifications.js + +_Subscription to document notifications with scope option_ + +<<< ./snippets/document-notifications-leave-scope.js + +_Subscription to message notifications_ + +<<< ./snippets/message-notifications.js + +_Subscription to user notifications_ + +<<< ./snippets/user-notifications.js diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js b/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js new file mode 100644 index 000000000..f0eecc0f1 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js @@ -0,0 +1,48 @@ +function callback (notification) { + console.log(notification); + /* + { status: 200, + requestId: 'e114c5d0-8ad1-4751-9236-772f9fea1b19', + timestamp: 1539783948258, + volatile: { sdkVersion: '6.0.0-beta-2' }, + index: 'nyc-open-data', + collection: 'yellow-taxi', + controller: 'document', + action: 'update', + protocol: 'websocket', + scope: 'out', + state: 'done', + result: { _id: 'AWaCRnfbiSV6vMG7iV_K' }, + type: 'document', + room: '638dd7b94b86720e6ac3f0617f26f116-ae85604010d1f5c7' } + */ + console.log(`Document moved ${notification.scope} from the scope`); +} + +try { + // Subscribe to notifications when document leaves the scope + const filters = { range: { age: { lte: 20 } } }; + const options = { scope: 'out' }; + + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filters, + callback, + options + ); + + const document = { name: 'nina vkote', age: 19 }; + + // The document is in the scope + const { _id } = await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + document + ); + + // The document isn't in the scope anymore + await kuzzle.document.update('nyc-open-data', 'yellow-taxi', _id, { age: 42 }); +} catch (error) { + console.log(error.message); +} diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml b/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml new file mode 100644 index 000000000..f4321c129 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml @@ -0,0 +1,10 @@ +name: realtime#subscribe-documents-leave-scope +description: Subscribe to documents leaving the scope +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create ; curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi/ + after: +template: realtime +expected: Document moved out from the scope + +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications.js b/doc/src/controllers/realtime/subscribe/snippets/document-notifications.js new file mode 100644 index 000000000..10e4c4231 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/document-notifications.js @@ -0,0 +1,46 @@ +function callback (notification) { + console.log(notification); + /* + { status: 200, + requestId: '1850b835-d82d-4bce-abec-bf593a578763', + timestamp: 1539680191720, + volatile: { sdkVersion: '6.0.0-beta-2' }, + index: 'nyc-open-data', + collection: 'yellow-taxi', + controller: 'document', + action: 'create', + protocol: 'websocket', + scope: 'in', + result: + { _source: + { name: 'nina vkote', + age: 19, + _kuzzle_info: + { author: '-1', + createdAt: 1539680191720, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } }, + _id: 'AWZ8F0TpJD41ulNI_b-v' }, + type: 'document', + room: '14b675feccf5ac320456ef0dbdf6c1fa-7a90af8c8bdaac1b' } + */ + if (notification.scope === 'in') { + console.log(`Document ${notification.result._source.name} enter the scope`); + } else { + console.log(`Document ${notification.result._source.name} leave the scope`); + } +} + +try { + // Subscribe to notifications for documents containing a 'name' property + const filters = { exists: 'name' }; + + await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filters, callback); + + const document = { name: 'nina vkote', age: 19 }; + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', document); +} catch (error) { + console.log(error.message); +} diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications.test.yml b/doc/src/controllers/realtime/subscribe/snippets/document-notifications.test.yml new file mode 100644 index 000000000..8dde8db25 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/document-notifications.test.yml @@ -0,0 +1,10 @@ +name: realtime#subscribe-documents +description: Simple subscribe to document notifications +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create ; curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi/ + after: +template: realtime +expected: Document nina vkote enter the scope + +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/subscribe/snippets/message-notifications.js b/doc/src/controllers/realtime/subscribe/snippets/message-notifications.js new file mode 100644 index 000000000..677a89c34 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/message-notifications.js @@ -0,0 +1,43 @@ +function callback (notification) { + console.log(notification); + /* + { status: 200, + requestId: '212cc14d-3a4e-4f26-9fe8-6ba6c6279f9d', + timestamp: 1539702246068, + volatile: { sdkVersion: '6.0.0-beta-2' }, + index: 'i-dont-exist', + collection: 'in-database', + controller: 'realtime', + action: 'publish', + protocol: 'websocket', + scope: 'in', + state: 'done', + result: + { _source: + { metAt: 'Insane', + hello: 'world', + _kuzzle_info: + { author: '-1', + createdAt: 1539680191720, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } }, + _id: null }, + type: 'document', + room: '24bbb5c44c343167eaf6a023dca8629e-7a90af8c8bdaac1b' } + */ + console.log('Message notification received'); +} + +try { + // Subscribe to a room + await kuzzle.realtime.subscribe('i-dont-exist', 'in-database', {}, callback); + + // Publish a message to this room + const message = { metAt: 'Insane', hello: 'world' }; + + await kuzzle.realtime.publish('i-dont-exist', 'in-database', message); +} catch (error) { + console.log(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/realtime/subscribe/snippets/message-notifications.test.yml b/doc/src/controllers/realtime/subscribe/snippets/message-notifications.test.yml new file mode 100644 index 000000000..b97305f9c --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/message-notifications.test.yml @@ -0,0 +1,10 @@ +name: realtime#subscribe-messages +description: Subscribe to message notifications +hooks: + before: + after: +template: realtime +expected: Message notification received + +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/subscribe/snippets/user-notifications.js b/doc/src/controllers/realtime/subscribe/snippets/user-notifications.js new file mode 100644 index 000000000..2b9cb8900 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/user-notifications.js @@ -0,0 +1,42 @@ +function callback (notification) { + if (notification.type === 'user') { + console.log(notification.volatile); + /* + { sdkVersion: '', username: 'nina vkote' }, + */ + console.log(`Currently ${notification.result.count} users in the room`); + } +} + +try { + const filters = { exists: 'name' }; + // Subscribe users notifications + const options = { users: 'all' }; + + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filters, + callback, + options + ); + + // Instantiates a second kuzzle client: multiple subscriptions + // made by the same user will not trigger "new user" notifications + const kuzzle2 = new Kuzzle( + new WebSocket('kuzzle') + ); + await kuzzle2.connect(); + + // Subscribe to the same room with the second client + const options2 = { users: 'all', volatile: { username: 'nina vkote' } }; + await kuzzle2.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filters, + () => {}, + options2 + ); +} catch (error) { + console.log(error.message); +} diff --git a/doc/src/controllers/realtime/subscribe/snippets/user-notifications.test.yml b/doc/src/controllers/realtime/subscribe/snippets/user-notifications.test.yml new file mode 100644 index 000000000..c0290cea0 --- /dev/null +++ b/doc/src/controllers/realtime/subscribe/snippets/user-notifications.test.yml @@ -0,0 +1,9 @@ +name: realtime#subscribe-users +description: Subscribe to users joining or leaving the room +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create ; curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi/ + after: +template: realtime +expected: "username: 'nina vkote'" +sdk: js +version: 6 diff --git a/doc/src/controllers/realtime/unsubscribe/index.md b/doc/src/controllers/realtime/unsubscribe/index.md new file mode 100644 index 000000000..b0615854c --- /dev/null +++ b/doc/src/controllers/realtime/unsubscribe/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: unsubscribe +description: Removes a subscription +--- + +# unsubscribe + +Removes a subscription. + +
+ +```javascript +unsubscribe(roomId, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | -------------------- | +| `roomId` |
string
| Subscription room ID | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Option | Type
(default) | Description | +| ---------- | ---------------------------- | --------------------------------- | +| `queuable` |
bool

(`true`) | Make this request queuable or not | + +## Resolves + +Resolves if successfuly unsubscribed. + +## Usage + +<<< ./snippets/unsubscribe.js diff --git a/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.js b/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.js new file mode 100644 index 000000000..d22947501 --- /dev/null +++ b/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.js @@ -0,0 +1,14 @@ +try { + const roomId = await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + {}, + () => {} + ); + + await kuzzle.realtime.unsubscribe(roomId); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml b/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml new file mode 100644 index 000000000..72124fdf9 --- /dev/null +++ b/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml @@ -0,0 +1,10 @@ +name: realtime#unsubscribe +description: Removes a subscription +hooks: + before: + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/controllers/server/admin-exists/index.md b/doc/src/controllers/server/admin-exists/index.md new file mode 100644 index 000000000..76c0cbe0d --- /dev/null +++ b/doc/src/controllers/server/admin-exists/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: adminExists +description: Checks that an administrator account exists. +--- + +# adminExists + +Checks that an administrator account exists. + +
+ +```javascript +adminExists([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a `boolean` set to `true` if an admin exists and `false` if it does not. + +## Usage + +<<< ./snippets/admin-exists.js diff --git a/doc/src/controllers/server/admin-exists/snippets/admin-exists.js b/doc/src/controllers/server/admin-exists/snippets/admin-exists.js new file mode 100644 index 000000000..c9c63df7b --- /dev/null +++ b/doc/src/controllers/server/admin-exists/snippets/admin-exists.js @@ -0,0 +1,7 @@ +try { + const exists = await kuzzle.server.adminExists(); + + console.log('Admin exists?', exists); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/admin-exists/snippets/admin-exists.test.yml b/doc/src/controllers/server/admin-exists/snippets/admin-exists.test.yml new file mode 100644 index 000000000..823029ea2 --- /dev/null +++ b/doc/src/controllers/server/admin-exists/snippets/admin-exists.test.yml @@ -0,0 +1,10 @@ +name: server#adminExists +description: Checks that an administrator account exists. +hooks: + before: + after: +template: default +expected: ^(Admin exists\?) (true|false)$ + +sdk: js +version: 6 diff --git a/doc/src/controllers/server/get-all-stats/index.md b/doc/src/controllers/server/get-all-stats/index.md new file mode 100644 index 000000000..65eb2fd03 --- /dev/null +++ b/doc/src/controllers/server/get-all-stats/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: getAllStats +description: Gets all stored internal statistic snapshots. +--- + +# getAllStats + +Gets all stored internal statistic snapshots. +By default, snapshots are made every 10 seconds and they are stored for 1 hour. + +These statistics include: + +- the number of connected users per protocol (not available for all protocols) +- the number of ongoing requests +- the number of completed requests since the last frame +- the number of failed requests since the last frame + +
+ +```javascript +getAllStats([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing all stored internal statistic snapshots. + +## Usage + +<<< ./snippets/get-all-stats.js diff --git a/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.js b/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.js new file mode 100644 index 000000000..c8448b610 --- /dev/null +++ b/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.js @@ -0,0 +1,7 @@ +try { + const allStats = await kuzzle.server.getAllStats(); + + console.log('All Kuzzle Stats:', JSON.stringify(allStats)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.test.yml b/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.test.yml new file mode 100644 index 000000000..9f3e4c6bf --- /dev/null +++ b/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.test.yml @@ -0,0 +1,10 @@ +name: server#getAllStats +description: Gets all stored internal statistic snapshots. +hooks: + before: + after: +template: default +expected: ^(All Kuzzle Stats:) {"hits":\[({"connections":{.*},"ongoingRequests":{.*},"completedRequests":{}.*},"failedRequests":{.*},"timestamp":[0-9]{13}}(,)*)+\],"total":[0-9]+}$ + +sdk: js +version: 6 diff --git a/doc/src/controllers/server/get-config/index.md b/doc/src/controllers/server/get-config/index.md new file mode 100644 index 000000000..fdcb314fe --- /dev/null +++ b/doc/src/controllers/server/get-config/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: getConfig +description: Returns the current Kuzzle configuration. +--- + +# getConfig + +Returns the current Kuzzle configuration. + +
+ This route should only be accessible to administrators, as it might return sensitive information about the backend. +
+ +
+ +```javascript +getConfig([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing server configuration. + +## Usage + +<<< ./snippets/get-config.js diff --git a/doc/src/controllers/server/get-config/snippets/get-config.js b/doc/src/controllers/server/get-config/snippets/get-config.js new file mode 100644 index 000000000..7a2080fe7 --- /dev/null +++ b/doc/src/controllers/server/get-config/snippets/get-config.js @@ -0,0 +1,7 @@ +try { + const config = await kuzzle.server.getConfig(); + + console.log('Kuzzle Server configuration:', JSON.stringify(config)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/get-config/snippets/get-config.test.yml b/doc/src/controllers/server/get-config/snippets/get-config.test.yml new file mode 100644 index 000000000..9d79d6cfa --- /dev/null +++ b/doc/src/controllers/server/get-config/snippets/get-config.test.yml @@ -0,0 +1,10 @@ +name: server#getConfig +description: Returns the current Kuzzle configuration. +hooks: + before: + after: +template: default +expected: ^(Kuzzle Server configuration:) {("dump":{.*}),("limits":{.*}),("plugins":{.*}),("queues":{.*}),("repositories":{.*}),("server":{.*}),("services":{.*}),("stats":{.*}),("validation":{.*}),("_":.*),("internal":{.*}),("version":"[0-9]\.[0-9]\.[0-9]")}$ + +sdk: js +version: 6 diff --git a/doc/src/controllers/server/get-last-stats/index.md b/doc/src/controllers/server/get-last-stats/index.md new file mode 100644 index 000000000..a60987c80 --- /dev/null +++ b/doc/src/controllers/server/get-last-stats/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: getLastStats +description: Returns the most recent statistics snapshot. +--- + +# getLastStats + +Returns the most recent statistics snapshot. + +By default, snapshots are made every 10 seconds and they are stored for 1 hour. + +These statistics include: + +- the number of connected users per protocol (not available for all protocols) +- the number of ongoing requests +- the number of completed requests since the last frame +- the number of failed requests since the last frame + +
+ +```javascript +getLastStats([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | no | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing the most recent statistics snapshot. + +## Usage + +<<< ./snippets/get-last-stats.js diff --git a/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.js b/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.js new file mode 100644 index 000000000..1fb9ee1ee --- /dev/null +++ b/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.js @@ -0,0 +1,7 @@ +try { + const lastStat = await kuzzle.server.getLastStats(); + + console.log('Last Kuzzle Stats:', JSON.stringify(lastStat)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.test.yml b/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.test.yml new file mode 100644 index 000000000..0e9b5b000 --- /dev/null +++ b/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.test.yml @@ -0,0 +1,10 @@ +name: server#getLastStats +description: Gets all stored internal statistic snapshots. +hooks: + before: + after: +template: default +expected: ^(Last Kuzzle Stats:) {("connections":{.*}),("ongoingRequests":{.*}),("completedRequests":{.*}),("failedRequests":{.*}),("timestamp":[0-9]{13})}$ + +sdk: js +version: 6 diff --git a/doc/src/controllers/server/get-stats/index.md b/doc/src/controllers/server/get-stats/index.md new file mode 100644 index 000000000..53b2a3589 --- /dev/null +++ b/doc/src/controllers/server/get-stats/index.md @@ -0,0 +1,48 @@ +--- +code: true +type: page +title: getStats +description: Returns statistics snapshots within a provided timestamp range. +--- + +# getStats + +Returns statistics snapshots within a provided timestamp range. +By default, snapshots are made every 10 seconds and they are stored for 1 hour. + +These statistics include: + +- the number of connected users per protocol (not available for all protocols) +- the number of ongoing requests +- the number of completed requests since the last frame +- the number of failed requests since the last frame + +
+ +```javascript +getStats(startTime, stopTime, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------------- | --------------------------------------------------------------- | +| `startTime` |
number, string
| Begining of statistics frame set (timestamp or datetime format) | +| `stopTime` |
number, string
| End of statistics frame set (timestamp or datetime format) | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing statistics snapshots within the provided range. + +## Usage + +<<< ./snippets/get-stats.js diff --git a/doc/src/controllers/server/get-stats/snippets/get-stats.js b/doc/src/controllers/server/get-stats/snippets/get-stats.js new file mode 100644 index 000000000..d3fb33fb8 --- /dev/null +++ b/doc/src/controllers/server/get-stats/snippets/get-stats.js @@ -0,0 +1,7 @@ +try { + const stats = await kuzzle.server.getStats('1234567890101', '1541426610304'); + + console.log('Kuzzle Stats:', JSON.stringify(stats)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/get-stats/snippets/get-stats.test.yml b/doc/src/controllers/server/get-stats/snippets/get-stats.test.yml new file mode 100644 index 000000000..80affa74d --- /dev/null +++ b/doc/src/controllers/server/get-stats/snippets/get-stats.test.yml @@ -0,0 +1,10 @@ +name: server#getStats +description: Returns statistics snapshots within a provided timestamp range. +hooks: + before: + after: +template: default +expected: ^(Kuzzle Stats:) {"hits":\[({"connections":{.*},"ongoingRequests":{.*},"completedRequests":{}.*},"failedRequests":{.*},"timestamp":[0-9]{13}}(,)*)*\],"total":[0-9]+}$ + +sdk: js +version: 6 diff --git a/doc/src/controllers/server/index.md b/doc/src/controllers/server/index.md new file mode 100644 index 000000000..8db5d1500 --- /dev/null +++ b/doc/src/controllers/server/index.md @@ -0,0 +1,8 @@ +--- +code: true +type: branch +title: server +description: Server Controller +--- + +# Server Controller diff --git a/doc/src/controllers/server/info/index.md b/doc/src/controllers/server/info/index.md new file mode 100644 index 000000000..68b63400e --- /dev/null +++ b/doc/src/controllers/server/info/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: info +description: Returns information about Kuzzle server. +--- + +# info + +Returns information about Kuzzle: available API (base + extended), plugins, external services (Redis, Elasticsearch, ...), servers, etc. + +
+ +```javascript +info([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing server information. + +## Usage + +<<< ./snippets/info.js diff --git a/doc/src/controllers/server/info/snippets/info.js b/doc/src/controllers/server/info/snippets/info.js new file mode 100644 index 000000000..b59bcbec6 --- /dev/null +++ b/doc/src/controllers/server/info/snippets/info.js @@ -0,0 +1,7 @@ +try { + const serverInfo = await kuzzle.server.info(); + + console.log('Kuzzle Server information:', JSON.stringify(serverInfo)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/info/snippets/info.test.yml b/doc/src/controllers/server/info/snippets/info.test.yml new file mode 100644 index 000000000..f33e1acc7 --- /dev/null +++ b/doc/src/controllers/server/info/snippets/info.test.yml @@ -0,0 +1,9 @@ +name: server##info +description: Retrieves information about Kuzzle plugins and active services. +hooks: + before: + after: +template: default +expected: "^Kuzzle Server information: {\"serverInfo\":{\"kuzzle\":{\"version\":\"[0-9]\\.[0-9]\\.[0-9]\",\"api\":{.*" +sdk: js +version: 6 diff --git a/doc/src/controllers/server/now/index.md b/doc/src/controllers/server/now/index.md new file mode 100644 index 000000000..fd82c7774 --- /dev/null +++ b/doc/src/controllers/server/now/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: now +description: Returns the current server timestamp, in Epoch-millis format. +--- + +# now + +Returns the current server timestamp, in Epoch-millis format. + +
+ +```javascript +now([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a number representing the current server timestamp in Epoch-millis format. + +## Usage + +<<< ./snippets/now.js diff --git a/doc/src/controllers/server/now/snippets/now.js b/doc/src/controllers/server/now/snippets/now.js new file mode 100644 index 000000000..c1c7665ae --- /dev/null +++ b/doc/src/controllers/server/now/snippets/now.js @@ -0,0 +1,7 @@ +try { + const timestamp = await kuzzle.server.now(); + + console.log('Epoch-millis timestamp:', timestamp); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/controllers/server/now/snippets/now.test.yml b/doc/src/controllers/server/now/snippets/now.test.yml new file mode 100644 index 000000000..342cdd0a3 --- /dev/null +++ b/doc/src/controllers/server/now/snippets/now.test.yml @@ -0,0 +1,10 @@ +name: server#now +description: Fetch the current server timestamp, in Epoch-millis format. +hooks: + before: + after: +template: default +expected: ^(Epoch-millis timestamp:) [0-9]{13}$ + +sdk: js +version: 6 diff --git a/doc/src/core-classes/index.md b/doc/src/core-classes/index.md new file mode 100644 index 000000000..bc837b134 --- /dev/null +++ b/doc/src/core-classes/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 100 +title: Core Classes +description: Javascript SDK v6.x core classes +--- diff --git a/doc/src/core-classes/kuzzle-error/index.md b/doc/src/core-classes/kuzzle-error/index.md new file mode 100644 index 000000000..5103a1d24 --- /dev/null +++ b/doc/src/core-classes/kuzzle-error/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: KuzzleError +description: KuzzleError object documentation +order: 510 +--- diff --git a/doc/src/core-classes/kuzzle-error/introduction/index.md b/doc/src/core-classes/kuzzle-error/introduction/index.md new file mode 100644 index 000000000..a53f48e11 --- /dev/null +++ b/doc/src/core-classes/kuzzle-error/introduction/index.md @@ -0,0 +1,23 @@ +--- +code: true +type: page +title: Introduction +description: KuzzleError object +order: 0 +--- + +# KuzzleError + +Inherits from the standard `Error` class. + +The KuzzleError class represents an [error response from Kuzzle API](/core/1/api/essentials/errors/). + +## Properties + +Available properties. + +| Property name | Type | Description | +| ------------- | ----------------- | ------------------------------------------- | +| `message` |
string
| Error message | +| `status` |
number
| Error status code | +| `stack` |
string
| Error stacktrace (only in development mode) | diff --git a/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/index.md b/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/index.md new file mode 100644 index 000000000..290e83a51 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/index.md @@ -0,0 +1,33 @@ +--- +code: true +type: page +title: addOnceListener +description: Adds a new listener for an event +--- + +# addOnceListener + +Adds a **one-time** listener function to an event. +The next time the event is triggered, this listener is removed and then invoked. +Whenever an event is triggered, listener functions are called in the order they were registered. + +## Arguments + +```js +addOnceListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | -------------------------------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call when the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/add-once-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js b/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js new file mode 100644 index 000000000..2f63326c1 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js @@ -0,0 +1,11 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addOnceListener( + 'myEvent', + () => console.log('Caught event "myEvent"!')); + +// Prints: Caught event "myEvent"! +eventEmitter.emit('myEvent'); + +// Prints nothing: the event has since been removed +eventEmitter.emit('myEvent'); diff --git a/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml b/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml new file mode 100644 index 000000000..fe7b777ac --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#add-once-listener +description: Adds new once listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Caught event "myEvent"! +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle-event-emitter/emit/index.md b/doc/src/core-classes/kuzzle-event-emitter/emit/index.md new file mode 100644 index 000000000..41b9b4775 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/emit/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: emit +description: Emits an event +--- + +# emit + +Emits an event with the specified payload. + +## Arguments + +```js +emit(eventName, ...payload); +``` + +
+ +| Argument | Type | Description | +| ----------- | ----------------- | --------------------------------- | +| `eventName` |
string
| The name of the event | +| `payload` |
any
| Payload(s) to send with the event | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/emit.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.js b/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.js new file mode 100644 index 000000000..b70bf929b --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.js @@ -0,0 +1,5 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('helloEvent', msg => console.log(`Hello ${msg}`)); + +eventEmitter.emit('helloEvent', 'World'); diff --git a/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml b/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml new file mode 100644 index 000000000..e2dec6f61 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#emit +description: Emits an event +hooks: + before: + after: +template: eventemitter +expected: Hello World +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle-event-emitter/index.md b/doc/src/core-classes/kuzzle-event-emitter/index.md new file mode 100644 index 000000000..f7b127318 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: KuzzleEventEmitter +description: KuzzleEventEmitter class documentation +order: 510 +--- diff --git a/doc/src/core-classes/kuzzle-event-emitter/introduction/index.md b/doc/src/core-classes/kuzzle-event-emitter/introduction/index.md new file mode 100644 index 000000000..dc2102834 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/introduction/index.md @@ -0,0 +1,18 @@ +--- +code: true +type: page +title: Introduction +description: KuzzleEventEmitter class +order: 0 +--- + +# KuzzleEventEmitter + +A portable implementation of the Node.js `EventEmitter` interface. + +There are several classes extending `KuzzleEventEmitter` in the SDK: + +- [Kuzzle](/sdk/js/6/kuzzle) +- [WebSocket](/sdk/js/6/websocket) +- [Http](/sdk/js/6/http) +- [SocketIO](/sdk/js/6/socketio) diff --git a/doc/src/core-classes/kuzzle-event-emitter/listeners/index.md b/doc/src/core-classes/kuzzle-event-emitter/listeners/index.md new file mode 100644 index 000000000..1455ff4f7 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/listeners/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: listeners +description: Returns listeners for an event +--- + +# listeners + +Returns the listener functions bound to a specific event. + +## Arguments + +```js +listeners(eventName); +``` + +## Return + +An array of listener functions. + +## Usage + +<<< ./snippets/listeners.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js b/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js new file mode 100644 index 000000000..4e5e83699 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js @@ -0,0 +1,8 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('Hello')); +eventEmitter.addListener('myEvent', () => console.log('Hello World')); + +const listeners = eventEmitter.listeners('myEvent'); + +console.log(`There are ${listeners.length} listeners bound to the event "myEvent"`); diff --git a/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml b/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml new file mode 100644 index 000000000..fe978c60d --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#listeners +description: Returns listeners binded to an event +hooks: + before: + after: +template: eventemitter +expected: There are 2 listeners bound to the event "myEvent" +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle-event-emitter/on/index.md b/doc/src/core-classes/kuzzle-event-emitter/on/index.md new file mode 100644 index 000000000..828d20535 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/on/index.md @@ -0,0 +1,10 @@ +--- +code: true +type: page +title: on +description: Alias for addListener +--- + +# on + +Alias for [addListener](/sdk/js/6/core-classes/kuzzle-event-emitteradd-listener/). diff --git a/doc/src/core-classes/kuzzle-event-emitter/once/index.md b/doc/src/core-classes/kuzzle-event-emitter/once/index.md new file mode 100644 index 000000000..79f84e55d --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/once/index.md @@ -0,0 +1,10 @@ +--- +code: true +type: page +title: once +description: Alias for addOnceListener +--- + +# once + +Alias for [addOnceListener](/sdk/js/6/core-classes/kuzzle-event-emitteradd-once-listener/). diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/index.md b/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/index.md new file mode 100644 index 000000000..a36187191 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: prependListener +description: Prepends a new listener for an event +--- + +# prependListener + +Adds a listener function to the beginning of the listeners array for an event. + +## Arguments + +```js +prependListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | -------------------------------------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call every time the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/prepend-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js b/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js new file mode 100644 index 000000000..997536d57 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js @@ -0,0 +1,10 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('listener1')); + +eventEmitter.prependListener('myEvent', () => console.log('listener2')); + +// Prints: +// listener2 +// listener1 +eventEmitter.emit('myEvent'); diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml b/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml new file mode 100644 index 000000000..6bb15910b --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml @@ -0,0 +1,11 @@ +name: kuzzleEventEmitter#prepend-listener +description: Prepends a new listener for the given event +hooks: + before: + after: +template: eventemitter +expected: + - ^listener2$ + - ^listener1$ +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md b/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md new file mode 100644 index 000000000..216d7af60 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md @@ -0,0 +1,32 @@ +--- +code: true +type: page +title: prependOnceListener +description: Prepends a new once listener for an event +--- + +# prependOnceListener + +Adds a **one-time** listener function for an event to the beginning of the listeners array. +The next time that event is triggered, this listener is removed, and then invoked. + +## Arguments + +```js +prependOnceListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | -------------------------------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call when the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/prepend-once-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js b/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js new file mode 100644 index 000000000..479c42e3c --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js @@ -0,0 +1,14 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('listener1')); + +eventEmitter.prependOnceListener('myEvent', () => console.log('listener2')); + +// Prints: +// listener2 +// listener1 +eventEmitter.emit('myEvent'); + +// Prints: listener1 +// (the listener function printing "listener2" as since been removed) +eventEmitter.emit('myEvent'); diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml b/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml new file mode 100644 index 000000000..d329f51ff --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml @@ -0,0 +1,12 @@ +name: kuzzleEventEmitter#prepend-once-listener +description: Prepends an once new listener for the given event +hooks: + before: + after: +template: eventemitter +expected: + - ^listener2$ + - ^listener1$ + - ^listener1$ +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/index.md b/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/index.md new file mode 100644 index 000000000..4f38ff477 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: removeAllListeners +description: Removes all listener functions, or all listener functions from an event +--- + +# removeAllListeners + +Removes all listener functions from an event. +If no eventName is specified, removes all listener functions from all events. + +## Arguments + +```js +removeAllListeners([eventName]); +``` + +
+ +| Argument | Type | Description | +| ----------- | ----------------- | -------------------------- | +| `eventName` |
string
| Optional name of the event | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/remove-all-listeners.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js b/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js new file mode 100644 index 000000000..00154de84 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js @@ -0,0 +1,18 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent" (1)')); +eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent" (2)')); + +// Prints: +// Caught event "myEvent" (1) +// Caught event "myEvent" (2) +eventEmitter.emit('myEvent'); + +eventEmitter.removeAllListeners('myEvent'); + +// Prints nothing: all events have been removed +eventEmitter.emit('myEvent'); + +if (eventEmitter.listeners('myEvent').length === 0) { + console.log('Successfully removed all listeners'); +} diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml b/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml new file mode 100644 index 000000000..043d330e0 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#remove-all-listeners +description: Removes a listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Successfully removed all listeners +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-listener/index.md b/doc/src/core-classes/kuzzle-event-emitter/remove-listener/index.md new file mode 100644 index 000000000..7b58fc659 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/remove-listener/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: removeListener +description: Removes a listener function from an event +--- + +# removeListener + +Removes a listener function from an event. + +## Arguments + +```js +removeListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | --------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Callback to remove | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/remove-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js b/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js new file mode 100644 index 000000000..8c7276211 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js @@ -0,0 +1,13 @@ +const eventEmitter = new KuzzleEventEmitter(); + +const listener = () => console.log('disconnected'); + +eventEmitter + .addListener('disconnected', () => console.log('disconnected')) + .addListener('disconnected', listener); + +eventEmitter.removeListener('disconnected', listener); + +if (eventEmitter.listeners('disconnected').length === 1) { + console.log('Successfully removed the listener'); +} diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml b/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml new file mode 100644 index 000000000..d50965568 --- /dev/null +++ b/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#remove-listener +description: Removes a listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Successfully removed the listener +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/add-listener/index.md b/doc/src/core-classes/kuzzle/add-listener/index.md new file mode 100644 index 000000000..9c14a22a7 --- /dev/null +++ b/doc/src/core-classes/kuzzle/add-listener/index.md @@ -0,0 +1,32 @@ +--- +code: true +type: page +title: addListener +description: Add a listener to an event +--- + +# addListener + +Adds a listener function to the end of the listeners array for an event. +Whenever an event is triggered, listener functions are called in the order they were registered. + +## Arguments + +```javascript +addListener(event, callback); +``` + +
+ +| Argument | Type | Description | +| ---------- | ------------------- | ------------------------------------------------------------------------------------------ | +| `event` |
string
| One of the event described in the [Events](/sdk/js/6/events) section of this documentation | +| `callback` |
function
| The function to call every time the event is triggered | + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/add-listener.js diff --git a/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.js b/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.js new file mode 100644 index 000000000..925da4259 --- /dev/null +++ b/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.js @@ -0,0 +1,9 @@ +try { + kuzzle + .addListener('connected', () => console.log('You are connected')) + .addListener('connected', () => console.log('I already told you')); + + console.log('Success'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml b/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml new file mode 100644 index 000000000..2ba3a0a70 --- /dev/null +++ b/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#addListener +description: Add a listener to an event +hooks: + before: + after: +template: without-connect +expected: Success + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/connect/index.md b/doc/src/core-classes/kuzzle/connect/index.md new file mode 100644 index 000000000..48e0a8fcb --- /dev/null +++ b/doc/src/core-classes/kuzzle/connect/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: connect +description: Connects the SDK to Kuzzle +--- + +# connect + +Connects to Kuzzle using the `host` property provided in the [constructor options](/sdk/js/6/core-classes/kuzzle/constructor/#arguments-default). +Subsequent call have no effect if the SDK is already connected. + +## Arguments + +```javascript +connect(); +``` + +## Resolves + +Resolves if the connection is successful. + +## Usage + +<<< ./snippets/connect.js diff --git a/doc/src/core-classes/kuzzle/connect/snippets/connect.js b/doc/src/core-classes/kuzzle/connect/snippets/connect.js new file mode 100644 index 000000000..6a12ea0c1 --- /dev/null +++ b/doc/src/core-classes/kuzzle/connect/snippets/connect.js @@ -0,0 +1,7 @@ +try { + await kuzzle.connect(); + + console.log('Successfully connected'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/core-classes/kuzzle/connect/snippets/connect.test.yml b/doc/src/core-classes/kuzzle/connect/snippets/connect.test.yml new file mode 100644 index 000000000..e904c4c4a --- /dev/null +++ b/doc/src/core-classes/kuzzle/connect/snippets/connect.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#connect +description: Connects the SDK to Kuzzle +hooks: + before: + after: +template: without-connect +expected: Successfully connected + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/constructor/index.md b/doc/src/core-classes/kuzzle/constructor/index.md new file mode 100644 index 000000000..93a5dcf13 --- /dev/null +++ b/doc/src/core-classes/kuzzle/constructor/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: Constructor +description: Creates a new Kuzzle object connected to the backend +order: 50 +--- + +# Constructor + +Use this constructor to create a new instance of the SDK. +Each instance represent a different connection to a Kuzzle server with specific options. + +## Arguments + +```javascript +Kuzzle(protocol, [options]); +``` + +
+ +| Argument | Type | Description | +| ---------- | ------------------- | --------------------------------- | +| `protocol` |
Protocol
| Protocol used by the SDK instance | +| `options` |
object
| Kuzzle object configuration | + +### protocol + +The protocol used to connect to the Kuzzle instance. +It can be one of the following available protocols: + +- [WebSocket](/sdk/js/6/websocket) +- [Http](/sdk/js/6/http) +- [SocketIO](/sdk/js/6/socketio) + +### options + +Kuzzle SDK instance options. + +| Property | Type
(default) | Description | +| ----------------- | -------------------------------- | ------------------------------------------------------------------ | +| `autoQueue` |
boolean

(`false`) | Automatically queue all requests during offline mode | +| `autoReplay` |
boolean

(`false`) | Automatically replay queued requests on a `reconnected` event | +| `autoResubscribe` |
boolean

(`true`) | Automatically renew all subscriptions on a `reconnected` event | +| `eventTimeout` |
number

(`200`) | Time (in ms) during which a similar event is ignored | +| `offlineMode` |
string

(`manual`) | Offline mode configuration. Can be `manual` or `auto` | +| `queueTTL` |
number

(`120000`) | Time a queued request is kept during offline mode, in milliseconds | +| `queueMaxSize` |
number

(`500`) | Number of maximum requests kept during offline mode | +| `replayInterval` |
number

(`10`) | Delay between each replayed requests, in milliseconds | +| `volatile` |
object

(`{}`) | Common volatile data, will be sent to all future requests | + +## Return + +The `Kuzzle` SDK instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/src/core-classes/kuzzle/constructor/snippets/constructor.js b/doc/src/core-classes/kuzzle/constructor/snippets/constructor.js new file mode 100644 index 000000000..f362d01c3 --- /dev/null +++ b/doc/src/core-classes/kuzzle/constructor/snippets/constructor.js @@ -0,0 +1,25 @@ +// Loads the Kuzzle SDK module +const + { + Kuzzle, + WebSocket, + Http + } = require('kuzzle-sdk'); + +const options = { + offlineMode: 'auto', + volatile: { username: 'Gordon' } +}; + +// Instantiates the SDK with the websocket protocol +const + kuzzleWs = new Kuzzle( + new WebSocket('kuzzle'), + options + ); + +// Instantiates the SDK with the http protocol +const + kuzzleHttp = new Kuzzle( + new Http('kuzzle') + ); diff --git a/doc/src/core-classes/kuzzle/constructor/snippets/constructor.test.yml b/doc/src/core-classes/kuzzle/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..2a43f0463 --- /dev/null +++ b/doc/src/core-classes/kuzzle/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: kuzzle#constructor +description: Creates a new Kuzzle instance connected to kuzzle +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/disconnect/index.md b/doc/src/core-classes/kuzzle/disconnect/index.md new file mode 100644 index 000000000..594aa0faa --- /dev/null +++ b/doc/src/core-classes/kuzzle/disconnect/index.md @@ -0,0 +1,22 @@ +--- +code: true +type: page +title: disconnect +description: Disconnect the SDK +--- + +# disconnect + +Closes the current connection to Kuzzle. +The SDK then enters the `offline` state. +A call to `disconnect()` will not trigger a `disconnected` event. This event is only triggered on unexpected disconnection. + +## Arguments + +```javascript +disconnect(); +``` + +## Usage + +<<< ./snippets/disconnect.js diff --git a/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.js b/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.js new file mode 100644 index 000000000..e3c9244e6 --- /dev/null +++ b/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.js @@ -0,0 +1,7 @@ +try { + kuzzle.disconnect(); + + console.log('Successfully disconnected'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml b/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml new file mode 100644 index 000000000..275657be6 --- /dev/null +++ b/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#disconnect +description: Disconnects the SDK +hooks: + before: + after: +template: without-connect +expected: Successfully disconnected + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/flush-queue/index.md b/doc/src/core-classes/kuzzle/flush-queue/index.md new file mode 100644 index 000000000..e2ecad867 --- /dev/null +++ b/doc/src/core-classes/kuzzle/flush-queue/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: flushQueue +description: Empties the offline request queue +--- + +# flushQueue + +Empties the offline request queue without playing it. + +## Arguments + +```javascript +flushQueue(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/flush-queue.js diff --git a/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.js b/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.js new file mode 100644 index 000000000..1ce69b412 --- /dev/null +++ b/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.js @@ -0,0 +1,7 @@ +try { + kuzzle.flushQueue(); + + console.log('Offline queue flushed'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml b/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml new file mode 100644 index 000000000..704e7e084 --- /dev/null +++ b/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#flushQueue +description: Empties the offline request queue +hooks: + before: + after: +template: without-connect +expected: Offline queue flushed + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/index.md b/doc/src/core-classes/kuzzle/index.md new file mode 100644 index 000000000..83d60da5d --- /dev/null +++ b/doc/src/core-classes/kuzzle/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Kuzzle +description: Kuzzle object documentation +order: 500 +--- diff --git a/doc/src/core-classes/kuzzle/introduction/index.md b/doc/src/core-classes/kuzzle/introduction/index.md new file mode 100644 index 000000000..1df558d3b --- /dev/null +++ b/doc/src/core-classes/kuzzle/introduction/index.md @@ -0,0 +1,103 @@ +--- +code: true +type: page +title: Introduction +description: Kuzzle object +order: 0 +--- + +# Kuzzle + +Inherits from: [KuzzleEventEmitter](/sdk/js/6/kuzzle-event-emitter). + +The Kuzzle class is the main class of the SDK. +Once instantiated, it represents a connection to your Kuzzle server. + +It gives access to the different features of the SDKs: + +- access to the available controllers +- [SDK events](/sdk/cpp/1/events) handling +- resilience to connection loss +- network request queue management + +## Network protocol + +Each instance of the class communicates with the Kuzzle server through a class representing a network protocol implementation. + +The following protocols are available in the SDK JS 6: + +- [WebSocket](/sdk/js/6/websocket) +- [Http](/sdk/js/6/http) +- [SocketIO](/sdk/js/6/socketio) + +## Volatile data + +You can tell the Kuzzle SDK to attach a set of "volatile" data to each request. You can set it as an object contained in the `volatile` field of the Kuzzle constructor. The response to a request containing volatile data will contain the same data in its `volatile` field. This can be useful, for example, in real-time notifications for [user join/leave notifications](/core/1/api/essentials/volatile-data/) to provide additional informations about the client who sent the request. + +Note that you can also set volatile data on a per-request basis (on requests that accept a `volatile` field in their `options` argument). In this case, per-request volatile data will be merged with the global `volatile` object set in the constructor. Per-request fields will override global ones. + +## Properties + +Available properties. + +| Property name | Type | Description | Writable? | +| -------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------- | :-------: | +| `autoQueue` |
boolean
| Automatically queue all requests during offline mode | Yes | +| `autoReplay` |
boolean
| Automatically replay queued requests on a `reconnected` event | Yes | +| `autoResubscribe` |
boolean
| Automatically renew all subscriptions on a `reconnected` event | Yes | +| `jwt` |
string
| Token used in requests for authentication | Yes | +| `offlineQueue` |
object[]
| Contains the queued requests during offline mode | No | +| `offlineQueueLoader` |
function
| Called before dequeuing requests after exiting offline mode,
to add items at the beginning of the offline queue | Yes | +| `protocol` |
Protocol
| Protocol used by the SDK | No | +| `queueFilter` |
function
| Called during offline mode.
Takes a request object as arguments and returns a boolean, indicating if a request can be queued | Yes | +| `queueMaxSize` |
number
| Number of maximum requests kept during offline mode | Yes | +| `queueTTL` |
number
| Time a queued request is kept during offline mode, in milliseconds | Yes | +| `replayInterval` |
number
| Delay between each replayed requests | Yes | +| `volatile` |
object
| Common volatile data, will be sent to all future requests | Yes | + +### offlineQueueLoader + +The `offlineQueueLoader` property must be set with a function of one of the following formats: + +```js +Object[] offlineQueueLoader() + +Promise offlineQueueLoader() +``` + +The returned (or resolved) array must contain objects, each with the following properties: + +| Property | Type | Description | +| --------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | +| `query` |
object
| Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format | +| `reject` |
function
| A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function | +| `resolve` |
function
| A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function | + +### queueFilter + +The `queueFilter` property must be set with a function of the following form: + +```js +boolean queueFilter(request) +``` + +The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format. + +### queueMaxSize + +This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue. + +This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests. + +If `queueMaxSize` is set to a number lower than, or equal to `0`, then an unlimited number of requests is kept in the offline buffer. +Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory. + +### queueTTL + +If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely. + +### volatile + +Multiple methods allow passing specific `volatile` data. + +These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones. diff --git a/doc/src/core-classes/kuzzle/play-queue/index.md b/doc/src/core-classes/kuzzle/play-queue/index.md new file mode 100644 index 000000000..62296de57 --- /dev/null +++ b/doc/src/core-classes/kuzzle/play-queue/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: playQueue +description: Play the offline request queue +--- + +# playQueue + +Plays the requests queued during `offline` state. +Works only if the SDK is not in a `offline` state, and if the `autoReplay` option is set to `false`. + +## Arguments + +```javascript +playQueue(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/play-queue.js diff --git a/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.js b/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.js new file mode 100644 index 000000000..463d99a18 --- /dev/null +++ b/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.js @@ -0,0 +1,7 @@ +try { + kuzzle.playQueue(); + + console.log('Start playing offline queue'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml b/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml new file mode 100644 index 000000000..a3507d292 --- /dev/null +++ b/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#playQueue +description: Play the requests queued +hooks: + before: + after: +template: without-connect +expected: Start playing offline queue + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/query/index.md b/doc/src/core-classes/kuzzle/query/index.md new file mode 100644 index 000000000..1c5885fae --- /dev/null +++ b/doc/src/core-classes/kuzzle/query/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: query +description: Base method to send API query to Kuzzle +--- + +# query + +Base method used to send queries to Kuzzle, following the [API Documentation](/core/1/api). + +
+This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods. +
+ +## Arguments + +```javascript +query(request, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------- | +| `request` |
object
| API request options | +| `options` |
object
| Optional query options | + +### request + +All properties necessary for the Kuzzle API can be added in the request object. +The following properties are the most common. + +| Property | Type | Description | +| ------------ | ----------------- | ---------------------------------------- | +| `controller` |
string
| Controller name (mandatory) | +| `action` |
string
| Action name (mandatory) | +| `body` |
object
| Query body for this action | +| `index` |
string
| Index name for this action | +| `collection` |
string
| Collection name for this action | +| `_id` |
string
| id for this action | +| `volatile` |
object
| Additional information to send to Kuzzle | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +Resolve to the raw Kuzzle API response. See the [API Documentation](/core/1/api). + +## Usage + +<<< ./snippets/query.js diff --git a/doc/src/core-classes/kuzzle/query/snippets/query.js b/doc/src/core-classes/kuzzle/query/snippets/query.js new file mode 100644 index 000000000..e06d967f5 --- /dev/null +++ b/doc/src/core-classes/kuzzle/query/snippets/query.js @@ -0,0 +1,50 @@ +const request = { + controller: 'document', + action: 'create', + index: 'nyc-open-data', + collection: 'yellow-taxi', + _id: 'my-custom-document-id', + refresh: 'wait_for', // Additional property allowed for this API action + body: { + trip_distance: 4.23, + passenger_count: 2 + } +}; + +try { + const response = await kuzzle.query(request); + console.log(response); + /* + { requestId: '49ffb6db-bdff-45b9-b3f6-00442f472393', + status: 200, + error: null, + controller: 'document', + action: 'create', + collection: 'yellow-taxi', + index: 'nyc-open-data', + volatile: { sdkVersion: '6.0.0-beta-2' }, + room: '49ffb6db-bdff-45b9-b3f6-00442f472393', + result: + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'my-custom-document-id', + _version: 1, + result: 'created', + _shards: { total: 2, successful: 1, failed: 0 }, + created: true, + _source: + { trip_distance: 4.23, + passenger_count: 2, + _kuzzle_info: + { author: '-1', + createdAt: 1532529302225, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } } + */ + + console.log('Document created'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/query/snippets/query.test.yml b/doc/src/core-classes/kuzzle/query/snippets/query.test.yml new file mode 100644 index 000000000..0b5358454 --- /dev/null +++ b/doc/src/core-classes/kuzzle/query/snippets/query.test.yml @@ -0,0 +1,14 @@ +--- +name: kuzzle#query +description: Sends a request to Kuzzle API +hooks: + before: | + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -X DELETE kuzzle:7512/nyc-open-data/yellow-taxi/my-custom-document-id + after: +template: default +expected: Document created + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/start-queuing/index.md b/doc/src/core-classes/kuzzle/start-queuing/index.md new file mode 100644 index 000000000..b8643668a --- /dev/null +++ b/doc/src/core-classes/kuzzle/start-queuing/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: startQueuing +description: Starts the requests queuing +--- + +# startQueuing + +Starts the requests queuing. +Works only in `offline` state, and if the `autoQueue` option is set to false. + +## Arguments + +```javascript +startQueuing(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/start-queuing.js diff --git a/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.js b/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.js new file mode 100644 index 000000000..787e2518b --- /dev/null +++ b/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.js @@ -0,0 +1,7 @@ +try { + kuzzle.startQueuing(); + + console.log('Start queuing requests'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml b/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml new file mode 100644 index 000000000..914f4ac01 --- /dev/null +++ b/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#startQueuing +description: Starts the requests queuing +hooks: + before: + after: +template: without-connect +expected: Start queuing requests + +sdk: js +version: 6 diff --git a/doc/src/core-classes/kuzzle/stop-queuing/index.md b/doc/src/core-classes/kuzzle/stop-queuing/index.md new file mode 100644 index 000000000..b067de427 --- /dev/null +++ b/doc/src/core-classes/kuzzle/stop-queuing/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: stopQueuing +description: Stops the requests queuing +--- + +# stopQueuing + +Stops the requests queuing. +Works only in `offline` state, and if the `autoQueue` option is set to false. + +## Arguments + +```javascript +stopQueuing(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/stop-queuing.js diff --git a/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js b/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js new file mode 100644 index 000000000..782278ef6 --- /dev/null +++ b/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js @@ -0,0 +1,7 @@ +try { + kuzzle.stopQueuing(); + + console.log('Stop queuing requests'); +} catch (error) { + console.error(error); +} diff --git a/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml b/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml new file mode 100644 index 000000000..d0709b139 --- /dev/null +++ b/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#stopQueuing +description: Stops the requests queuing +hooks: + before: + after: +template: without-connect +expected: Stop queuing requests + +sdk: js +version: 6 diff --git a/doc/src/core-classes/profile/getRoles/index.md b/doc/src/core-classes/profile/getRoles/index.md new file mode 100644 index 000000000..a091c0a32 --- /dev/null +++ b/doc/src/core-classes/profile/getRoles/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: getRoles +description: Profile getRoles method +--- + +# getRoles + +Loads information about the profile roles. + +## Arguments + +```js +getRoles(); +``` + +## Resolve + +Resolves to an array of [Role](/sdk/js/6/role). + +## Usage + +<<< ./snippets/getRoles.js diff --git a/doc/src/core-classes/profile/getRoles/snippets/getRoles.js b/doc/src/core-classes/profile/getRoles/snippets/getRoles.js new file mode 100644 index 000000000..5ded07431 --- /dev/null +++ b/doc/src/core-classes/profile/getRoles/snippets/getRoles.js @@ -0,0 +1,28 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.getCurrentUser(); + + const profiles = await user.getProfiles(); + + const roles = await profiles[0].getRoles(); + console.log(roles); + /* + [ + Role { + _id: 'default', + controllers: { + '*': { + actions: { + '*': true + } + } + } + } + ] + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/core-classes/profile/getRoles/snippets/getRoles.test.yml b/doc/src/core-classes/profile/getRoles/snippets/getRoles.test.yml new file mode 100644 index 000000000..0ddd2c4b4 --- /dev/null +++ b/doc/src/core-classes/profile/getRoles/snippets/getRoles.test.yml @@ -0,0 +1,12 @@ +name: user#getRoles +description: Loads informations about user roles +hooks: + before: | + curl -X DELETE kuzzle:7512/users/foo + curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: +template: default +expected: + - Profile { _id: \'default\' +sdk: js +version: 6 diff --git a/doc/src/core-classes/profile/index.md b/doc/src/core-classes/profile/index.md new file mode 100644 index 000000000..ba2bda51a --- /dev/null +++ b/doc/src/core-classes/profile/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Profile +description: Profile class documentation +order: 510 +--- diff --git a/doc/src/core-classes/profile/introduction/index.md b/doc/src/core-classes/profile/introduction/index.md new file mode 100644 index 000000000..27319490e --- /dev/null +++ b/doc/src/core-classes/profile/introduction/index.md @@ -0,0 +1,29 @@ +--- +code: true +type: page +title: Introduction +description: Profile class +order: 0 +--- + +# Profile + +This class represents a Kuzzle Profile. + +Refer to the [Security guide](/core/1/guide/guides/essentials/security/#defining-profiles-default) for more information about profiles. + +## Properties + +Available properties: + +| Property | Type | Description | +| ---------- | ------------------- | ---------------------------------- | +| `_id` |
string
| Profile ID | +| `policies` |
object[]
| Array of policies for this profile | + +Each policy object can contain the following properties: + +| Property | Type | Description | +| -------------- | ------------------- | ------------------------------------------------------------------------------------- | +| `roleId` |
string
| Roles IDs for this user | +| `restrictedTo` |
object[]
| Array of object containing indexes and collections which the profile is restricted to | diff --git a/doc/src/core-classes/role/index.md b/doc/src/core-classes/role/index.md new file mode 100644 index 000000000..25fb73bea --- /dev/null +++ b/doc/src/core-classes/role/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Role +description: Role class documentation +order: 510 +--- diff --git a/doc/src/core-classes/role/introduction/index.md b/doc/src/core-classes/role/introduction/index.md new file mode 100644 index 000000000..0ac949f4d --- /dev/null +++ b/doc/src/core-classes/role/introduction/index.md @@ -0,0 +1,22 @@ +--- +code: true +type: page +title: Introduction +description: Role class +order: 0 +--- + +# Role + +This class represents a Kuzzle Role. + +Refer to the [Security guide](/core/1/guide/guides/essentials/security/#defining-roles-default) for more information about roles. + +## Properties + +Available properties: + +| Property | Type | Description | +| ------------- | ----------------- | ---------------------------------------------------------- | +| `_id` |
string
| Role ID | +| `controllers` |
object
| Object defining controllers action available for this role | diff --git a/doc/src/core-classes/search-result/index.md b/doc/src/core-classes/search-result/index.md new file mode 100644 index 000000000..5e822dcbe --- /dev/null +++ b/doc/src/core-classes/search-result/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: SearchResult +description: SearchResult class documentation +order: 510 +--- diff --git a/doc/src/core-classes/search-result/introduction/index.md b/doc/src/core-classes/search-result/introduction/index.md new file mode 100644 index 000000000..01fef966f --- /dev/null +++ b/doc/src/core-classes/search-result/introduction/index.md @@ -0,0 +1,35 @@ +--- +code: true +type: page +title: Introduction +description: SearchResult class +order: 0 +--- + +# SearchResult + +The class is used to retrieve the subsequent paginated results of a search query. +The following methods returns a `SearchResult`: + +- [document:search](/sdk/js/6/controllers/document/search) +- [collection:searchSpecifications](/sdk/js/6/collection/search-specifications) + +## Properties + +Available properties. + +| Property | Type | Description | +| -------------- | ------------------- | ----------------------------------------------------------------- | +| `aggregations` |
object
| Search aggregations if any | +| `hits` |
object[]
| Array containing the retrieved items for the current page | +| `total` |
number
| Total number of items matching the given query in Kuzzle database | +| `fetched` |
number
| Number of retrieved items so far | +| `scroll_id` |
string
| Scroll identifier if the search was given a `scroll` parameter | + +Each object of the `hits` array contain the following properties: + +| Property | Type | Description | +| --------- | ----------------- | --------------------------------------------------------------------------------------------------- | +| `_id` |
string
| Document ID | +| `_score` |
number
| [Relevance score](https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html) | +| `_source` |
object
| Document content | diff --git a/doc/src/core-classes/search-result/next/index.md b/doc/src/core-classes/search-result/next/index.md new file mode 100644 index 000000000..34ae4afb1 --- /dev/null +++ b/doc/src/core-classes/search-result/next/index.md @@ -0,0 +1,67 @@ +--- +code: true +type: page +title: next +description: SearchResult next method +--- + +# SearchResult + +Returns a new `SearchResult` object which contain the subsequent results of the search. + +## Arguments + +```js +next(); +``` + +## Behaviour of the next method + +In order to be able to compute the next search page, some initial conditions must be met. + +Depending on the arguments given to the initial search, thhe `next` method will pick one of the following policies, by decreasing order of priority (i.e. a search including a `scroll`, `sort` and `size` will use the `scroll` policy). + +If no policy is applicable, the `next` method will throw an exception. + +
+

+ When processing a large number of documents (i.e. more than 1000), it is advised to use a scroll cursor. +

+

+ It is also the only method that garantees all matching documents will be retrieved and no duplicates will be included. +

+
+ +## Usage with scroll + +**This is the preferred way to get some paginated results**. + +If the original search is given a `scroll` parameter, the `next` method will use a cursor to paginate results. + +The results that are returned from a scroll request reflect the state of the index at the time the initial `search` request was performed, like a snapshot in time. + +As such, even if some documents are added or deleted from the database between two calls to `next`, the result is garanteed to include all items matching the query at the time the initial `search` was sent and to not get any duplicate between two search pages. + +<<< ./snippets/scroll.js + +## Usage with sort / size + +If the initial search is given some `sort` and `size` parameters, the `next` method will retrieve the next items matching the sort. + +To avoid too many duplicates, it is advised to provide a sort combination that will always identify one item only. The recommended way is to use the field `_uid` which is certain to contain one unique value for each document. + +Because this method does not freeze the research between two calls, if some updates are applied to the database between two calls, it is still possible to miss some documents and/or to get some duplicates between search pages. + +## Usage with from / size + +If the initial search is given some `from` and `size` parameters, the `next` method will increment the `from` parameter to retrieved the next results. + +Because this method does not freeze the research between two calls, if some updates are applied to the database between two calls, it is possible to miss some documents and/or to get some duplicates between search pages. + +
+

+ NB: It is not possible to retrieve more than 10000 items using this method. Above that limit, any call to next will throw an Exception. +

+
+ +<<< ./snippets/fromsize.js diff --git a/doc/src/core-classes/search-result/next/snippets/fromsize.js b/doc/src/core-classes/search-result/next/snippets/fromsize.js new file mode 100644 index 000000000..74fb61abe --- /dev/null +++ b/doc/src/core-classes/search-result/next/snippets/fromsize.js @@ -0,0 +1,69 @@ +const suv = { category: 'suv' }; + +try { + const requests = []; + + for (let i = 0; i < 10; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); + } + + await Promise.all(requests); + + // Waits documents to be indexed + await kuzzle.index.refresh('nyc-open-data'); + + const searchOptions = { + from: 1, + size: 5 + }; + + const results = await kuzzle.document.search( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + category: 'suv' + } + } + }, + searchOptions + ); + + const nextResults = await results.next(); + + console.log(`Successfully retrieved ${nextResults.fetched} documents`); + console.log(nextResults); + /* + { + "aggregations": undefined, + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "AWgi6A1POQUM6ucJ3q06", + "_score": 0.046520017, + "_source": { + "category": "suv", + "_kuzzle_info": { + "author": "-1", + "createdAt": 1546773859655, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + ... + ] + }, + "total": 10, + "fetched": 10, + "scroll_id": undefined, + "from": 1, + "size": 5 + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/core-classes/search-result/next/snippets/fromsize.test.yml b/doc/src/core-classes/search-result/next/snippets/fromsize.test.yml new file mode 100644 index 000000000..b23305a90 --- /dev/null +++ b/doc/src/core-classes/search-result/next/snippets/fromsize.test.yml @@ -0,0 +1,13 @@ +name: searchresult#fromsize +description: Next method with from/size +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully retrieved 10 documents +sdk: js +version: 6 diff --git a/doc/src/core-classes/search-result/next/snippets/scroll.js b/doc/src/core-classes/search-result/next/snippets/scroll.js new file mode 100644 index 000000000..c2e4f83ac --- /dev/null +++ b/doc/src/core-classes/search-result/next/snippets/scroll.js @@ -0,0 +1,74 @@ +const suv = { category: 'suv' }; + +try { + const requests = []; + + for (let i = 0; i < 10; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); + } + + await Promise.all(requests); + + // Waits documents to be indexed + await kuzzle.index.refresh('nyc-open-data'); + + const searchOptions = { + scroll: '1m', + size: 5 + }; + + let results = await kuzzle.document.search( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + category: 'suv' + } + } + }, + searchOptions + ); + + // Fetch the next fetch results and push them into the 'documents' array + const documents = []; + + while (results) { + results.hits.forEach(hit => documents.push(hit._source)); + results = await results.next(); + } + + console.log(results); + /* + { + "aggregations": undefined, + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "AWgi6A1POQUM6ucJ3q06", + "_score": 0.046520017, + "_source": { + "category": "suv", + "_kuzzle_info": { + "author": "-1", + "createdAt": 1546773859655, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + ... + ] + }, + "total": 10, + "fetched": 10, + "scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAAqFnQ5NU9sZWFaUTRhd2VHNU5KZzVEQ" + */ + + console.log(`Successfully retrieved ${documents.length} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/core-classes/search-result/next/snippets/scroll.test.yml b/doc/src/core-classes/search-result/next/snippets/scroll.test.yml new file mode 100644 index 000000000..6daa0f360 --- /dev/null +++ b/doc/src/core-classes/search-result/next/snippets/scroll.test.yml @@ -0,0 +1,13 @@ +name: searchresult#scroll +description: Next method with scroll +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully retrieved 10 documents +sdk: js +version: 6 diff --git a/doc/src/core-classes/user/getProfiles/index.md b/doc/src/core-classes/user/getProfiles/index.md new file mode 100644 index 000000000..cb837c20c --- /dev/null +++ b/doc/src/core-classes/user/getProfiles/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: getProfiles +description: User getProfiles method +--- + +# getProfiles + +Loads information about the user profiles. + +## Arguments + +```js +getProfiles(); +``` + +## Resolve + +Resolves to an array of [Profile](/sdk/js/6/profile). + +## Usage + +<<< ./snippets/getProfiles.js diff --git a/doc/src/core-classes/user/getProfiles/snippets/getProfiles.js b/doc/src/core-classes/user/getProfiles/snippets/getProfiles.js new file mode 100644 index 000000000..e21000022 --- /dev/null +++ b/doc/src/core-classes/user/getProfiles/snippets/getProfiles.js @@ -0,0 +1,24 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.getCurrentUser(); + + const profiles = await user.getProfiles(); + console.log(profiles); + /* + [ + Profile { + _id: 'default', + policies: [ + { + roleId: 'default' + } + ] + } + ] + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/src/core-classes/user/getProfiles/snippets/getProfiles.test.yml b/doc/src/core-classes/user/getProfiles/snippets/getProfiles.test.yml new file mode 100644 index 000000000..f23afa975 --- /dev/null +++ b/doc/src/core-classes/user/getProfiles/snippets/getProfiles.test.yml @@ -0,0 +1,12 @@ +name: user#getProfiles +description: Loads informations about user profiles +hooks: + before: | + curl -X DELETE kuzzle:7512/users/foo + curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: +template: default +expected: + - Role { _id: \'default\' +sdk: js +version: 6 diff --git a/doc/src/core-classes/user/index.md b/doc/src/core-classes/user/index.md new file mode 100644 index 000000000..f5b765f27 --- /dev/null +++ b/doc/src/core-classes/user/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: User +description: User class documentation +order: 510 +--- diff --git a/doc/src/core-classes/user/introduction/index.md b/doc/src/core-classes/user/introduction/index.md new file mode 100644 index 000000000..efe42528b --- /dev/null +++ b/doc/src/core-classes/user/introduction/index.md @@ -0,0 +1,34 @@ +--- +code: true +type: page +title: Introduction +description: User class +order: 0 +--- + +# User + +This class represents a Kuzzle User. + +Refer to the [Security guide](/core/1/guide/guides/essentials/security/) for more information about users. + +The following methods return a `User` object: + +- [auth:getCurrentUser](/sdk/js/6/controllers/auth/get-current-user) +- [auth:updateSelf](/sdk/js/6/controllers/auth/update-self) + +## Properties + +Available properties: + +| Property | Type | Description | +| --------- | ----------------- | --------------------- | +| `_id` |
string
| User ID (kuid) | +| `content` |
object
| User internal content | + +The `content` property is an object containing generic properties alongside custom defined properties. + +| Property | Type | Description | +| -------------- | ------------------- | --------------------------------------------------------------------- | +| `profileIds` |
string[]
| Profiles IDs for this user | +| `_kuzzle_info` |
object
| [Kuzzle metadata](/core/1/guide/guides/essentials/document-metadata/) | diff --git a/doc/src/essentials/error-handling/index.md b/doc/src/essentials/error-handling/index.md new file mode 100644 index 000000000..7f3e5a713 --- /dev/null +++ b/doc/src/essentials/error-handling/index.md @@ -0,0 +1,28 @@ +--- +code: false +type: page +title: Error Handling +description: How to handle errors with the SDK +order: 100 +--- + +# Error Handling + +All SDK methods return a promise, that can be rejected with a `KuzzleError` value in case of failure. + +[KuzzleError](/sdk/js/6/core-classes/kuzzle-errorintroduction/) objects inherit the standard `Error` object, and add the following properties to it: + +| Property | Type | Description | +| -------- | ----------------- | ------------------------------------------------------------------------------------------ | +| `status` |
number
| Status following [HTTP Standards](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) | +| `stack` |
string
| Error stacktrace (Only in development mode) | + +You can find a detailed list of possible errors messages and statuses in the [documentation API](/core/1/api/essentials/errors). + +#### Example with a promise chain + +<<< ./snippets/error-handling.js + +#### Example with async/await + +<<< ./snippets/error-handling-async.js diff --git a/doc/src/essentials/error-handling/snippets/error-handling-async.js b/doc/src/essentials/error-handling/snippets/error-handling-async.js new file mode 100644 index 000000000..7ad0589e0 --- /dev/null +++ b/doc/src/essentials/error-handling/snippets/error-handling-async.js @@ -0,0 +1,8 @@ +try { + await kuzzle.index.create('nyc-open-data'); +} catch (error) { + if (error.status === 400) { + console.log(error.message); + console.log('Try with another name!'); + } +} diff --git a/doc/src/essentials/error-handling/snippets/error-handling-async.test.yml b/doc/src/essentials/error-handling/snippets/error-handling-async.test.yml new file mode 100644 index 000000000..8473fa704 --- /dev/null +++ b/doc/src/essentials/error-handling/snippets/error-handling-async.test.yml @@ -0,0 +1,10 @@ +name: essentials#errorHandlingAsync +description: How to handle errors with the SDK +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Try with another name! + +sdk: js +version: 6 diff --git a/doc/src/essentials/error-handling/snippets/error-handling.js b/doc/src/essentials/error-handling/snippets/error-handling.js new file mode 100644 index 000000000..3cde31af5 --- /dev/null +++ b/doc/src/essentials/error-handling/snippets/error-handling.js @@ -0,0 +1,8 @@ +kuzzle.index.create('nyc-open-data') + .then(() => 'do something') + .catch(error => { + if (error.status === 400) { + console.log(error.message); + console.log('Try with another name!'); + } + }); diff --git a/doc/src/essentials/error-handling/snippets/error-handling.test.yml b/doc/src/essentials/error-handling/snippets/error-handling.test.yml new file mode 100644 index 000000000..948f43353 --- /dev/null +++ b/doc/src/essentials/error-handling/snippets/error-handling.test.yml @@ -0,0 +1,10 @@ +name: essentials#errorHandling +description: How to handle errors with the SDK +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: thencatch +expected: Try with another name! + +sdk: js +version: 6 diff --git a/doc/src/essentials/events/index.md b/doc/src/essentials/events/index.md new file mode 100644 index 000000000..62548d82d --- /dev/null +++ b/doc/src/essentials/events/index.md @@ -0,0 +1,101 @@ +--- +code: false +type: page +title: Events +description: SDK events system +order: 200 +--- + +# Events + +An event system allows to be notified when the SDK status changes. These events are issued by the [Kuzzle](/sdk/js/6/kuzzle) SDK object. + +The API for interacting with events is described by our [KuzzleEventEmitter](/sdk-reference/js/6/kuzzle-event-emitter) class documentation. + +**Note:** listeners are called in the order of their insertion. + +# Emitted Events + +## connected + +Triggered when the SDK has successfully connected to Kuzzle. + +## discarded + +Triggered when Kuzzle discards a request, typically if no connection is established and the request is not queuable, either because the offline mode is not set or if set explicitely. + +**Callback arguments:** + +`@param {object} request`: the discarded [request](/core/1/api/essentials/query-syntax/) + +## disconnected + +Triggered when the current session has been unexpectedly disconnected. + +## loginAttempt + +Triggered when a login attempt completes, either with a success or a failure result. + +**Callback arguments:** + +`@param {object} data` + +| Property | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `success` |
boolean
| Indicate if login attempt succeed | +| `error` |
string
| Error message when login fail | + +## networkError + +Triggered when the SDK has failed to connect to Kuzzle. + +**Callback arguments:** + +`@param {Error} error` + +| Property | Type | Description | +| --------- | ----------------- | ---------------------------------- | +| `message` |
string
| Error description | +| `status` |
number
| Error code | +| `stack` |
string
| Stacktrace (development mode only) | + +## offlineQueuePop + +Triggered whenever a request is removed from the offline queue. + +**Callback arguments:** + +`@param {object} request`: the [request](/core/1/api/essentials/query-syntax/) removed from the queue + +## offlineQueuePush + +Triggered whenever a request is added to the offline queue. + +**Callback arguments:** + +`@param {object} data` + +| Property | Type | Description | +| --------- | ----------------- | ------------------------------------------------------------------ | +| `request` |
object
| [Request](/core/1/api/essentials/query-syntax/) added to the queue | + +## queryError + +Triggered whenever Kuzzle responds with an error + +**Callback arguments:** + +`@param {object} data` + +| Property | Type | Description | +| --------- | ----------------- | ----------------------------- | +| `request` |
object
| Request that causing an error | +| `error` |
Error
| Error details | + +## reconnected + +Triggered when the current session has reconnected to Kuzzle after a disconnection, and only if `autoReconnect` is set to `true`. + +## tokenExpired + +Triggered when Kuzzle rejects a request because the authentication token has expired. diff --git a/doc/src/essentials/extend-sdk/index.md b/doc/src/essentials/extend-sdk/index.md new file mode 100644 index 000000000..1b381fe12 --- /dev/null +++ b/doc/src/essentials/extend-sdk/index.md @@ -0,0 +1,102 @@ +--- +code: false +type: page +title: Extends the SDK +description: Extend the SDK +order: 410 +--- + +# Extend the SDK with a custom SDK controller + + + +It is possible to extend the SDK's API by adding new controllers. + +These controllers correspond to [custom controllers created in a plugin](/plugins/1/essentials/controllers). Thus, it is possible to use the actions of a core plugin in the SDK in the same way as the other actions of the Kuzzle API. + +## Define a custom SDK controller + +A custom SDK controller is a class inheriting from the [BaseController](/sdk-reference/js/6/base-controller) class and defining methods matching Kuzzle API actions. + +This base class is exposed alongside the other classes of the SDK module. + +After defining your new controller based on `BaseController`, you can add it to the SDK with the [Kuzzle.useController](/sdk-reference/js/6/kuzzle/use-controller) method. + +## Constructor + +The constructor of a custom SDK controller will be called by passing the SDK instance to it. It must call the parent constructor with this instance of the SDK and its name as defined in the API. + +For instance, if there is a plugin named `nyc-open-data-plugin`, extending Kuzzle's API with the following controller: + +```javascript +this.controllers = { + taxi: { + startDuty: request => this.startDuty(request) + } +} +``` + +Then the constructor of the custom SDK controller must specify its name as follows (see [how to query a custom API route](/plugins/1/essentials/controllers/#querying-plugins-controllers) documentation): + +```javascript +const { BaseController } = require('kuzzle-sdk'); + +class TaxiController extends BaseController { + constructor (kuzzle) { + super(kuzzle, 'nyc-open-data-plugin/taxi'); + } +} +``` + +The controller name will then be injected into the requests sent with the [BaseController.query](/sdk-reference/js/6/base-controller/query) method. + +## Define custom SDK controller actions + +Each action of your custom SDK controller is a method of the class. + +These methods have to use the [BaseController.query](/sdk-reference/js/6/base-controller/query) method to invoke an API action. + +Extending the previous example, we now have: + +```javascript +const { BaseController } = require('kuzzle-sdk'); + +class TaxiController extends BaseController { + constructor (kuzzle) { + super(kuzzle, 'nyc-open-data-plugin/taxi'); + } + + startDuty (driver) { + const apiRequest = { + action: 'startDuty', + body: { + driver + } + }; + + return this.query(apiRequest) + .then(response => response.result); + } +} +``` + +## Add a custom SDK controller to the SDK + +Once you have defined your custom SDK controller, you can add it to the SDK with the [Kuzzle.useController](/sdk-reference/js/6/kuzzle/use-controller) method. + + +You can then use the actions of your plugins in the same way as the rest of the Kuzzle API by taking advantage of authentication, offline mode management, etc. + +```javascript +const + TaxiController = require('./taxiController'), + { Kuzzle, WebSocket } = require('kuzzle-sdk'); + +const kuzzle = new Kuzzle(new WebSocket('localhost')); + +kuzzle.useController(TaxiController, 'taxi'); + +await kuzzle.connect(); + +await kuzzle.taxi.startDuty('lia meh ry'); +``` diff --git a/doc/src/essentials/getting-started/index.md b/doc/src/essentials/getting-started/index.md new file mode 100644 index 000000000..7ea7b11d6 --- /dev/null +++ b/doc/src/essentials/getting-started/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +title: Getting Started +description: Get started with the Javascript SDK +order: 0 +--- diff --git a/doc/src/essentials/getting-started/node-js/index.md b/doc/src/essentials/getting-started/node-js/index.md new file mode 100644 index 000000000..2ca8dae3c --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/index.md @@ -0,0 +1,156 @@ +--- +code: false +type: page +title: Node.js +description: Getting started with Kuzzle and Node.js +order: 100 +--- + +# Getting Started with Kuzzle and Node.js + +This tutorial explains you how to use **Kuzzle** with **Node.js** and the **Javascript SDK**. +It will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** about document creations. + +You are going to write an application that **stores** documents in Kuzzle Server and subscribe to **real time notifications** for each created document. + +To follow this tutorial, you must have a Kuzzle Server up and running. Follow these instructions if this is not already the case: [Running Kuzzle](/core/1/guide/guides/getting-started/running-kuzzle/). + +## Explore the SDK + +It's time to get started with the [Kuzzle Javascript SDK](/sdk/js/6). This section, explains you how to store a document and subscribe to notifications in Kuzzle using the Javascript SDK. + +Before proceeding, please make sure your system has **Node.js** version 8 or higher (instructions here) installed. + +## Prepare your environment + +Create your playground directory and install the Javascript SDK from the command line using npm: + +```sh +mkdir "kuzzle-playground" +cd "kuzzle-playground" +npm install kuzzle-sdk +``` + +
+If you are performing a clean install you might get some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +
+ +Then, create an `init.js` file and start by adding the code below. +This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. + +<<< ./snippets/load-sdk.js + +
+Replace 'kuzzle' which is the Kuzzle server hostname with 'localhost' or the hostname where your Kuzzle server is running. +
+ +Next, add a listener to be notified in case of a connection error: + +```javascript +kuzzle.on('networkError', error => { + console.error('Network Error: ', error); +}); +``` + +Then, connect the client to your Kuzzle server with the `connect()` method, afterwards you have to add the code that will access Kuzzle to create a new index 'nyc-open-data' and a new collection 'yellow-taxi' that you will use to store data later on. + +<<< ./snippets/prepare-db.js + +Your `init.js` file should now look like this: + +<<< ./snippets/init.js + +This code does the following: + +- loads the `Kuzzle SDK` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket +- creates the `nyc-open-data` index +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created or if an error occurs + +Run the code with Node.js: + +```bash +node init.js +``` + +The console should output the following message: + +```bash +nyc-open-data/yellow-taxi ready! +``` + +
+Congratulations! You are now ready to say Hello to the World! +
+ +## Create your first "Hello World" document + +Create a `create.js` file with the following code: + +<<< ./snippets/create.js + +This code does the following: + +- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions fails +- disconnects from Kuzzle after the document is created or if an error occurs + +Run the code with Node.js: + +```bash +node create.js +``` + +
+You have now successfully stored your first document into Kuzzle. Click here to see how you can use the + Kuzzle Admin Console to browse your collection and confirm that your document was saved. +
+ +
+Having trouble? Get in touch with us on Gitter! We're happy to help. +
+ +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the realtime notifications documentation). + +Let's get started. Create a `subscribe.js` file with the following code: + +<<< ./snippets/subscribe.js + +Run the code with Node.js: + +```bash +node subscribe.js +``` + +The `subscribe.js` program is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. + +Now in another terminal, launch the `create.js` file from the previous section. + +```bash +node create.js +``` + +This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages-default) sent to the `subscribe.js` program. +Check the `subscribe.js` terminal: a new message is printed everytime a document is created using the `create.js` code. + +```bash +New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. +``` + +
+Congratulations! You have just set up your first pub/sub communication! +
+ +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- discover what this SDK has to offer by browsing other sections of this documentation +- learn how to use Koncorde to create incredibly fine-grained and blazing-fast subscriptions +- learn how to perform a basic authentication +- follow our guide to learn how to manage users, and how to set up fine-grained access control diff --git a/doc/src/essentials/getting-started/node-js/snippets/create.js b/doc/src/essentials/getting-started/node-js/snippets/create.js new file mode 100644 index 000000000..abd761b20 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/create.js @@ -0,0 +1,39 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates a document + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); + console.log('New document successfully created!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/src/essentials/getting-started/node-js/snippets/create.test.yml b/doc/src/essentials/getting-started/node-js/snippets/create.test.yml new file mode 100644 index 000000000..910484f25 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/create.test.yml @@ -0,0 +1,11 @@ +name: gettingstarted#nodejscreate +description: Creates a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: empty +expected: New document successfully created! +sdk: js +version: 6 diff --git a/doc/src/essentials/getting-started/node-js/snippets/init.js b/doc/src/essentials/getting-started/node-js/snippets/init.js new file mode 100644 index 000000000..fd0a31384 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/init.js @@ -0,0 +1,37 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates an index + await kuzzle.index.create('nyc-open-data'); + + // Creates a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/src/essentials/getting-started/node-js/snippets/init.test.yml b/doc/src/essentials/getting-started/node-js/snippets/init.test.yml new file mode 100644 index 000000000..0e76545bc --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/init.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejsinit +description: Creates an index and a collection +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: empty +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 diff --git a/doc/src/essentials/getting-started/node-js/snippets/load-sdk.js b/doc/src/essentials/getting-started/node-js/snippets/load-sdk.js new file mode 100644 index 000000000..ae17a9b0e --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/load-sdk.js @@ -0,0 +1,9 @@ +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); diff --git a/doc/src/essentials/getting-started/node-js/snippets/load-sdk.test.yml b/doc/src/essentials/getting-started/node-js/snippets/load-sdk.test.yml new file mode 100644 index 000000000..0d32da204 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/load-sdk.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejsload +description: Load SDK +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/src/essentials/getting-started/node-js/snippets/prepare-db.js b/doc/src/essentials/getting-started/node-js/snippets/prepare-db.js new file mode 100644 index 000000000..2fb9b8410 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/prepare-db.js @@ -0,0 +1,20 @@ +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates an index + await kuzzle.index.create('nyc-open-data'); + + // Creates a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/src/essentials/getting-started/node-js/snippets/prepare-db.test.yml b/doc/src/essentials/getting-started/node-js/snippets/prepare-db.test.yml new file mode 100644 index 000000000..e51b6f7ce --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/prepare-db.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejspreparedb +description: Prepare database +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: blank +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 diff --git a/doc/src/essentials/getting-started/node-js/snippets/subscribe.js b/doc/src/essentials/getting-started/node-js/snippets/subscribe.js new file mode 100644 index 000000000..f85d66357 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/subscribe.js @@ -0,0 +1,51 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Defines a filter + const filter = { + equals: { license: 'B' } + }; + + // Defines a callback invoked each time a notification is received + const callback = (notification) => { + + if (notification.type === 'document' && notification.action === 'create') { + const { + _source: driver, + _id: driverId + } = notification.result; + + console.log(`New driver ${driver.name} with id ${driverId} has B license.`); + kuzzle.disconnect(); + } + }; + + // Subscribes to document notifications using the above filter + await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filter, callback); + + console.log('Successfully subscribed to document notifications!'); + } catch (error) { + console.error(error.message); + } +}; + +run(); diff --git a/doc/src/essentials/getting-started/node-js/snippets/subscribe.test.yml b/doc/src/essentials/getting-started/node-js/snippets/subscribe.test.yml new file mode 100644 index 000000000..5e6720558 --- /dev/null +++ b/doc/src/essentials/getting-started/node-js/snippets/subscribe.test.yml @@ -0,0 +1,11 @@ +name: gettingstarted#nodejssubscribe +description: Subscribes to document notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: empty-realtime +expected: Successfully subscribed to document notifications! +sdk: js +version: 6 diff --git a/doc/src/essentials/getting-started/raw-web/index.md b/doc/src/essentials/getting-started/raw-web/index.md new file mode 100644 index 000000000..c7d0c74a5 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/index.md @@ -0,0 +1,166 @@ +--- +code: false +type: page +title: Browser (Vanilla) +description: Getting started with Kuzzle in the browser +--- + +# Getting Started with Kuzzle in the browser + +This tutorial explains how to use **Kuzzle** with the **Javascript SDK** in a **browser**. + +To follow this tutorial, you must have a Kuzzle Server up and running (you'll need to know the hostname of the machine running it). If this is not already the case, take a look at [how to run Kuzzle](/core/1/guide/guides/getting-started/running-kuzzle/). + +Before proceeding, make sure your system has **Node.js** version 8 or higher (instructions here) installed. + +In this tutorial, you'll learn how to **store** a document and **subscribe** to notifications in Kuzzle using the Javascript SDK. + +## Prepare your environment + +Create your playground directory: + +```sh +mkdir "kuzzle-playground" +cd "kuzzle-playground" +``` + +
+If you are performing a clean install you might get some UNMET PEER DEPENDENCY warnings, these are safe to ignore as they refer to optional dependencies. +
+ +Then, create an `index.html` file with the following structure: + +```html + + + + + + Kuzzle SDK Playground + + + + + + + + +``` + +
+If you are using Internet Explorer (not Edge), you are responsible of installing a Promise polyfill, which enables IE to support +Javascript Promises. +Our advice is to use Bluebird, as shown in the code example above (refer to the commented lines in the head tag). +
+ +Then, add the code below in the `body` tag. +This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. If an error occurs, it is displayed +in the console. Once the connection is established, a success message is displayed in the console. + +<<< ./snippets/load-sdk.js + +
+Replace kuzzle with localhost or the hostname where your Kuzzle server is running. +
+ +Now you have to add the code that will access Kuzzle to create a new index `nyc-open-data` and a new collection `yellow-taxi` +that you will use to store data later on. Make sure the code inside your `body` tag looks like the following: + +<<< ./snippets/prepare-db.js + +Now, let's take a look at what your script is doing: + +- creates an instance of the SDK, +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, +- creates the `nyc-open-data` index, +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created, +- displays an error whenever something goes wrong. + +Run this code by opening the `index.html` file in your favorite browser. +The console should output the following message: + +```plaintext +Successfully connected to Kuzzle +nyc-open-data/yellow-taxi ready! +``` + +
+Congratulations! You are now ready to say Hello to the World! +
+ +
+If you reload the page, you should see an error in the console. This is OK, since Kuzzle is just refusing to create +the nyc-open-data index as it already exists. +
+ +## Create your first "Hello World" document + +Create a `create.html` file with the same structure as `index.html` (see above). +And, right like before, add some code to the `body` tag: + +<<< ./snippets/create.js + +This code does the following: + +- creates an instance of the SDK, +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, +- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions fails +- disconnects from Kuzzle after the document is created or if an error occurs + +Run this code by opening the `create.html` file in your favorite browser. +The console should output the following message: + +``` +Successfully connected to Kuzzle +New document successfully created! +``` + +
+You have now successfully stored your first document into Kuzzle. Click here to see how you can use the Kuzzle Admin Console to browse your collection and confirm that your document was saved. +
+ +
+Having trouble? Get in touch with us on Gitter! We're happy to help. +
+ +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the realtime notifications documentation). + +Let's get started. Create a `subscribe.html` file (same structure as above) with the following code in the `body` tag: + +<<< ./snippets/subscribe.js + +Run this code by opening the `subscribe.html` file in a new tab, leaving the previous one (showing `create.html`) open. +The console should output the following message: + +``` +Successfully connected to Kuzzle +Successfully subscribed to document notifications! +``` + +The code in the `subscribe.html` page is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. + +Now go back to the other tab and reload `create.html`. + +This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages-default) sent to the `subscribe.html` tab. Check the `subscribe.html` tab: a new message is printed everytime a document is created using the `create.html` code. + +``` +New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. +``` + +
+Congratulations! You have just set up your first pub/sub communication! +
+ +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- discover what this SDK has to offer by browsing other sections of this documentation +- learn how to use Koncorde to create incredibly fine-grained and blazing-fast subscriptions +- learn how to perform a basic authentication +- follow our guide to learn how to manage users, and how to set up fine-grained access control diff --git a/doc/src/essentials/getting-started/raw-web/snippets/create.html b/doc/src/essentials/getting-started/raw-web/snippets/create.html new file mode 100644 index 000000000..70aee4f09 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/create.html @@ -0,0 +1,31 @@ + diff --git a/doc/src/essentials/getting-started/raw-web/snippets/create.test.yml b/doc/src/essentials/getting-started/raw-web/snippets/create.test.yml new file mode 100644 index 000000000..557868de8 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/create.test.yml @@ -0,0 +1,12 @@ +name: gettingstarted#browservanillacreate +description: Create a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: New document successfully created +sdk: js +version: 6 +runner: web diff --git a/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.html b/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.html new file mode 100644 index 000000000..10d2477d1 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.test.yml b/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.test.yml new file mode 100644 index 000000000..c17ef17d8 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#browservanillaconnect +description: Connect to Kuzzle +hooks: + before: + after: +template: default +expected: Successfully connected to Kuzzle +sdk: js +version: 6 +runner: web diff --git a/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.html b/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.html new file mode 100644 index 000000000..c392a86b4 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.html @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.test.yml b/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.test.yml new file mode 100644 index 000000000..3ac1c5a75 --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#browservanillaprepare +description: Prepare the database +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: default +expected: nyc-open-data/yellow-taxi ready +sdk: js +version: 6 +runner: web diff --git a/doc/src/essentials/getting-started/raw-web/snippets/subscribe.html b/doc/src/essentials/getting-started/raw-web/snippets/subscribe.html new file mode 100644 index 000000000..ec6c858ab --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/subscribe.html @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/doc/src/essentials/getting-started/raw-web/snippets/subscribe.test.yml b/doc/src/essentials/getting-started/raw-web/snippets/subscribe.test.yml new file mode 100644 index 000000000..2fad572cd --- /dev/null +++ b/doc/src/essentials/getting-started/raw-web/snippets/subscribe.test.yml @@ -0,0 +1,12 @@ +name: gettingstarted#browservanillasubscribe +description: Subscribe to notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Successfully subscribed to document notifications +sdk: js +version: 6 +runner: web diff --git a/doc/src/essentials/getting-started/webpack/index.md b/doc/src/essentials/getting-started/webpack/index.md new file mode 100644 index 000000000..fefe62f78 --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/index.md @@ -0,0 +1,233 @@ +--- +type: page +code: false +title: Webpack +description: Getting started with Kuzzle and Webpack +--- + +# Getting Started with Kuzzle and Webpack + +In this tutorial you will learn how to install, run and use **Kuzzle** with the **Javascript SDK** in the browser using **Webpack**. +We will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** for each new document created. + +## Running Kuzzle + +Before going through this tutorial, you should have a Kuzzle server running. Please refer to the [Running Kuzzle Tutorial](https://docs.kuzzle.io/core/1/guide/guides/getting-started/running-kuzzle/) if you don't have one yet. + +## Fun with the SDK + +It's time to play with the [Kuzzle Javscript SDK](/sdk/js/6). In this section, we will store a document and subscribe to notifications in Kuzzle using the Javascript SDK in your browser. + +Before proceeding, please make sure your system has **Node.js** version 8 or higher (instructions here) installed. + +## Including the Kuzzle SDK in a Webpack project + +
+ This section explains how to use the Kuzzle SDK within an existing Webpack project. + If you don't have your project up and running yet and want to learn how to leverage Webpack to build it, please refer to + the official Webpack Getting Started page. +
+ +In your terminal, go to the root of your front-end project using Webpack and type + +```bash +npm install kuzzle-sdk +``` + +
+If you are performing a clean install you might see some unmet peer dependency warnings, these are safe to ignore as they refer to optional dependencies. +
+ +Then, create a `init-kuzzle.js` file and start by adding the code below. This will load the Kuzzle Javascript SDK: + +```javascript +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; +``` + +Next, we instantiate a client that will connect to Kuzzle via WebSocket. If Kuzzle is not running on localhost, replace it with the corresponding server name or IP address. + +```javascript +const kuzzle = new Kuzzle(new WebSocket('localhost')); +``` + +Next we add a listener to be notified in case of a connection error: + +```javascript +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); +``` + +Then we have to connect our web app to the Kuzzle server with the `connect()` method. + +```javascript +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Some more things will go here... + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; +``` + +Finally, we will create a new index `nyc-open-data` and a new collection +`yellow-taxi` that we will use to store data later on. + +```javascript +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create an index + await kuzzle.index.create('nyc-open-data'); + // Create a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; +``` + +Your `kuzzle-init.js` file should now look like this: + +<<< ./snippets/init-kuzzle.js + +This code does the following: + +- loads the `kuzzle-sdk` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `localhost` with the `WebSocket` protocol +- creates the `nyc-open-data` index +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created or if an error occurs + +Now, to have your script up and running, require it somewhere in your application +(e.g. your main entry point) and launch it. + +```javascript +require('../path/to/init-kuzzle.js'); +``` + +Your console should output the following message: + +``` +nyc-open-data/yellow-taxi ready! +``` + +
+Congratulations! You are now ready to say Hello to the World! +
+ +
+Having trouble? Get in touch with us on Gitter! We're happy to help. +
+ +## Create your first document + +Create a `create.js` file with following code: + +<<< ./snippets/create.js + +This code does the following: + +- creates a new document in `nyc-open-data` within the `yellow-taxi` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions failed +- disconnects from Kuzzle after the document is created or if an error occurs + +To activate this code, create a button somewhere in your page like the following + +```html + +``` + +Then, associate it to the `create` function by adding this code to your application + +```javascript +const create = require('../path/to/create.js'); + +// This is the most "vanilla" way to call a function in reaction to a click, +// if you're using a front-end framework like Vuejs, React or jQuery, feel free +// to follow any convenience method it provides for this purpose. +document.querySelector('#create-document-btn').addListener('click', event => { + create(); +}); +``` + +Now, click the button and check your console for a message like the following: + +```bash +New document successfully created! +``` + +
+ You have now successfully stored your first document into Kuzzle. Click + here to see how you can use the + Kuzzle Admin Console to browse your collection and + confirm that your document was saved. +
+ +
+Having trouble? Get in touch with us on Gitter! We're happy to help. +
+ +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the realtime notifications documentation). + +Let's get started. Create a `subscribe.js` file with following code: + +<<< ./snippets/subscribe.js + +This code does the following: + +- loads the `Kuzzle SDK` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `localhost` with the `websocket` protocol +- defines a filter for the subscription to be done later (drivers with "B" license) +- defines a callback that will be called whenever a notification is received from Kuzzle (print driver name to console) +- subscribes for notifications on the `yellow-taxi` collection + +You can execute this code in the same page as before or in another page of your app. Whatever option you choose, to +execute the code, you just need to require it in your page + +```javascript +require('../path/to/subscribe.js'); +``` + +From now on, whenever you click the button we created before, Kuzzle will send a notification to the page containing +the subscription to the `yellow-taxi` collection. In the console corresponding to this page, you should see the following message: + +```bash +New driver Sirkis with id has B license. +``` + +In place of `` you'll see the ID that Kuzzle automatically generated for the document. + +
+Congratulations! You have just choreographed your first pub/sub pattern! +
+ +
+Having trouble? Get in touch with us on Gitter! We're happy to help. +
+ +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- take a look at the SDK Reference +- learn how to use Koncorde to create incredibly fine-grained and blazing-fast subscriptions +- follow our guide to learn how to implement basic authentication +- follow our guide to learn how to implement manage users and setup fine-grained access control diff --git a/doc/src/essentials/getting-started/webpack/snippets/create.js b/doc/src/essentials/getting-started/webpack/snippets/create.js new file mode 100644 index 000000000..fe66ca6b5 --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/snippets/create.js @@ -0,0 +1,33 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const doIt = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create your document + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); + console.log('New document successfully created!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +export default doIt; diff --git a/doc/src/essentials/getting-started/webpack/snippets/create.test.yml b/doc/src/essentials/getting-started/webpack/snippets/create.test.yml new file mode 100644 index 000000000..fb4561210 --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/snippets/create.test.yml @@ -0,0 +1,13 @@ +name: gettingstarted#webpackcreate +description: Creates a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: doIt +expected: New document successfully created! + +runner: webpack +sdk: js +version: 6 diff --git a/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.js b/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.js new file mode 100644 index 000000000..49068c155 --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.js @@ -0,0 +1,30 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create an index + await kuzzle.index.create('nyc-open-data'); + + // Create a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml b/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml new file mode 100644 index 000000000..cd2ff4589 --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#webpackinitkuzzle +description: Creates an index and a collection +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: empty +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 +runner: webpack diff --git a/doc/src/essentials/getting-started/webpack/snippets/subscribe.js b/doc/src/essentials/getting-started/webpack/snippets/subscribe.js new file mode 100644 index 000000000..892c99bcb --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/snippets/subscribe.js @@ -0,0 +1,49 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const doIt = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Define a filter + const filter = { + equals: { license: 'B' } + }; + + // Define a callback + const callback = notification => { + if ( + notification.type === 'document' && + notification.action === 'create' + ) { + const driver = notification.result._source; + const driverId = notification.result._id; + console.log( + `New driver ${driver.name} with id ${driverId} has B license.` + ); + } + }; + + // Subscribes to document notifications with our filter + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filter, + callback + ); + console.log('Successfully subscribed to document notifications!'); + } catch (error) { + console.error(error.message); + } +}; + +doIt(); diff --git a/doc/src/essentials/getting-started/webpack/snippets/subscribe.test.yml b/doc/src/essentials/getting-started/webpack/snippets/subscribe.test.yml new file mode 100644 index 000000000..f62f51a44 --- /dev/null +++ b/doc/src/essentials/getting-started/webpack/snippets/subscribe.test.yml @@ -0,0 +1,14 @@ +name: gettingstarted#webpacksubscribe +description: Subscribes to document notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: createDocumentAfterSnippet +expected: + - Successfully subscribed to document notifications! + - New driver Sirkis with id +sdk: js +version: 6 +runner: webpack diff --git a/doc/src/essentials/index.md b/doc/src/essentials/index.md new file mode 100644 index 000000000..cfad2d95d --- /dev/null +++ b/doc/src/essentials/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 0 +title: Essentials +description: Javascript SDK v6.x essential notions +--- diff --git a/doc/src/essentials/offline-tools/index.md b/doc/src/essentials/offline-tools/index.md new file mode 100644 index 000000000..411536c0b --- /dev/null +++ b/doc/src/essentials/offline-tools/index.md @@ -0,0 +1,76 @@ +--- +code: false +type: page +title: Offline Tools +description: Tools to handle the loss of connection to the Kuzzle server +order: 400 +--- + +# Offline tools + +The Kuzzle SDK provides a set of properties that help your application to be resilient to the loss of network connection +during its lifespan. + +## offlineQueue + +A read-only `Array` containing the requests queued while the SDK is in the `offline` state (it behaves like a FIFO queue). + +## queueMaxSize + +A writable `number` defining the maximun size of the `offlineQueue`. + +## queueTTL + +A writable `number` defining the time in milliseconds a queued request is kept in the `offlineQueue`. + +## startQueuing() + +Starts queuing requests when in `offline` state. Request will be put in the `offlineQueue` instead of being discarded, until `stopQueuing` is called. +Works only in `offline` state when the `autoQueue` option is set to `false`. Call `playQueue` to send to Kuzzle the +requests in the queue, once the SDK state passes to `online`. Call `flushQueue` to empty the queue without sending the requests. + +## stopQueuing() + +Stop queuing the requests. Requests will no more be put in the `offlineQueue`, they will be discarded. +Works only in the `offline` state, and if the `autoQueue` option is set to `false`. + +## playQueue() + +Sends to Kuzzle all the requests in the `offlineQueue`. Works only if the SDK is not in a `offline` state, and if the +`autoReplay` option is set to false. + +## flushQueue() + +Empties the `offlineQueue` without sending the requests to Kuzzle. + +## autoQueue + +A writable `boolean` telling the SDK whether to automatically queue requests during the `offline` state or not. + +## autoReplay + +A writable `boolean` telling the SDK whether to automatically send or not the requests in the `offlineQueue` on a +`reconnected` event. + +## autoReconnect + +A writable `boolean` telling the SDK whether to automatically reconnect or not to Kuzzle after a connection loss. + +## reconnectionDelay + +A read-only `number` specifying the time in milliseconds between different reconnection attempts. + +## autoResubscribe + +A writable `boolean` telling the SDK whether to automatically renew or not all subscriptions on a reconnected event. + +## queueFilter + +A writable `Function` called by the SDK each time a `Request` need to be queued. The `Request` is passed as the only argument +to the function and is queued only if the function returns `true`. Use it to define which requests are allowed to be queued. + +## offlineQueueLoader + +A writable `Function` called by the SDK before playing the requests in the `offlineQueue`. This function takes no arguments +and returns an array of `Request` that are added on top of the `offlineQueue`. Use it to inject new requests to be played +before the queue. diff --git a/doc/src/essentials/realtime-notifications/index.md b/doc/src/essentials/realtime-notifications/index.md new file mode 100644 index 000000000..45d570203 --- /dev/null +++ b/doc/src/essentials/realtime-notifications/index.md @@ -0,0 +1,69 @@ +--- +code: false +type: page +title: Realtime notifications +description: List of realtime notifications sent by Kuzzle +order: 300 +--- + +# Notifications + +The [realtime.subscribe](/sdk/js/6/controllers/realtime/) method takes a callback argument, called with a notification object, whose properties depends on the type of notification received. + +## Document & messages + +These notifications represent [documents changes & messages](/core/1/api/essentials/notifications#documents-changes-messages-default). + +| Property | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------- | +| `action` |
string
| API controller's action | +| `collection` |
string
| Data collection | +| `controller` |
string
| API controller | +| `index` |
string
| Data index | +| `protocol` |
string
| Network protocol used to modify the document | +| `result` |
object
| Notification content | +| `room` |
string
| Subscription channel identifier. Can be used to link a notification to its corresponding subscription | +| `scope` |
string
| `in`: document enters (or stays) in the scope
number | Timestamp of the event, in Epoch-millis format | +| `type` |
string
| `document`: Notification type | +| `volatile` |
object
| Request [volatile data](/core/1/api/essentials/volatile-data/) | + +The `result` object is the notification content, and it has the following structure: + +| Property | Type | Description | +| --------- | ----------------- | --------------------------------------------------------------------------------------- | +| `_id` |
string
| Document unique ID
object | Message or full document content. Not present if the event is about a document deletion | + +## User + +These notifications represent [user events](/core/1/api/essentials/notifications#user-events-default). + +| Property | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------- | +| `action` |
string
| API controller's action | +| `collection` |
string
| Data collection | +| `controller` |
string
| API controller | +| `index` |
string
| Data index | +| `protocol` |
string
| Network protocol used by the entering/leaving user | +| `result` |
object
| Notification content | +| `room` |
string
| Subscription channel identifier. Can be used to link a notification to its corresponding subscription | +| `timestamp` |
number
| Timestamp of the event, in Epoch-millis format | +| `type` |
string
| `user`: Notification type | +| `user` |
string
| `in`: a new user has subscribed to the same filters
object | Request [volatile data](/core/1/api/essentials/volatile-data/) | + +The `result` object is the notification content, and it has the following structure: + +| Property | Type | Description | +| -------- | ----------------- | -------------------------------------------------- | +| `count` |
number
| Updated users count sharing that same subscription | + +## Server + +These notifications represent [server events](/core/1/api/essentials/notifications#server-events-default). + +| Property | Type | Value | +| --------- | ----------------- | ------------------------------------------------------------------ | +| `message` |
string
| Server message explaining why this notification has been triggered | +| `type` |
string
| `TokenExpired`: notification type | diff --git a/doc/src/index.md b/doc/src/index.md new file mode 100644 index 000000000..1f7b5ba97 --- /dev/null +++ b/doc/src/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: root +order: 0 +title: Javascript SDK v6.x +description: Javascript SDK v6.x +--- diff --git a/doc/src/protocols/http/constructor/index.md b/doc/src/protocols/http/constructor/index.md new file mode 100644 index 000000000..15cc9ac1b --- /dev/null +++ b/doc/src/protocols/http/constructor/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: Constructor +description: Creates a new Http protocol +order: 50 +--- + +# Constructor + +Use this constructor to create a new instance of the `Http` protocol with specific options. + +## Arguments + +```javascript +Http(host, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------------- | +| `host` |
string
| Kuzzle server hostname or IP | +| `options` |
object
| Http connection options | + +### options + +Http protocol connection options. + +| Property | Type
(default) | Description | +| --------------- | -------------------------------- | ----------------------------------- | +| `port` |
number

(`7512`) | Kuzzle server port | +| `sslConnection` |
boolean

(`false`) | Use SSL to connect to Kuzzle server | + +## Return + +A `Http` protocol instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/src/protocols/http/constructor/snippets/constructor.js b/doc/src/protocols/http/constructor/snippets/constructor.js new file mode 100644 index 000000000..073ebabdd --- /dev/null +++ b/doc/src/protocols/http/constructor/snippets/constructor.js @@ -0,0 +1,16 @@ +// Loads the Http protocol +const + { + Kuzzle, + Http + } = require('kuzzle-sdk'); + +const options = { + sslConnection: false +}; + +// Instantiates the Http protocol +const httpProtocol = new Http('kuzzle', options); + +// Use it with Kuzzle +const kuzzle = new Kuzzle(httpProtocol); diff --git a/doc/src/protocols/http/constructor/snippets/constructor.test.yml b/doc/src/protocols/http/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..585b32c5a --- /dev/null +++ b/doc/src/protocols/http/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: http#constructor +description: Creates a new Http instance +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/src/protocols/http/index.md b/doc/src/protocols/http/index.md new file mode 100644 index 000000000..7d3ae6f0e --- /dev/null +++ b/doc/src/protocols/http/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Http +description: Http protocol documentation +order: 600 +--- diff --git a/doc/src/protocols/http/introduction/index.md b/doc/src/protocols/http/introduction/index.md new file mode 100644 index 000000000..1f2b0bab4 --- /dev/null +++ b/doc/src/protocols/http/introduction/index.md @@ -0,0 +1,20 @@ +--- +code: true +type: page +title: Introduction +description: Http protocol implementation +order: 0 +--- + +# Http + +The Http protocol can be used by an instance of the SDK to communicate with your Kuzzle server. + +
+

+ This protocol does not allow to use the real-time notifications. +

+

+ You have to use WebSocket or SocketIO protocol instead. +

+
diff --git a/doc/src/protocols/index.md b/doc/src/protocols/index.md new file mode 100644 index 000000000..91d86f85d --- /dev/null +++ b/doc/src/protocols/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 200 +title: Protocols +description: Javascript SDK v6.x protocols +--- diff --git a/doc/src/protocols/socketio/constructor/index.md b/doc/src/protocols/socketio/constructor/index.md new file mode 100644 index 000000000..8ba0dd9bf --- /dev/null +++ b/doc/src/protocols/socketio/constructor/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: Constructor +description: Creates a new SocketIO protocol +order: 50 +--- + +# Constructor + +Use this constructor to create a new instance of the `SocketIO` protocol with specific options. + +## Arguments + +```javascript +SocketIO(host, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------------- | +| `host` |
string
| Kuzzle server hostname or IP | +| `options` |
object
| SocketIO connection options | + +### options + +SocketIO protocol connection options. + +| Property | Type
(default) | Description | +| ------------------- | -------------------------------- | -------------------------------------------------------------- | +| `port` |
number

(`7512`) | Kuzzle server port | +| `sslConnection` |
boolean

(`false`) | Use SSL to connect to Kuzzle server | +| `autoReconnect` |
boolean

(`true`) | Automatically reconnect to kuzzle after a `disconnected` event | +| `reconnectionDelay` |
number

(`1000`) | Number of milliseconds between reconnection attempts | + +## Return + +A `SocketIO` protocol instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/src/protocols/socketio/constructor/snippets/constructor.js b/doc/src/protocols/socketio/constructor/snippets/constructor.js new file mode 100644 index 000000000..ff5f68f10 --- /dev/null +++ b/doc/src/protocols/socketio/constructor/snippets/constructor.js @@ -0,0 +1,16 @@ +// Loads the SocketIO protocol +const + { + Kuzzle, + SocketIO + } = require('kuzzle-sdk'); + +const options = { + autoReconnect: false +}; + +// Instantiates the SocketIO protocol +const socketIOProtocol = new SocketIO('kuzzle', options); + +// Use it with Kuzzle +const kuzzle = new Kuzzle(socketIOProtocol); diff --git a/doc/src/protocols/socketio/constructor/snippets/constructor.test.yml b/doc/src/protocols/socketio/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..f8b638ee1 --- /dev/null +++ b/doc/src/protocols/socketio/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: socketio#constructor +description: Creates a new SocketIO instance +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/src/protocols/socketio/index.md b/doc/src/protocols/socketio/index.md new file mode 100644 index 000000000..44ea1ab0d --- /dev/null +++ b/doc/src/protocols/socketio/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: SocketIO +description: SocketIO protocol documentation +order: 600 +--- diff --git a/doc/src/protocols/socketio/introduction/index.md b/doc/src/protocols/socketio/introduction/index.md new file mode 100644 index 000000000..528d29882 --- /dev/null +++ b/doc/src/protocols/socketio/introduction/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: Introduction +description: SocketIO protocol implementation +order: 0 +--- + +# SocketIO + +The SocketIO protocol can be used by an instance of the SDK to communicate with your Kuzzle server. +This protocol allows you to use all the features of Kuzzle, including [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). + +
+

+ The SocketIO protocol is used for websocket compatibility with older browsers. It is preferable to use the WebSocket protocol when possible. +

+
+ +## Properties + +Available properties. + +| Property name | Type | Description | Writable? | +| ------------------- | ------------------ | ---------------------------------------------------- | :-------: | +| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | No | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | No | + +**Notes:** + +- updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on next `connect` call diff --git a/doc/src/protocols/websocket/constructor/index.md b/doc/src/protocols/websocket/constructor/index.md new file mode 100644 index 000000000..8ac46fe20 --- /dev/null +++ b/doc/src/protocols/websocket/constructor/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: Constructor +description: Creates a new WebSocket protocol +order: 50 +--- + +# Constructor + +This constructor creates a new WebSocket connection, using the specified options. + +## Arguments + +```javascript +WebSocket(host, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------------- | +| `host` |
string
| Kuzzle server hostname or IP | +| `options` |
object
| WebSocket connection options | + +### options + +WebSocket protocol connection options. + +| Property | Type
(default) | Description | +| ------------------- | -------------------------------- | -------------------------------------------------------------------------------------------- | +| `autoReconnect` |
boolean

(`true`) | Automatically reconnect to kuzzle after a `disconnected` event | +| `port` |
number

(`7512`) | Kuzzle server port | +| `headers` |
object
(`{}`) | Connection HTTP headers (e.g. origin, subprotocols, ...)
**(Not supported by browsers)** | +| `reconnectionDelay` |
number

(`1000`) | Number of milliseconds between reconnection attempts | +| `sslConnection` |
boolean

(`false`) | Use SSL to connect to Kuzzle server | + +## Return + +A `WebSocket` protocol instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/src/protocols/websocket/constructor/snippets/constructor.js b/doc/src/protocols/websocket/constructor/snippets/constructor.js new file mode 100644 index 000000000..17fc0cd26 --- /dev/null +++ b/doc/src/protocols/websocket/constructor/snippets/constructor.js @@ -0,0 +1,16 @@ +// Loads the WebSocket protocol +const + { + Kuzzle, + WebSocket + } = require('kuzzle-sdk'); + +const options = { + autoReconnect: false +}; + +// Instantiates the websocket protocol +const websocketProtocol = new WebSocket('kuzzle', options); + +// Use it with Kuzzle +const kuzzle = new Kuzzle(websocketProtocol); diff --git a/doc/src/protocols/websocket/constructor/snippets/constructor.test.yml b/doc/src/protocols/websocket/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..9f49ef71a --- /dev/null +++ b/doc/src/protocols/websocket/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: websocket#constructor +description: Creates a new WebSocket instance +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/src/protocols/websocket/index.md b/doc/src/protocols/websocket/index.md new file mode 100644 index 000000000..e57f9b855 --- /dev/null +++ b/doc/src/protocols/websocket/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: WebSocket +description: WebSocket protocol documentation +order: 600 +--- diff --git a/doc/src/protocols/websocket/introduction/index.md b/doc/src/protocols/websocket/introduction/index.md new file mode 100644 index 000000000..d9627a470 --- /dev/null +++ b/doc/src/protocols/websocket/introduction/index.md @@ -0,0 +1,28 @@ +--- +code: true +type: page +title: Introduction +description: Websocket protocol implementation +order: 0 +--- + +# WebSocket + +Inherits from: [KuzzleEventEmitter](/sdk/js/6/kuzzle-event-emitter) + +The WebSocket protocol can be used by an instance of the SDK to communicate with your Kuzzle server. + +This protocol allows you to use all the features of Kuzzle, including [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). + +## Properties + +Available properties. + +| Property name | Type | Description | Writable? | +| ------------------- | ------------------ | ---------------------------------------------------- | :-------: | +| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | No | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | No | + +**Notes:** + +- updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on next `connect` call From 6a89673fe451abdd76fda3610314546e9de87973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Tue, 28 May 2019 18:19:13 +0200 Subject: [PATCH 02/26] fix doc compose command --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ca72b2275..7ae477e14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ jobs: node_js: 8 script: - - docker-compose .ci/docker-compose doc-tests node index + - docker-compose .ci/docker-compose.yml run doc-tests node index - stage: "Deploy Stable release on NPM" if: type != pull_request && branch = master From d4c19002e196fe100f2120d300f9ab3f3808a50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Tue, 28 May 2019 18:22:14 +0200 Subject: [PATCH 03/26] add missing -f compose option --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ae477e14..69f575fbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ jobs: include: - - stage: Tests + - name: Sdk tests + stage: Tests sudo: false language: node_js node_js: 8 @@ -38,7 +39,7 @@ jobs: node_js: 8 script: - - docker-compose .ci/docker-compose.yml run doc-tests node index + - docker-compose -f .ci/docker-compose.yml run doc-tests node index - stage: "Deploy Stable release on NPM" if: type != pull_request && branch = master From 907de1952a50294fd7b3018a6c118c5968a46abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Wed, 29 May 2019 09:48:52 +0200 Subject: [PATCH 04/26] fix bulk import test --- doc/src/controllers/bulk/import/snippets/import.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/controllers/bulk/import/snippets/import.js b/doc/src/controllers/bulk/import/snippets/import.js index 91c0ebe3d..d2ba28f6b 100644 --- a/doc/src/controllers/bulk/import/snippets/import.js +++ b/doc/src/controllers/bulk/import/snippets/import.js @@ -24,7 +24,7 @@ try { status: 200 } } ] } */ - console.log(`Successfully imported ${response.length} documents`); + console.log(`Successfully imported ${response.items.length} documents`); } catch (error) { console.error(error.message); } From 7ed78e64d61b7652f96bc0c6483466b9e8fdcd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Wed, 29 May 2019 10:25:04 +0200 Subject: [PATCH 05/26] [doctest] remove non-existing work_dir --- .ci/docker-compose.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 0b2ea93f9..5a71dbcb4 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -45,9 +45,9 @@ services: doc-runner-node: image: node:8-alpine - working_dir: /var/snippets/node command: > ash -c ' + mkdir -p /var/snippets/node; apk add --no-cache curl; npm install -g \ eslint \ @@ -57,6 +57,7 @@ services: eslint-plugin-promise \ eslint-plugin-standard; touch /tmp/runner_ready_to_lint; + cd /var/snippets/node; npm install \ bluebird \ /mnt/; @@ -69,9 +70,9 @@ services: doc-runner-web: image: buildkite/puppeteer:latest - working_dir: /var/snippets/web command: > bash -c ' + mkdir -p /var/snippets/web; apt-get update; apt-get install -y curl; npm install -g \ @@ -82,6 +83,7 @@ services: eslint-plugin-promise \ eslint-plugin-standard; touch /tmp/runner_ready_to_lint; + cd /var/snippets/web; cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; npm install \ /mnt/ \ @@ -95,9 +97,9 @@ services: doc-runner-webpack: image: buildkite/puppeteer:latest - working_dir: /var/snippets/webpack command: > bash -c ' + mkdir -p /var/snippets/webpack; apt-get update; apt-get install -y curl; npm install -g \ @@ -108,6 +110,7 @@ services: eslint-plugin-promise \ eslint-plugin-standard; touch /tmp/runner_ready_to_lint; + cd /var/snippets/webpack; cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/; cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/; npm install \ From 77ba015c433b3feeb2d0868a9a346f88cbe364ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Wed, 29 May 2019 11:03:43 +0200 Subject: [PATCH 06/26] [doctest] split compose btw sdk & doc tests --- .ci/doc/docker-compose.yml | 133 +++++++++++++++++++++++++++++++++++++ .ci/docker-compose.yml | 101 ---------------------------- .ci/start_kuzzle.sh | 2 +- 3 files changed, 134 insertions(+), 102 deletions(-) create mode 100644 .ci/doc/docker-compose.yml diff --git a/.ci/doc/docker-compose.yml b/.ci/doc/docker-compose.yml new file mode 100644 index 000000000..11c38dc5d --- /dev/null +++ b/.ci/doc/docker-compose.yml @@ -0,0 +1,133 @@ +version: '3' + +services: + kuzzle: + image: kuzzleio/kuzzle + ports: + - "7512:7512" + cap_add: + - SYS_PTRACE + depends_on: + - redis + - elasticsearch + container_name: kuzzle + environment: + - kuzzle_services__db__client__host=http://elasticsearch:9200 + - kuzzle_services__internalCache__node__host=redis + - kuzzle_services__memoryStorage__node__host=redis + - NODE_ENV=production + + redis: + image: redis:3.2 + + elasticsearch: + image: kuzzleio/elasticsearch:5.6.10 + ulimits: + nofile: 65536 + environment: + - cluster.name=kuzzle + - "ES_JAVA_OPTS=-Xms256m -Xmx256m" + + doc-tests: + image: kuzzleio/snippets-tests + privileged: true + depends_on: + - kuzzle + - doc-runner-node + - doc-runner-web + - doc-runner-webpack + volumes: + - ../..:/mnt + - /var/run/docker.sock:/var/run/docker.sock + - snippets:/var/snippets + environment: + - CONFIG_FILE=/mnt/.ci/doc/config.yml + + doc-runner-node: + image: node:8-alpine + command: > + ash -c ' + mkdir -p /var/snippets/node; + apk add --no-cache curl; + npm install -g \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + cd /var/snippets/node; + npm install \ + bluebird \ + /mnt/; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ../..:/mnt + - snippets:/var/snippets + + doc-runner-web: + image: buildkite/puppeteer:latest + command: > + bash -c ' + mkdir -p /var/snippets/web; + apt-get update; + apt-get install -y curl; + npm install -g \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + cd /var/snippets/web; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; + npm install \ + /mnt/ \ + puppeteer; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ../..:/mnt + - snippets:/var/snippets + + doc-runner-webpack: + image: buildkite/puppeteer:latest + command: > + bash -c ' + mkdir -p /var/snippets/webpack; + apt-get update; + apt-get install -y curl; + npm install -g \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + cd /var/snippets/webpack; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/; + cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/; + npm install \ + /mnt/ \ + babel-loader \ + @babel/core \ + puppeteer \ + html-webpack-plugin \ + webpack \ + webpack-cli; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ../..:/mnt + - snippets:/var/snippets + +volumes: + snippets: + diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 5a71dbcb4..50c1e4867 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -10,7 +10,6 @@ services: depends_on: - redis - elasticsearch - container_name: kuzzle environment: - kuzzle_services__db__client__host=http://elasticsearch:9200 - kuzzle_services__internalCache__node__host=redis @@ -28,106 +27,6 @@ services: - cluster.name=kuzzle - "ES_JAVA_OPTS=-Xms256m -Xmx256m" - doc-tests: - image: kuzzleio/snippets-tests - privileged: true - depends_on: - - kuzzle - - doc-runner-node - - doc-runner-web - - doc-runner-webpack - volumes: - - ..:/mnt - - /var/run/docker.sock:/var/run/docker.sock - - snippets:/var/snippets - environment: - - CONFIG_FILE=/mnt/.ci/doc/config.yml - - doc-runner-node: - image: node:8-alpine - command: > - ash -c ' - mkdir -p /var/snippets/node; - apk add --no-cache curl; - npm install -g \ - eslint \ - eslint-plugin-html \ - eslint-plugin-import \ - eslint-plugin-node \ - eslint-plugin-promise \ - eslint-plugin-standard; - touch /tmp/runner_ready_to_lint; - cd /var/snippets/node; - npm install \ - bluebird \ - /mnt/; - touch /tmp/runner_is_ready; - tail -f /dev/null - ' - volumes: - - ..:/mnt - - snippets:/var/snippets - - doc-runner-web: - image: buildkite/puppeteer:latest - command: > - bash -c ' - mkdir -p /var/snippets/web; - apt-get update; - apt-get install -y curl; - npm install -g \ - eslint \ - eslint-plugin-html \ - eslint-plugin-import \ - eslint-plugin-node \ - eslint-plugin-promise \ - eslint-plugin-standard; - touch /tmp/runner_ready_to_lint; - cd /var/snippets/web; - cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; - npm install \ - /mnt/ \ - puppeteer; - touch /tmp/runner_is_ready; - tail -f /dev/null - ' - volumes: - - ..:/mnt - - snippets:/var/snippets - - doc-runner-webpack: - image: buildkite/puppeteer:latest - command: > - bash -c ' - mkdir -p /var/snippets/webpack; - apt-get update; - apt-get install -y curl; - npm install -g \ - eslint \ - eslint-plugin-html \ - eslint-plugin-import \ - eslint-plugin-node \ - eslint-plugin-promise \ - eslint-plugin-standard; - touch /tmp/runner_ready_to_lint; - cd /var/snippets/webpack; - cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/; - cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/; - npm install \ - /mnt/ \ - babel-loader \ - @babel/core \ - puppeteer \ - html-webpack-plugin \ - webpack \ - webpack-cli; - touch /tmp/runner_is_ready; - tail -f /dev/null - ' - volumes: - - ..:/mnt - - snippets:/var/snippets - volumes: snippets: diff --git a/.ci/start_kuzzle.sh b/.ci/start_kuzzle.sh index 1acb2fc0e..539eec912 100755 --- a/.ci/start_kuzzle.sh +++ b/.ci/start_kuzzle.sh @@ -2,7 +2,7 @@ set -e # Download and launch custom Kuzzle stack -docker-compose -f .ci/docker-compose.yml run -d kuzzle +docker-compose -f .ci/docker-compose.yml up -d printf 'Waiting for Kuzzle stack to be up and running' From 9165a4acc8d7959301e873075ce0ffb4c229c892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Wed, 29 May 2019 11:07:17 +0200 Subject: [PATCH 07/26] [doctest] fix compose path for doc tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 69f575fbf..03958bd10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ jobs: node_js: 8 script: - - docker-compose -f .ci/docker-compose.yml run doc-tests node index + - docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index - stage: "Deploy Stable release on NPM" if: type != pull_request && branch = master From cc67b247cf34dc095bb3e343ba0b9ac54981811e Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Thu, 6 Jun 2019 15:58:34 +0200 Subject: [PATCH 08/26] Renamed directory to follow convention --- doc/{src => 6}/controllers/auth/check-token/index.md | 0 .../controllers/auth/check-token/snippets/check-token.js | 0 .../controllers/auth/check-token/snippets/check-token.test.yml | 0 doc/{src => 6}/controllers/auth/create-my-credentials/index.md | 0 .../auth/create-my-credentials/snippets/create-my-credentials.js | 0 .../create-my-credentials/snippets/create-my-credentials.test.yml | 0 doc/{src => 6}/controllers/auth/credentials-exist/index.md | 0 .../auth/credentials-exist/snippets/credentials-exist.js | 0 .../auth/credentials-exist/snippets/credentials-exist.test.yml | 0 doc/{src => 6}/controllers/auth/delete-my-credentials/index.md | 0 .../auth/delete-my-credentials/snippets/delete-my-credentials.js | 0 .../delete-my-credentials/snippets/delete-my-credentials.test.yml | 0 doc/{src => 6}/controllers/auth/get-current-user/index.md | 0 .../auth/get-current-user/snippets/get-current-user.js | 0 .../auth/get-current-user/snippets/get-current-user.test.yml | 0 doc/{src => 6}/controllers/auth/get-my-credentials/index.md | 0 .../auth/get-my-credentials/snippets/get-my-credentials.js | 0 .../auth/get-my-credentials/snippets/get-my-credentials.test.yml | 0 doc/{src => 6}/controllers/auth/get-my-rights/index.md | 0 .../controllers/auth/get-my-rights/snippets/get-my-rights.js | 0 .../auth/get-my-rights/snippets/get-my-rights.test.yml | 0 doc/{src => 6}/controllers/auth/get-strategies/index.md | 0 .../controllers/auth/get-strategies/snippets/get-strategies.js | 0 .../auth/get-strategies/snippets/get-strategies.test.yml | 0 doc/{src => 6}/controllers/auth/index.md | 0 doc/{src => 6}/controllers/auth/login/index.md | 0 doc/{src => 6}/controllers/auth/login/snippets/login.js | 0 doc/{src => 6}/controllers/auth/login/snippets/login.test.yml | 0 doc/{src => 6}/controllers/auth/logout/index.md | 0 doc/{src => 6}/controllers/auth/logout/snippets/logout.js | 0 doc/{src => 6}/controllers/auth/logout/snippets/logout.test.yml | 0 doc/{src => 6}/controllers/auth/update-my-credentials/index.md | 0 .../auth/update-my-credentials/snippets/update-my-credentials.js | 0 .../update-my-credentials/snippets/update-my-credentials.test.yml | 0 doc/{src => 6}/controllers/auth/update-self/index.md | 0 .../controllers/auth/update-self/snippets/update-self.js | 0 .../controllers/auth/update-self/snippets/update-self.test.yml | 0 doc/{src => 6}/controllers/auth/validate-my-credentials/index.md | 0 .../validate-my-credentials/snippets/validate-my-credentials.js | 0 .../snippets/validate-my-credentials.test.yml | 0 doc/{src => 6}/controllers/bulk/import/index.md | 0 doc/{src => 6}/controllers/bulk/import/snippets/import.js | 0 doc/{src => 6}/controllers/bulk/import/snippets/import.test.yml | 0 doc/{src => 6}/controllers/bulk/index.md | 0 doc/{src => 6}/controllers/collection/create/index.md | 0 doc/{src => 6}/controllers/collection/create/snippets/create.js | 0 .../controllers/collection/create/snippets/create.test.yml | 0 .../controllers/collection/delete-specifications/index.md | 0 .../delete-specifications/snippets/delete-specifications.js | 0 .../delete-specifications/snippets/delete-specifications.test.yml | 0 doc/{src => 6}/controllers/collection/exists/index.md | 0 doc/{src => 6}/controllers/collection/exists/snippets/exists.js | 0 .../controllers/collection/exists/snippets/exists.test.yml | 0 doc/{src => 6}/controllers/collection/get-mapping/index.md | 0 .../controllers/collection/get-mapping/snippets/get-mapping.js | 0 .../collection/get-mapping/snippets/get-mapping.test.yml | 0 doc/{src => 6}/controllers/collection/get-specifications/index.md | 0 .../collection/get-specifications/snippets/get-specifications.js | 0 .../get-specifications/snippets/get-specifications.test.yml | 0 doc/{src => 6}/controllers/collection/index.md | 0 doc/{src => 6}/controllers/collection/list/index.md | 0 doc/{src => 6}/controllers/collection/list/snippets/list.js | 0 doc/{src => 6}/controllers/collection/list/snippets/list.test.yml | 0 .../controllers/collection/search-specifications/index.md | 0 .../search-specifications/snippets/search-specifications.js | 0 .../search-specifications/snippets/search-specifications.test.yml | 0 doc/{src => 6}/controllers/collection/truncate/index.md | 0 .../controllers/collection/truncate/snippets/truncate.js | 0 .../controllers/collection/truncate/snippets/truncate.test.yml | 0 doc/{src => 6}/controllers/collection/update-mapping/index.md | 0 .../collection/update-mapping/snippets/update-mapping.js | 0 .../collection/update-mapping/snippets/update-mapping.test.yml | 0 .../controllers/collection/update-specifications/index.md | 0 .../update-specifications/snippets/update-specifications.js | 0 .../update-specifications/snippets/update-specifications.test.yml | 0 .../controllers/collection/validate-specifications/index.md | 0 .../validate-specifications/snippets/validate-specifications.js | 0 .../snippets/validate-specifications.test.yml | 0 doc/{src => 6}/controllers/document/count/index.md | 0 doc/{src => 6}/controllers/document/count/snippets/count.js | 0 doc/{src => 6}/controllers/document/count/snippets/count.test.yml | 0 doc/{src => 6}/controllers/document/create/index.md | 0 doc/{src => 6}/controllers/document/create/snippets/create.js | 0 .../controllers/document/create/snippets/create.test.yml | 0 doc/{src => 6}/controllers/document/createOrReplace/index.md | 0 .../document/createOrReplace/snippets/create-or-replace.js | 0 .../document/createOrReplace/snippets/create-or-replace.test.yml | 0 doc/{src => 6}/controllers/document/delete/index.md | 0 doc/{src => 6}/controllers/document/delete/snippets/delete.js | 0 .../controllers/document/delete/snippets/delete.test.yml | 0 doc/{src => 6}/controllers/document/deleteByQuery/index.md | 0 .../document/deleteByQuery/snippets/delete-by-query.js | 0 .../document/deleteByQuery/snippets/delete-by-query.test.yml | 0 doc/{src => 6}/controllers/document/get/index.md | 0 doc/{src => 6}/controllers/document/get/snippets/get.js | 0 doc/{src => 6}/controllers/document/get/snippets/get.test.yml | 0 doc/{src => 6}/controllers/document/index.md | 0 doc/{src => 6}/controllers/document/mCreate/index.md | 0 doc/{src => 6}/controllers/document/mCreate/snippets/m-create.js | 0 .../controllers/document/mCreate/snippets/m-create.test.yml | 0 doc/{src => 6}/controllers/document/mCreateOrReplace/index.md | 0 .../document/mCreateOrReplace/snippets/m-create-or-replace.js | 0 .../mCreateOrReplace/snippets/m-create-or-replace.test.yml | 0 doc/{src => 6}/controllers/document/mDelete/index.md | 0 doc/{src => 6}/controllers/document/mDelete/snippets/m-delete.js | 0 .../controllers/document/mDelete/snippets/m-delete.test.yml | 0 doc/{src => 6}/controllers/document/mGet/index.md | 0 doc/{src => 6}/controllers/document/mGet/snippets/m-get.js | 0 doc/{src => 6}/controllers/document/mGet/snippets/m-get.test.yml | 0 doc/{src => 6}/controllers/document/mReplace/index.md | 0 .../controllers/document/mReplace/snippets/m-replace.js | 0 .../controllers/document/mReplace/snippets/m-replace.test.yml | 0 doc/{src => 6}/controllers/document/mUpdate/index.md | 0 doc/{src => 6}/controllers/document/mUpdate/snippets/m-update.js | 0 .../controllers/document/mUpdate/snippets/m-update.test.yml | 0 doc/{src => 6}/controllers/document/replace/index.md | 0 doc/{src => 6}/controllers/document/replace/snippets/replace.js | 0 .../controllers/document/replace/snippets/replace.test.yml | 0 doc/{src => 6}/controllers/document/search/index.md | 0 doc/{src => 6}/controllers/document/search/snippets/search.js | 0 .../controllers/document/search/snippets/search.test.yml | 0 doc/{src => 6}/controllers/document/update/index.md | 0 doc/{src => 6}/controllers/document/update/snippets/update.js | 0 .../controllers/document/update/snippets/update.test.yml | 0 doc/{src => 6}/controllers/document/validate/index.md | 0 doc/{src => 6}/controllers/document/validate/snippets/validate.js | 0 .../controllers/document/validate/snippets/validate.test.yml | 0 doc/{src => 6}/controllers/index.md | 0 doc/{src => 6}/controllers/index/create/index.md | 0 doc/{src => 6}/controllers/index/create/snippets/create.js | 0 doc/{src => 6}/controllers/index/create/snippets/create.test.yml | 0 doc/{src => 6}/controllers/index/delete/index.md | 0 doc/{src => 6}/controllers/index/delete/snippets/delete.js | 0 doc/{src => 6}/controllers/index/delete/snippets/delete.test.yml | 0 doc/{src => 6}/controllers/index/exists/index.md | 0 doc/{src => 6}/controllers/index/exists/snippets/exists.js | 0 doc/{src => 6}/controllers/index/exists/snippets/exists.test.yml | 0 doc/{src => 6}/controllers/index/get-auto-refresh/index.md | 0 .../controllers/index/get-auto-refresh/snippets/getAutoRefresh.js | 0 .../index/get-auto-refresh/snippets/getAutoRefresh.test.yml | 0 doc/{src => 6}/controllers/index/index.md | 0 doc/{src => 6}/controllers/index/list/index.md | 0 doc/{src => 6}/controllers/index/list/snippets/list.js | 0 doc/{src => 6}/controllers/index/list/snippets/list.test.yml | 0 doc/{src => 6}/controllers/index/m-delete/index.md | 0 doc/{src => 6}/controllers/index/m-delete/snippets/mDelete.js | 0 .../controllers/index/m-delete/snippets/mDelete.test.yml | 0 doc/{src => 6}/controllers/index/refresh-internal/index.md | 0 .../index/refresh-internal/snippets/refreshInternal.js | 0 .../index/refresh-internal/snippets/refreshInternal.test.yml | 0 doc/{src => 6}/controllers/index/refresh/index.md | 0 doc/{src => 6}/controllers/index/refresh/snippets/refresh.js | 0 .../controllers/index/refresh/snippets/refresh.test.yml | 0 doc/{src => 6}/controllers/index/set-auto-refresh/index.md | 0 .../controllers/index/set-auto-refresh/snippets/setAutoRefresh.js | 0 .../index/set-auto-refresh/snippets/setAutoRefresh.test.yml | 0 doc/{src => 6}/controllers/ms/append/index.md | 0 doc/{src => 6}/controllers/ms/append/snippets/append.js | 0 doc/{src => 6}/controllers/ms/append/snippets/append.test.yml | 0 doc/{src => 6}/controllers/ms/bitcount/index.md | 0 doc/{src => 6}/controllers/ms/bitcount/snippets/bitcount.js | 0 doc/{src => 6}/controllers/ms/bitcount/snippets/bitcount.test.yml | 0 doc/{src => 6}/controllers/ms/bitop/index.md | 0 doc/{src => 6}/controllers/ms/bitop/snippets/bitop.js | 0 doc/{src => 6}/controllers/ms/bitop/snippets/bitop.test.yml | 0 doc/{src => 6}/controllers/ms/bitpos/index.md | 0 doc/{src => 6}/controllers/ms/bitpos/snippets/bitpos.js | 0 doc/{src => 6}/controllers/ms/bitpos/snippets/bitpos.test.yml | 0 doc/{src => 6}/controllers/ms/dbsize/index.md | 0 doc/{src => 6}/controllers/ms/dbsize/snippets/dbsize.js | 0 doc/{src => 6}/controllers/ms/dbsize/snippets/dbsize.test.yml | 0 doc/{src => 6}/controllers/ms/decr/index.md | 0 doc/{src => 6}/controllers/ms/decr/snippets/decr.js | 0 doc/{src => 6}/controllers/ms/decr/snippets/decr.test.yml | 0 doc/{src => 6}/controllers/ms/decrby/index.md | 0 doc/{src => 6}/controllers/ms/decrby/snippets/decrby.js | 0 doc/{src => 6}/controllers/ms/decrby/snippets/decrby.test.yml | 0 doc/{src => 6}/controllers/ms/del/index.md | 0 doc/{src => 6}/controllers/ms/del/snippets/del.js | 0 doc/{src => 6}/controllers/ms/del/snippets/del.test.yml | 0 doc/{src => 6}/controllers/ms/exists/index.md | 0 doc/{src => 6}/controllers/ms/exists/snippets/exists.js | 0 doc/{src => 6}/controllers/ms/exists/snippets/exists.test.yml | 0 doc/{src => 6}/controllers/ms/expire/index.md | 0 doc/{src => 6}/controllers/ms/expire/snippets/expire.js | 0 doc/{src => 6}/controllers/ms/expire/snippets/expire.test.yml | 0 doc/{src => 6}/controllers/ms/expireat/index.md | 0 doc/{src => 6}/controllers/ms/expireat/snippets/expireat.js | 0 doc/{src => 6}/controllers/ms/expireat/snippets/expireat.test.yml | 0 doc/{src => 6}/controllers/ms/flushdb/index.md | 0 doc/{src => 6}/controllers/ms/flushdb/snippets/flushdb.js | 0 doc/{src => 6}/controllers/ms/flushdb/snippets/flushdb.test.yml | 0 doc/{src => 6}/controllers/ms/geoadd/index.md | 0 doc/{src => 6}/controllers/ms/geoadd/snippets/geoadd.js | 0 doc/{src => 6}/controllers/ms/geoadd/snippets/geoadd.test.yml | 0 doc/{src => 6}/controllers/ms/geodist/index.md | 0 doc/{src => 6}/controllers/ms/geodist/snippets/geodist.js | 0 doc/{src => 6}/controllers/ms/geodist/snippets/geodist.test.yml | 0 doc/{src => 6}/controllers/ms/geohash/index.md | 0 doc/{src => 6}/controllers/ms/geohash/snippets/geohash.js | 0 doc/{src => 6}/controllers/ms/geohash/snippets/geohash.test.yml | 0 doc/{src => 6}/controllers/ms/geopos/index.md | 0 doc/{src => 6}/controllers/ms/geopos/snippets/geopos.js | 0 doc/{src => 6}/controllers/ms/geopos/snippets/geopos.test.yml | 0 doc/{src => 6}/controllers/ms/georadius/index.md | 0 doc/{src => 6}/controllers/ms/georadius/snippets/georadius.js | 0 .../controllers/ms/georadius/snippets/georadius.test.yml | 0 doc/{src => 6}/controllers/ms/georadiusbymember/index.md | 0 .../ms/georadiusbymember/snippets/georadiusbymember.js | 0 .../ms/georadiusbymember/snippets/georadiusbymember.test.yml | 0 doc/{src => 6}/controllers/ms/get/index.md | 0 doc/{src => 6}/controllers/ms/get/snippets/get.js | 0 doc/{src => 6}/controllers/ms/get/snippets/get.test.yml | 0 doc/{src => 6}/controllers/ms/getbit/index.md | 0 doc/{src => 6}/controllers/ms/getbit/snippets/getbit.js | 0 doc/{src => 6}/controllers/ms/getbit/snippets/getbit.test.yml | 0 doc/{src => 6}/controllers/ms/getrange/index.md | 0 doc/{src => 6}/controllers/ms/getrange/snippets/getrange.js | 0 doc/{src => 6}/controllers/ms/getrange/snippets/getrange.test.yml | 0 doc/{src => 6}/controllers/ms/getset/index.md | 0 doc/{src => 6}/controllers/ms/getset/snippets/getset.js | 0 doc/{src => 6}/controllers/ms/getset/snippets/getset.test.yml | 0 doc/{src => 6}/controllers/ms/hdel/index.md | 0 doc/{src => 6}/controllers/ms/hdel/snippets/hdel.js | 0 doc/{src => 6}/controllers/ms/hdel/snippets/hdel.test.yml | 0 doc/{src => 6}/controllers/ms/hexists/index.md | 0 doc/{src => 6}/controllers/ms/hexists/snippets/hexists.js | 0 doc/{src => 6}/controllers/ms/hexists/snippets/hexists.test.yml | 0 doc/{src => 6}/controllers/ms/hget/index.md | 0 doc/{src => 6}/controllers/ms/hget/snippets/hget.js | 0 doc/{src => 6}/controllers/ms/hget/snippets/hget.test.yml | 0 doc/{src => 6}/controllers/ms/hgetall/index.md | 0 doc/{src => 6}/controllers/ms/hgetall/snippets/hgetall.js | 0 doc/{src => 6}/controllers/ms/hgetall/snippets/hgetall.test.yml | 0 doc/{src => 6}/controllers/ms/hincrby/index.md | 0 doc/{src => 6}/controllers/ms/hincrby/snippets/hincrby.js | 0 doc/{src => 6}/controllers/ms/hincrby/snippets/hincrby.test.yml | 0 doc/{src => 6}/controllers/ms/hincrbyfloat/index.md | 0 .../controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js | 0 .../controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml | 0 doc/{src => 6}/controllers/ms/hkeys/index.md | 0 doc/{src => 6}/controllers/ms/hkeys/snippets/hkeys.js | 0 doc/{src => 6}/controllers/ms/hkeys/snippets/hkeys.test.yml | 0 doc/{src => 6}/controllers/ms/hlen/index.md | 0 doc/{src => 6}/controllers/ms/hlen/snippets/hlen.js | 0 doc/{src => 6}/controllers/ms/hlen/snippets/hlen.test.yml | 0 doc/{src => 6}/controllers/ms/hmget/index.md | 0 doc/{src => 6}/controllers/ms/hmget/snippets/hmget.js | 0 doc/{src => 6}/controllers/ms/hmget/snippets/hmget.test.yml | 0 doc/{src => 6}/controllers/ms/hmset/index.md | 0 doc/{src => 6}/controllers/ms/hmset/snippets/hmset.js | 0 doc/{src => 6}/controllers/ms/hmset/snippets/hmset.test.yml | 0 doc/{src => 6}/controllers/ms/hscan/index.md | 0 doc/{src => 6}/controllers/ms/hscan/snippets/hscan.js | 0 doc/{src => 6}/controllers/ms/hscan/snippets/hscan.test.yml | 0 doc/{src => 6}/controllers/ms/hset/index.md | 0 doc/{src => 6}/controllers/ms/hset/snippets/hset.js | 0 doc/{src => 6}/controllers/ms/hset/snippets/hset.test.yml | 0 doc/{src => 6}/controllers/ms/hsetnx/index.md | 0 doc/{src => 6}/controllers/ms/hsetnx/snippets/hsetnx.js | 0 doc/{src => 6}/controllers/ms/hsetnx/snippets/hsetnx.test.yml | 0 doc/{src => 6}/controllers/ms/hstrlen/index.md | 0 doc/{src => 6}/controllers/ms/hstrlen/snippets/hstrlen.js | 0 doc/{src => 6}/controllers/ms/hstrlen/snippets/hstrlen.test.yml | 0 doc/{src => 6}/controllers/ms/hvals/index.md | 0 doc/{src => 6}/controllers/ms/hvals/snippets/hvals.js | 0 doc/{src => 6}/controllers/ms/hvals/snippets/hvals.test.yml | 0 doc/{src => 6}/controllers/ms/incr/index.md | 0 doc/{src => 6}/controllers/ms/incr/snippets/incr.js | 0 doc/{src => 6}/controllers/ms/incr/snippets/incr.test.yml | 0 doc/{src => 6}/controllers/ms/incrby/index.md | 0 doc/{src => 6}/controllers/ms/incrby/snippets/incrby.js | 0 doc/{src => 6}/controllers/ms/incrby/snippets/incrby.test.yml | 0 doc/{src => 6}/controllers/ms/incrbyfloat/index.md | 0 doc/{src => 6}/controllers/ms/incrbyfloat/snippets/incrbyfloat.js | 0 .../controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml | 0 doc/{src => 6}/controllers/ms/index.md | 0 doc/{src => 6}/controllers/ms/keys/index.md | 0 doc/{src => 6}/controllers/ms/keys/snippets/keys.js | 0 doc/{src => 6}/controllers/ms/keys/snippets/keys.test.yml | 0 doc/{src => 6}/controllers/ms/lindex/index.md | 0 doc/{src => 6}/controllers/ms/lindex/snippets/lindex.js | 0 doc/{src => 6}/controllers/ms/lindex/snippets/lindex.test.yml | 0 doc/{src => 6}/controllers/ms/linsert/index.md | 0 doc/{src => 6}/controllers/ms/linsert/snippets/linsert.js | 0 doc/{src => 6}/controllers/ms/linsert/snippets/linsert.test.yml | 0 doc/{src => 6}/controllers/ms/llen/index.md | 0 doc/{src => 6}/controllers/ms/llen/snippets/llen.js | 0 doc/{src => 6}/controllers/ms/llen/snippets/llen.test.yml | 0 doc/{src => 6}/controllers/ms/lpop/index.md | 0 doc/{src => 6}/controllers/ms/lpop/snippets/lpop.js | 0 doc/{src => 6}/controllers/ms/lpop/snippets/lpop.test.yml | 0 doc/{src => 6}/controllers/ms/lpush/index.md | 0 doc/{src => 6}/controllers/ms/lpush/snippets/lpush.js | 0 doc/{src => 6}/controllers/ms/lpush/snippets/lpush.test.yml | 0 doc/{src => 6}/controllers/ms/lpushx/index.md | 0 doc/{src => 6}/controllers/ms/lpushx/snippets/lpushx.js | 0 doc/{src => 6}/controllers/ms/lpushx/snippets/lpushx.test.yml | 0 doc/{src => 6}/controllers/ms/lrange/index.md | 0 doc/{src => 6}/controllers/ms/lrange/snippets/lrange.js | 0 doc/{src => 6}/controllers/ms/lrange/snippets/lrange.test.yml | 0 doc/{src => 6}/controllers/ms/lrem/index.md | 0 doc/{src => 6}/controllers/ms/lrem/snippets/lrem.js | 0 doc/{src => 6}/controllers/ms/lrem/snippets/lrem.test.yml | 0 doc/{src => 6}/controllers/ms/lset/index.md | 0 doc/{src => 6}/controllers/ms/lset/snippets/lset.js | 0 doc/{src => 6}/controllers/ms/lset/snippets/lset.test.yml | 0 doc/{src => 6}/controllers/ms/ltrim/index.md | 0 doc/{src => 6}/controllers/ms/ltrim/snippets/ltrim.js | 0 doc/{src => 6}/controllers/ms/ltrim/snippets/ltrim.test.yml | 0 doc/{src => 6}/controllers/ms/mget/index.md | 0 doc/{src => 6}/controllers/ms/mget/snippets/mget.js | 0 doc/{src => 6}/controllers/ms/mget/snippets/mget.test.yml | 0 doc/{src => 6}/controllers/ms/mset/index.md | 0 doc/{src => 6}/controllers/ms/mset/snippets/mset.js | 0 doc/{src => 6}/controllers/ms/mset/snippets/mset.test.yml | 0 doc/{src => 6}/controllers/ms/msetnx/index.md | 0 doc/{src => 6}/controllers/ms/msetnx/snippets/msetnx.js | 0 doc/{src => 6}/controllers/ms/msetnx/snippets/msetnx.test.yml | 0 doc/{src => 6}/controllers/ms/object/index.md | 0 doc/{src => 6}/controllers/ms/object/snippets/object.js | 0 doc/{src => 6}/controllers/ms/object/snippets/object.test.yml | 0 doc/{src => 6}/controllers/ms/persist/index.md | 0 doc/{src => 6}/controllers/ms/persist/snippets/persist.js | 0 doc/{src => 6}/controllers/ms/persist/snippets/persist.test.yml | 0 doc/{src => 6}/controllers/ms/pexpire/index.md | 0 doc/{src => 6}/controllers/ms/pexpire/snippets/pexpire.js | 0 doc/{src => 6}/controllers/ms/pexpire/snippets/pexpire.test.yml | 0 doc/{src => 6}/controllers/ms/pexpireat/index.md | 0 doc/{src => 6}/controllers/ms/pexpireat/snippets/pexpireat.js | 0 .../controllers/ms/pexpireat/snippets/pexpireat.test.yml | 0 doc/{src => 6}/controllers/ms/pfadd/index.md | 0 doc/{src => 6}/controllers/ms/pfadd/snippets/pfadd.js | 0 doc/{src => 6}/controllers/ms/pfadd/snippets/pfadd.test.yml | 0 doc/{src => 6}/controllers/ms/pfcount/index.md | 0 doc/{src => 6}/controllers/ms/pfcount/snippets/pfcount.js | 0 doc/{src => 6}/controllers/ms/pfcount/snippets/pfcount.test.yml | 0 doc/{src => 6}/controllers/ms/pfmerge/index.md | 0 doc/{src => 6}/controllers/ms/pfmerge/snippets/pfmerge.js | 0 doc/{src => 6}/controllers/ms/pfmerge/snippets/pfmerge.test.yml | 0 doc/{src => 6}/controllers/ms/ping/index.md | 0 doc/{src => 6}/controllers/ms/ping/snippets/ping.js | 0 doc/{src => 6}/controllers/ms/ping/snippets/ping.test.yml | 0 doc/{src => 6}/controllers/ms/psetex/index.md | 0 doc/{src => 6}/controllers/ms/psetex/snippets/psetex.js | 0 doc/{src => 6}/controllers/ms/psetex/snippets/psetex.test.yml | 0 doc/{src => 6}/controllers/ms/pttl/index.md | 0 doc/{src => 6}/controllers/ms/pttl/snippets/pttl.js | 0 doc/{src => 6}/controllers/ms/pttl/snippets/pttl.test.yml | 0 doc/{src => 6}/controllers/ms/randomkey/index.md | 0 doc/{src => 6}/controllers/ms/randomkey/snippets/randomkey.js | 0 .../controllers/ms/randomkey/snippets/randomkey.test.yml | 0 doc/{src => 6}/controllers/ms/rename/index.md | 0 doc/{src => 6}/controllers/ms/rename/snippets/rename.js | 0 doc/{src => 6}/controllers/ms/rename/snippets/rename.test.yml | 0 doc/{src => 6}/controllers/ms/renamenx/index.md | 0 doc/{src => 6}/controllers/ms/renamenx/snippets/renamenx.js | 0 doc/{src => 6}/controllers/ms/renamenx/snippets/renamenx.test.yml | 0 doc/{src => 6}/controllers/ms/rpop/index.md | 0 doc/{src => 6}/controllers/ms/rpop/snippets/rpop.js | 0 doc/{src => 6}/controllers/ms/rpop/snippets/rpop.test.yml | 0 doc/{src => 6}/controllers/ms/rpoplpush/index.md | 0 doc/{src => 6}/controllers/ms/rpoplpush/snippets/rpoplpush.js | 0 .../controllers/ms/rpoplpush/snippets/rpoplpush.test.yml | 0 doc/{src => 6}/controllers/ms/rpush/index.md | 0 doc/{src => 6}/controllers/ms/rpush/snippets/rpush.js | 0 doc/{src => 6}/controllers/ms/rpush/snippets/rpush.test.yml | 0 doc/{src => 6}/controllers/ms/rpushx/index.md | 0 doc/{src => 6}/controllers/ms/rpushx/snippets/rpushx.js | 0 doc/{src => 6}/controllers/ms/rpushx/snippets/rpushx.test.yml | 0 doc/{src => 6}/controllers/ms/sadd/index.md | 0 doc/{src => 6}/controllers/ms/sadd/snippets/sadd.js | 0 doc/{src => 6}/controllers/ms/sadd/snippets/sadd.test.yml | 0 doc/{src => 6}/controllers/ms/scan/index.md | 0 doc/{src => 6}/controllers/ms/scan/snippets/scan.js | 0 doc/{src => 6}/controllers/ms/scan/snippets/scan.test.yml | 0 doc/{src => 6}/controllers/ms/scard/index.md | 0 doc/{src => 6}/controllers/ms/scard/snippets/scard.js | 0 doc/{src => 6}/controllers/ms/scard/snippets/scard.test.yml | 0 doc/{src => 6}/controllers/ms/sdiff/index.md | 0 doc/{src => 6}/controllers/ms/sdiff/snippets/sdiff.js | 0 doc/{src => 6}/controllers/ms/sdiff/snippets/sdiff.test.yml | 0 doc/{src => 6}/controllers/ms/sdiffstore/index.md | 0 doc/{src => 6}/controllers/ms/sdiffstore/snippets/sdiffstore.js | 0 .../controllers/ms/sdiffstore/snippets/sdiffstore.test.yml | 0 doc/{src => 6}/controllers/ms/set/index.md | 0 doc/{src => 6}/controllers/ms/set/snippets/set.js | 0 doc/{src => 6}/controllers/ms/set/snippets/set.test.yml | 0 doc/{src => 6}/controllers/ms/setex/index.md | 0 doc/{src => 6}/controllers/ms/setex/snippets/setex.js | 0 doc/{src => 6}/controllers/ms/setex/snippets/setex.test.yml | 0 doc/{src => 6}/controllers/ms/setnx/index.md | 0 doc/{src => 6}/controllers/ms/setnx/snippets/setnx.js | 0 doc/{src => 6}/controllers/ms/setnx/snippets/setnx.test.yml | 0 doc/{src => 6}/controllers/ms/sinter/index.md | 0 doc/{src => 6}/controllers/ms/sinter/snippets/sinter.js | 0 doc/{src => 6}/controllers/ms/sinter/snippets/sinter.test.yml | 0 doc/{src => 6}/controllers/ms/sinterstore/index.md | 0 doc/{src => 6}/controllers/ms/sinterstore/snippets/sinterstore.js | 0 .../controllers/ms/sinterstore/snippets/sinterstore.test.yml | 0 doc/{src => 6}/controllers/ms/sismember/index.md | 0 doc/{src => 6}/controllers/ms/sismember/snippets/sismember.js | 0 .../controllers/ms/sismember/snippets/sismember.test.yml | 0 doc/{src => 6}/controllers/ms/smembers/index.md | 0 doc/{src => 6}/controllers/ms/smembers/snippets/smembers.js | 0 doc/{src => 6}/controllers/ms/smembers/snippets/smembers.test.yml | 0 doc/{src => 6}/controllers/ms/smove/index.md | 0 doc/{src => 6}/controllers/ms/smove/snippets/smove.js | 0 doc/{src => 6}/controllers/ms/smove/snippets/smove.test.yml | 0 doc/{src => 6}/controllers/ms/sort/index.md | 0 doc/{src => 6}/controllers/ms/sort/snippets/sort.js | 0 doc/{src => 6}/controllers/ms/sort/snippets/sort.test.yml | 0 doc/{src => 6}/controllers/ms/spop/index.md | 0 doc/{src => 6}/controllers/ms/spop/snippets/spop.js | 0 doc/{src => 6}/controllers/ms/spop/snippets/spop.test.yml | 0 doc/{src => 6}/controllers/ms/srandmember/index.md | 0 doc/{src => 6}/controllers/ms/srandmember/snippets/srandmember.js | 0 .../controllers/ms/srandmember/snippets/srandmember.test.yml | 0 doc/{src => 6}/controllers/ms/srem/index.md | 0 doc/{src => 6}/controllers/ms/srem/snippets/srem.js | 0 doc/{src => 6}/controllers/ms/srem/snippets/srem.test.yml | 0 doc/{src => 6}/controllers/ms/sscan/index.md | 0 doc/{src => 6}/controllers/ms/sscan/snippets/sscan.js | 0 doc/{src => 6}/controllers/ms/sscan/snippets/sscan.test.yml | 0 doc/{src => 6}/controllers/ms/strlen/index.md | 0 doc/{src => 6}/controllers/ms/strlen/snippets/strlen.js | 0 doc/{src => 6}/controllers/ms/strlen/snippets/strlen.test.yml | 0 doc/{src => 6}/controllers/ms/sunion/index.md | 0 doc/{src => 6}/controllers/ms/sunion/snippets/sunion.js | 0 doc/{src => 6}/controllers/ms/sunion/snippets/sunion.test.yml | 0 doc/{src => 6}/controllers/ms/sunionstore/index.md | 0 doc/{src => 6}/controllers/ms/sunionstore/snippets/sunionstore.js | 0 .../controllers/ms/sunionstore/snippets/sunionstore.test.yml | 0 doc/{src => 6}/controllers/ms/time/index.md | 0 doc/{src => 6}/controllers/ms/time/snippets/time.js | 0 doc/{src => 6}/controllers/ms/time/snippets/time.test.yml | 0 doc/{src => 6}/controllers/ms/touch/index.md | 0 doc/{src => 6}/controllers/ms/touch/snippets/touch.js | 0 doc/{src => 6}/controllers/ms/touch/snippets/touch.test.yml | 0 doc/{src => 6}/controllers/ms/ttl/index.md | 0 doc/{src => 6}/controllers/ms/ttl/snippets/ttl.js | 0 doc/{src => 6}/controllers/ms/ttl/snippets/ttl.test.yml | 0 doc/{src => 6}/controllers/ms/type/index.md | 0 doc/{src => 6}/controllers/ms/type/snippets/type.js | 0 doc/{src => 6}/controllers/ms/type/snippets/type.test.yml | 0 doc/{src => 6}/controllers/ms/zadd/index.md | 0 doc/{src => 6}/controllers/ms/zadd/snippets/zadd.js | 0 doc/{src => 6}/controllers/ms/zadd/snippets/zadd.test.yml | 0 doc/{src => 6}/controllers/ms/zcard/index.md | 0 doc/{src => 6}/controllers/ms/zcard/snippets/zcard.js | 0 doc/{src => 6}/controllers/ms/zcard/snippets/zcard.test.yml | 0 doc/{src => 6}/controllers/ms/zcount/index.md | 0 doc/{src => 6}/controllers/ms/zcount/snippets/zcount.js | 0 doc/{src => 6}/controllers/ms/zcount/snippets/zcount.test.yml | 0 doc/{src => 6}/controllers/ms/zincrby/index.md | 0 doc/{src => 6}/controllers/ms/zincrby/snippets/zincrby.js | 0 doc/{src => 6}/controllers/ms/zincrby/snippets/zincrby.test.yml | 0 doc/{src => 6}/controllers/ms/zinterstore/index.md | 0 doc/{src => 6}/controllers/ms/zinterstore/snippets/zinterstore.js | 0 .../controllers/ms/zinterstore/snippets/zinterstore.test.yml | 0 doc/{src => 6}/controllers/ms/zlexcount/index.md | 0 doc/{src => 6}/controllers/ms/zlexcount/snippets/zlexcount.js | 0 .../controllers/ms/zlexcount/snippets/zlexcount.test.yml | 0 doc/{src => 6}/controllers/ms/zrange/index.md | 0 doc/{src => 6}/controllers/ms/zrange/snippets/zrange.js | 0 doc/{src => 6}/controllers/ms/zrange/snippets/zrange.test.yml | 0 doc/{src => 6}/controllers/ms/zrangebylex/index.md | 0 doc/{src => 6}/controllers/ms/zrangebylex/snippets/zrangebylex.js | 0 .../controllers/ms/zrangebylex/snippets/zrangebylex.test.yml | 0 doc/{src => 6}/controllers/ms/zrangebyscore/index.md | 0 .../controllers/ms/zrangebyscore/snippets/zrangebyscore.js | 0 .../controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml | 0 doc/{src => 6}/controllers/ms/zrank/index.md | 0 doc/{src => 6}/controllers/ms/zrank/snippets/zrank.js | 0 doc/{src => 6}/controllers/ms/zrank/snippets/zrank.test.yml | 0 doc/{src => 6}/controllers/ms/zrem/index.md | 0 doc/{src => 6}/controllers/ms/zrem/snippets/zrem.js | 0 doc/{src => 6}/controllers/ms/zrem/snippets/zrem.test.yml | 0 doc/{src => 6}/controllers/ms/zremrangebylex/index.md | 0 .../controllers/ms/zremrangebylex/snippets/zremrangebylex.js | 0 .../ms/zremrangebylex/snippets/zremrangebylex.test.yml | 0 doc/{src => 6}/controllers/ms/zremrangebyrank/index.md | 0 .../controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js | 0 .../ms/zremrangebyrank/snippets/zremrangebyrank.test.yml | 0 doc/{src => 6}/controllers/ms/zremrangebyscore/index.md | 0 .../controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js | 0 .../ms/zremrangebyscore/snippets/zremrangebyscore.test.yml | 0 doc/{src => 6}/controllers/ms/zrevrange/index.md | 0 doc/{src => 6}/controllers/ms/zrevrange/snippets/zrevrange.js | 0 .../controllers/ms/zrevrange/snippets/zrevrange.test.yml | 0 doc/{src => 6}/controllers/ms/zrevrangebylex/index.md | 0 .../controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js | 0 .../ms/zrevrangebylex/snippets/zrevrangebylex.test.yml | 0 doc/{src => 6}/controllers/ms/zrevrangebyscore/index.md | 0 .../controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js | 0 .../ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml | 0 doc/{src => 6}/controllers/ms/zrevrank/index.md | 0 doc/{src => 6}/controllers/ms/zrevrank/snippets/zrevrank.js | 0 doc/{src => 6}/controllers/ms/zrevrank/snippets/zrevrank.test.yml | 0 doc/{src => 6}/controllers/ms/zscan/index.md | 0 doc/{src => 6}/controllers/ms/zscan/snippets/zscan.js | 0 doc/{src => 6}/controllers/ms/zscan/snippets/zscan.test.yml | 0 doc/{src => 6}/controllers/ms/zscore/index.md | 0 doc/{src => 6}/controllers/ms/zscore/snippets/zscore.js | 0 doc/{src => 6}/controllers/ms/zscore/snippets/zscore.test.yml | 0 doc/{src => 6}/controllers/ms/zunionstore/index.md | 0 doc/{src => 6}/controllers/ms/zunionstore/snippets/zunionstore.js | 0 .../controllers/ms/zunionstore/snippets/zunionstore.test.yml | 0 doc/{src => 6}/controllers/realtime/count/index.md | 0 doc/{src => 6}/controllers/realtime/count/snippets/count.js | 0 doc/{src => 6}/controllers/realtime/count/snippets/count.test.yml | 0 doc/{src => 6}/controllers/realtime/index.md | 0 doc/{src => 6}/controllers/realtime/publish/index.md | 0 doc/{src => 6}/controllers/realtime/publish/snippets/publish.js | 0 .../controllers/realtime/publish/snippets/publish.test.yml | 0 doc/{src => 6}/controllers/realtime/subscribe/index.md | 0 .../subscribe/snippets/document-notifications-leave-scope.js | 0 .../snippets/document-notifications-leave-scope.test.yml | 0 .../realtime/subscribe/snippets/document-notifications.js | 0 .../realtime/subscribe/snippets/document-notifications.test.yml | 0 .../realtime/subscribe/snippets/message-notifications.js | 0 .../realtime/subscribe/snippets/message-notifications.test.yml | 0 .../controllers/realtime/subscribe/snippets/user-notifications.js | 0 .../realtime/subscribe/snippets/user-notifications.test.yml | 0 doc/{src => 6}/controllers/realtime/unsubscribe/index.md | 0 .../controllers/realtime/unsubscribe/snippets/unsubscribe.js | 0 .../realtime/unsubscribe/snippets/unsubscribe.test.yml | 0 doc/{src => 6}/controllers/server/admin-exists/index.md | 0 .../controllers/server/admin-exists/snippets/admin-exists.js | 0 .../server/admin-exists/snippets/admin-exists.test.yml | 0 doc/{src => 6}/controllers/server/get-all-stats/index.md | 0 .../controllers/server/get-all-stats/snippets/get-all-stats.js | 0 .../server/get-all-stats/snippets/get-all-stats.test.yml | 0 doc/{src => 6}/controllers/server/get-config/index.md | 0 .../controllers/server/get-config/snippets/get-config.js | 0 .../controllers/server/get-config/snippets/get-config.test.yml | 0 doc/{src => 6}/controllers/server/get-last-stats/index.md | 0 .../controllers/server/get-last-stats/snippets/get-last-stats.js | 0 .../server/get-last-stats/snippets/get-last-stats.test.yml | 0 doc/{src => 6}/controllers/server/get-stats/index.md | 0 doc/{src => 6}/controllers/server/get-stats/snippets/get-stats.js | 0 .../controllers/server/get-stats/snippets/get-stats.test.yml | 0 doc/{src => 6}/controllers/server/index.md | 0 doc/{src => 6}/controllers/server/info/index.md | 0 doc/{src => 6}/controllers/server/info/snippets/info.js | 0 doc/{src => 6}/controllers/server/info/snippets/info.test.yml | 0 doc/{src => 6}/controllers/server/now/index.md | 0 doc/{src => 6}/controllers/server/now/snippets/now.js | 0 doc/{src => 6}/controllers/server/now/snippets/now.test.yml | 0 doc/{src => 6}/core-classes/index.md | 0 doc/{src => 6}/core-classes/kuzzle-error/index.md | 0 doc/{src => 6}/core-classes/kuzzle-error/introduction/index.md | 0 .../core-classes/kuzzle-event-emitter/add-once-listener/index.md | 0 .../add-once-listener/snippets/add-once-listener.js | 0 .../add-once-listener/snippets/add-once-listener.test.yml | 0 doc/{src => 6}/core-classes/kuzzle-event-emitter/emit/index.md | 0 .../core-classes/kuzzle-event-emitter/emit/snippets/emit.js | 0 .../core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml | 0 doc/{src => 6}/core-classes/kuzzle-event-emitter/index.md | 0 .../core-classes/kuzzle-event-emitter/introduction/index.md | 0 .../core-classes/kuzzle-event-emitter/listeners/index.md | 0 .../kuzzle-event-emitter/listeners/snippets/listeners.js | 0 .../kuzzle-event-emitter/listeners/snippets/listeners.test.yml | 0 doc/{src => 6}/core-classes/kuzzle-event-emitter/on/index.md | 0 doc/{src => 6}/core-classes/kuzzle-event-emitter/once/index.md | 0 .../core-classes/kuzzle-event-emitter/prepend-listener/index.md | 0 .../prepend-listener/snippets/prepend-listener.js | 0 .../prepend-listener/snippets/prepend-listener.test.yml | 0 .../kuzzle-event-emitter/prepend-once-listener/index.md | 0 .../prepend-once-listener/snippets/prepend-once-listener.js | 0 .../prepend-once-listener/snippets/prepend-once-listener.test.yml | 0 .../kuzzle-event-emitter/remove-all-listener/index.md | 0 .../remove-all-listener/snippets/remove-all-listeners.js | 0 .../remove-all-listener/snippets/remove-all-listeners.test.yml | 0 .../core-classes/kuzzle-event-emitter/remove-listener/index.md | 0 .../remove-listener/snippets/remove-listener.js | 0 .../remove-listener/snippets/remove-listener.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/add-listener/index.md | 0 .../core-classes/kuzzle/add-listener/snippets/add-listener.js | 0 .../kuzzle/add-listener/snippets/add-listener.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/connect/index.md | 0 doc/{src => 6}/core-classes/kuzzle/connect/snippets/connect.js | 0 .../core-classes/kuzzle/connect/snippets/connect.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/constructor/index.md | 0 .../core-classes/kuzzle/constructor/snippets/constructor.js | 0 .../core-classes/kuzzle/constructor/snippets/constructor.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/disconnect/index.md | 0 .../core-classes/kuzzle/disconnect/snippets/disconnect.js | 0 .../core-classes/kuzzle/disconnect/snippets/disconnect.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/flush-queue/index.md | 0 .../core-classes/kuzzle/flush-queue/snippets/flush-queue.js | 0 .../core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/index.md | 0 doc/{src => 6}/core-classes/kuzzle/introduction/index.md | 0 doc/{src => 6}/core-classes/kuzzle/play-queue/index.md | 0 .../core-classes/kuzzle/play-queue/snippets/play-queue.js | 0 .../core-classes/kuzzle/play-queue/snippets/play-queue.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/query/index.md | 0 doc/{src => 6}/core-classes/kuzzle/query/snippets/query.js | 0 doc/{src => 6}/core-classes/kuzzle/query/snippets/query.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/start-queuing/index.md | 0 .../core-classes/kuzzle/start-queuing/snippets/start-queuing.js | 0 .../kuzzle/start-queuing/snippets/start-queuing.test.yml | 0 doc/{src => 6}/core-classes/kuzzle/stop-queuing/index.md | 0 .../core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js | 0 .../kuzzle/stop-queuing/snippets/stop-queuing.test.yml | 0 doc/{src => 6}/core-classes/profile/getRoles/index.md | 0 doc/{src => 6}/core-classes/profile/getRoles/snippets/getRoles.js | 0 .../core-classes/profile/getRoles/snippets/getRoles.test.yml | 0 doc/{src => 6}/core-classes/profile/index.md | 0 doc/{src => 6}/core-classes/profile/introduction/index.md | 0 doc/{src => 6}/core-classes/role/index.md | 0 doc/{src => 6}/core-classes/role/introduction/index.md | 0 doc/{src => 6}/core-classes/search-result/index.md | 0 doc/{src => 6}/core-classes/search-result/introduction/index.md | 0 doc/{src => 6}/core-classes/search-result/next/index.md | 0 .../core-classes/search-result/next/snippets/fromsize.js | 0 .../core-classes/search-result/next/snippets/fromsize.test.yml | 0 doc/{src => 6}/core-classes/search-result/next/snippets/scroll.js | 0 .../core-classes/search-result/next/snippets/scroll.test.yml | 0 doc/{src => 6}/core-classes/user/getProfiles/index.md | 0 .../core-classes/user/getProfiles/snippets/getProfiles.js | 0 .../core-classes/user/getProfiles/snippets/getProfiles.test.yml | 0 doc/{src => 6}/core-classes/user/index.md | 0 doc/{src => 6}/core-classes/user/introduction/index.md | 0 doc/{src => 6}/essentials/error-handling/index.md | 0 .../essentials/error-handling/snippets/error-handling-async.js | 0 .../error-handling/snippets/error-handling-async.test.yml | 0 .../essentials/error-handling/snippets/error-handling.js | 0 .../essentials/error-handling/snippets/error-handling.test.yml | 0 doc/{src => 6}/essentials/events/index.md | 0 doc/{src => 6}/essentials/extend-sdk/index.md | 0 doc/{src => 6}/essentials/getting-started/index.md | 0 doc/{src => 6}/essentials/getting-started/node-js/index.md | 0 .../essentials/getting-started/node-js/snippets/create.js | 0 .../essentials/getting-started/node-js/snippets/create.test.yml | 0 .../essentials/getting-started/node-js/snippets/init.js | 0 .../essentials/getting-started/node-js/snippets/init.test.yml | 0 .../essentials/getting-started/node-js/snippets/load-sdk.js | 0 .../essentials/getting-started/node-js/snippets/load-sdk.test.yml | 0 .../essentials/getting-started/node-js/snippets/prepare-db.js | 0 .../getting-started/node-js/snippets/prepare-db.test.yml | 0 .../essentials/getting-started/node-js/snippets/subscribe.js | 0 .../getting-started/node-js/snippets/subscribe.test.yml | 0 doc/{src => 6}/essentials/getting-started/raw-web/index.md | 0 .../essentials/getting-started/raw-web/snippets/create.html | 0 .../essentials/getting-started/raw-web/snippets/create.test.yml | 0 .../essentials/getting-started/raw-web/snippets/load-sdk.html | 0 .../essentials/getting-started/raw-web/snippets/load-sdk.test.yml | 0 .../essentials/getting-started/raw-web/snippets/prepare-db.html | 0 .../getting-started/raw-web/snippets/prepare-db.test.yml | 0 .../essentials/getting-started/raw-web/snippets/subscribe.html | 0 .../getting-started/raw-web/snippets/subscribe.test.yml | 0 doc/{src => 6}/essentials/getting-started/webpack/index.md | 0 .../essentials/getting-started/webpack/snippets/create.js | 0 .../essentials/getting-started/webpack/snippets/create.test.yml | 0 .../essentials/getting-started/webpack/snippets/init-kuzzle.js | 0 .../getting-started/webpack/snippets/init-kuzzle.test.yml | 0 .../essentials/getting-started/webpack/snippets/subscribe.js | 0 .../getting-started/webpack/snippets/subscribe.test.yml | 0 doc/{src => 6}/essentials/index.md | 0 doc/{src => 6}/essentials/offline-tools/index.md | 0 doc/{src => 6}/essentials/realtime-notifications/index.md | 0 doc/{src => 6}/index.md | 0 doc/{src => 6}/protocols/http/constructor/index.md | 0 doc/{src => 6}/protocols/http/constructor/snippets/constructor.js | 0 .../protocols/http/constructor/snippets/constructor.test.yml | 0 doc/{src => 6}/protocols/http/index.md | 0 doc/{src => 6}/protocols/http/introduction/index.md | 0 doc/{src => 6}/protocols/index.md | 0 doc/{src => 6}/protocols/socketio/constructor/index.md | 0 .../protocols/socketio/constructor/snippets/constructor.js | 0 .../protocols/socketio/constructor/snippets/constructor.test.yml | 0 doc/{src => 6}/protocols/socketio/index.md | 0 doc/{src => 6}/protocols/socketio/introduction/index.md | 0 doc/{src => 6}/protocols/websocket/constructor/index.md | 0 .../protocols/websocket/constructor/snippets/constructor.js | 0 .../protocols/websocket/constructor/snippets/constructor.test.yml | 0 doc/{src => 6}/protocols/websocket/index.md | 0 doc/{src => 6}/protocols/websocket/introduction/index.md | 0 680 files changed, 0 insertions(+), 0 deletions(-) rename doc/{src => 6}/controllers/auth/check-token/index.md (100%) rename doc/{src => 6}/controllers/auth/check-token/snippets/check-token.js (100%) rename doc/{src => 6}/controllers/auth/check-token/snippets/check-token.test.yml (100%) rename doc/{src => 6}/controllers/auth/create-my-credentials/index.md (100%) rename doc/{src => 6}/controllers/auth/create-my-credentials/snippets/create-my-credentials.js (100%) rename doc/{src => 6}/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml (100%) rename doc/{src => 6}/controllers/auth/credentials-exist/index.md (100%) rename doc/{src => 6}/controllers/auth/credentials-exist/snippets/credentials-exist.js (100%) rename doc/{src => 6}/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml (100%) rename doc/{src => 6}/controllers/auth/delete-my-credentials/index.md (100%) rename doc/{src => 6}/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js (100%) rename doc/{src => 6}/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml (100%) rename doc/{src => 6}/controllers/auth/get-current-user/index.md (100%) rename doc/{src => 6}/controllers/auth/get-current-user/snippets/get-current-user.js (100%) rename doc/{src => 6}/controllers/auth/get-current-user/snippets/get-current-user.test.yml (100%) rename doc/{src => 6}/controllers/auth/get-my-credentials/index.md (100%) rename doc/{src => 6}/controllers/auth/get-my-credentials/snippets/get-my-credentials.js (100%) rename doc/{src => 6}/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml (100%) rename doc/{src => 6}/controllers/auth/get-my-rights/index.md (100%) rename doc/{src => 6}/controllers/auth/get-my-rights/snippets/get-my-rights.js (100%) rename doc/{src => 6}/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml (100%) rename doc/{src => 6}/controllers/auth/get-strategies/index.md (100%) rename doc/{src => 6}/controllers/auth/get-strategies/snippets/get-strategies.js (100%) rename doc/{src => 6}/controllers/auth/get-strategies/snippets/get-strategies.test.yml (100%) rename doc/{src => 6}/controllers/auth/index.md (100%) rename doc/{src => 6}/controllers/auth/login/index.md (100%) rename doc/{src => 6}/controllers/auth/login/snippets/login.js (100%) rename doc/{src => 6}/controllers/auth/login/snippets/login.test.yml (100%) rename doc/{src => 6}/controllers/auth/logout/index.md (100%) rename doc/{src => 6}/controllers/auth/logout/snippets/logout.js (100%) rename doc/{src => 6}/controllers/auth/logout/snippets/logout.test.yml (100%) rename doc/{src => 6}/controllers/auth/update-my-credentials/index.md (100%) rename doc/{src => 6}/controllers/auth/update-my-credentials/snippets/update-my-credentials.js (100%) rename doc/{src => 6}/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml (100%) rename doc/{src => 6}/controllers/auth/update-self/index.md (100%) rename doc/{src => 6}/controllers/auth/update-self/snippets/update-self.js (100%) rename doc/{src => 6}/controllers/auth/update-self/snippets/update-self.test.yml (100%) rename doc/{src => 6}/controllers/auth/validate-my-credentials/index.md (100%) rename doc/{src => 6}/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js (100%) rename doc/{src => 6}/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml (100%) rename doc/{src => 6}/controllers/bulk/import/index.md (100%) rename doc/{src => 6}/controllers/bulk/import/snippets/import.js (100%) rename doc/{src => 6}/controllers/bulk/import/snippets/import.test.yml (100%) rename doc/{src => 6}/controllers/bulk/index.md (100%) rename doc/{src => 6}/controllers/collection/create/index.md (100%) rename doc/{src => 6}/controllers/collection/create/snippets/create.js (100%) rename doc/{src => 6}/controllers/collection/create/snippets/create.test.yml (100%) rename doc/{src => 6}/controllers/collection/delete-specifications/index.md (100%) rename doc/{src => 6}/controllers/collection/delete-specifications/snippets/delete-specifications.js (100%) rename doc/{src => 6}/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml (100%) rename doc/{src => 6}/controllers/collection/exists/index.md (100%) rename doc/{src => 6}/controllers/collection/exists/snippets/exists.js (100%) rename doc/{src => 6}/controllers/collection/exists/snippets/exists.test.yml (100%) rename doc/{src => 6}/controllers/collection/get-mapping/index.md (100%) rename doc/{src => 6}/controllers/collection/get-mapping/snippets/get-mapping.js (100%) rename doc/{src => 6}/controllers/collection/get-mapping/snippets/get-mapping.test.yml (100%) rename doc/{src => 6}/controllers/collection/get-specifications/index.md (100%) rename doc/{src => 6}/controllers/collection/get-specifications/snippets/get-specifications.js (100%) rename doc/{src => 6}/controllers/collection/get-specifications/snippets/get-specifications.test.yml (100%) rename doc/{src => 6}/controllers/collection/index.md (100%) rename doc/{src => 6}/controllers/collection/list/index.md (100%) rename doc/{src => 6}/controllers/collection/list/snippets/list.js (100%) rename doc/{src => 6}/controllers/collection/list/snippets/list.test.yml (100%) rename doc/{src => 6}/controllers/collection/search-specifications/index.md (100%) rename doc/{src => 6}/controllers/collection/search-specifications/snippets/search-specifications.js (100%) rename doc/{src => 6}/controllers/collection/search-specifications/snippets/search-specifications.test.yml (100%) rename doc/{src => 6}/controllers/collection/truncate/index.md (100%) rename doc/{src => 6}/controllers/collection/truncate/snippets/truncate.js (100%) rename doc/{src => 6}/controllers/collection/truncate/snippets/truncate.test.yml (100%) rename doc/{src => 6}/controllers/collection/update-mapping/index.md (100%) rename doc/{src => 6}/controllers/collection/update-mapping/snippets/update-mapping.js (100%) rename doc/{src => 6}/controllers/collection/update-mapping/snippets/update-mapping.test.yml (100%) rename doc/{src => 6}/controllers/collection/update-specifications/index.md (100%) rename doc/{src => 6}/controllers/collection/update-specifications/snippets/update-specifications.js (100%) rename doc/{src => 6}/controllers/collection/update-specifications/snippets/update-specifications.test.yml (100%) rename doc/{src => 6}/controllers/collection/validate-specifications/index.md (100%) rename doc/{src => 6}/controllers/collection/validate-specifications/snippets/validate-specifications.js (100%) rename doc/{src => 6}/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml (100%) rename doc/{src => 6}/controllers/document/count/index.md (100%) rename doc/{src => 6}/controllers/document/count/snippets/count.js (100%) rename doc/{src => 6}/controllers/document/count/snippets/count.test.yml (100%) rename doc/{src => 6}/controllers/document/create/index.md (100%) rename doc/{src => 6}/controllers/document/create/snippets/create.js (100%) rename doc/{src => 6}/controllers/document/create/snippets/create.test.yml (100%) rename doc/{src => 6}/controllers/document/createOrReplace/index.md (100%) rename doc/{src => 6}/controllers/document/createOrReplace/snippets/create-or-replace.js (100%) rename doc/{src => 6}/controllers/document/createOrReplace/snippets/create-or-replace.test.yml (100%) rename doc/{src => 6}/controllers/document/delete/index.md (100%) rename doc/{src => 6}/controllers/document/delete/snippets/delete.js (100%) rename doc/{src => 6}/controllers/document/delete/snippets/delete.test.yml (100%) rename doc/{src => 6}/controllers/document/deleteByQuery/index.md (100%) rename doc/{src => 6}/controllers/document/deleteByQuery/snippets/delete-by-query.js (100%) rename doc/{src => 6}/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml (100%) rename doc/{src => 6}/controllers/document/get/index.md (100%) rename doc/{src => 6}/controllers/document/get/snippets/get.js (100%) rename doc/{src => 6}/controllers/document/get/snippets/get.test.yml (100%) rename doc/{src => 6}/controllers/document/index.md (100%) rename doc/{src => 6}/controllers/document/mCreate/index.md (100%) rename doc/{src => 6}/controllers/document/mCreate/snippets/m-create.js (100%) rename doc/{src => 6}/controllers/document/mCreate/snippets/m-create.test.yml (100%) rename doc/{src => 6}/controllers/document/mCreateOrReplace/index.md (100%) rename doc/{src => 6}/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js (100%) rename doc/{src => 6}/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml (100%) rename doc/{src => 6}/controllers/document/mDelete/index.md (100%) rename doc/{src => 6}/controllers/document/mDelete/snippets/m-delete.js (100%) rename doc/{src => 6}/controllers/document/mDelete/snippets/m-delete.test.yml (100%) rename doc/{src => 6}/controllers/document/mGet/index.md (100%) rename doc/{src => 6}/controllers/document/mGet/snippets/m-get.js (100%) rename doc/{src => 6}/controllers/document/mGet/snippets/m-get.test.yml (100%) rename doc/{src => 6}/controllers/document/mReplace/index.md (100%) rename doc/{src => 6}/controllers/document/mReplace/snippets/m-replace.js (100%) rename doc/{src => 6}/controllers/document/mReplace/snippets/m-replace.test.yml (100%) rename doc/{src => 6}/controllers/document/mUpdate/index.md (100%) rename doc/{src => 6}/controllers/document/mUpdate/snippets/m-update.js (100%) rename doc/{src => 6}/controllers/document/mUpdate/snippets/m-update.test.yml (100%) rename doc/{src => 6}/controllers/document/replace/index.md (100%) rename doc/{src => 6}/controllers/document/replace/snippets/replace.js (100%) rename doc/{src => 6}/controllers/document/replace/snippets/replace.test.yml (100%) rename doc/{src => 6}/controllers/document/search/index.md (100%) rename doc/{src => 6}/controllers/document/search/snippets/search.js (100%) rename doc/{src => 6}/controllers/document/search/snippets/search.test.yml (100%) rename doc/{src => 6}/controllers/document/update/index.md (100%) rename doc/{src => 6}/controllers/document/update/snippets/update.js (100%) rename doc/{src => 6}/controllers/document/update/snippets/update.test.yml (100%) rename doc/{src => 6}/controllers/document/validate/index.md (100%) rename doc/{src => 6}/controllers/document/validate/snippets/validate.js (100%) rename doc/{src => 6}/controllers/document/validate/snippets/validate.test.yml (100%) rename doc/{src => 6}/controllers/index.md (100%) rename doc/{src => 6}/controllers/index/create/index.md (100%) rename doc/{src => 6}/controllers/index/create/snippets/create.js (100%) rename doc/{src => 6}/controllers/index/create/snippets/create.test.yml (100%) rename doc/{src => 6}/controllers/index/delete/index.md (100%) rename doc/{src => 6}/controllers/index/delete/snippets/delete.js (100%) rename doc/{src => 6}/controllers/index/delete/snippets/delete.test.yml (100%) rename doc/{src => 6}/controllers/index/exists/index.md (100%) rename doc/{src => 6}/controllers/index/exists/snippets/exists.js (100%) rename doc/{src => 6}/controllers/index/exists/snippets/exists.test.yml (100%) rename doc/{src => 6}/controllers/index/get-auto-refresh/index.md (100%) rename doc/{src => 6}/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js (100%) rename doc/{src => 6}/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml (100%) rename doc/{src => 6}/controllers/index/index.md (100%) rename doc/{src => 6}/controllers/index/list/index.md (100%) rename doc/{src => 6}/controllers/index/list/snippets/list.js (100%) rename doc/{src => 6}/controllers/index/list/snippets/list.test.yml (100%) rename doc/{src => 6}/controllers/index/m-delete/index.md (100%) rename doc/{src => 6}/controllers/index/m-delete/snippets/mDelete.js (100%) rename doc/{src => 6}/controllers/index/m-delete/snippets/mDelete.test.yml (100%) rename doc/{src => 6}/controllers/index/refresh-internal/index.md (100%) rename doc/{src => 6}/controllers/index/refresh-internal/snippets/refreshInternal.js (100%) rename doc/{src => 6}/controllers/index/refresh-internal/snippets/refreshInternal.test.yml (100%) rename doc/{src => 6}/controllers/index/refresh/index.md (100%) rename doc/{src => 6}/controllers/index/refresh/snippets/refresh.js (100%) rename doc/{src => 6}/controllers/index/refresh/snippets/refresh.test.yml (100%) rename doc/{src => 6}/controllers/index/set-auto-refresh/index.md (100%) rename doc/{src => 6}/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js (100%) rename doc/{src => 6}/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml (100%) rename doc/{src => 6}/controllers/ms/append/index.md (100%) rename doc/{src => 6}/controllers/ms/append/snippets/append.js (100%) rename doc/{src => 6}/controllers/ms/append/snippets/append.test.yml (100%) rename doc/{src => 6}/controllers/ms/bitcount/index.md (100%) rename doc/{src => 6}/controllers/ms/bitcount/snippets/bitcount.js (100%) rename doc/{src => 6}/controllers/ms/bitcount/snippets/bitcount.test.yml (100%) rename doc/{src => 6}/controllers/ms/bitop/index.md (100%) rename doc/{src => 6}/controllers/ms/bitop/snippets/bitop.js (100%) rename doc/{src => 6}/controllers/ms/bitop/snippets/bitop.test.yml (100%) rename doc/{src => 6}/controllers/ms/bitpos/index.md (100%) rename doc/{src => 6}/controllers/ms/bitpos/snippets/bitpos.js (100%) rename doc/{src => 6}/controllers/ms/bitpos/snippets/bitpos.test.yml (100%) rename doc/{src => 6}/controllers/ms/dbsize/index.md (100%) rename doc/{src => 6}/controllers/ms/dbsize/snippets/dbsize.js (100%) rename doc/{src => 6}/controllers/ms/dbsize/snippets/dbsize.test.yml (100%) rename doc/{src => 6}/controllers/ms/decr/index.md (100%) rename doc/{src => 6}/controllers/ms/decr/snippets/decr.js (100%) rename doc/{src => 6}/controllers/ms/decr/snippets/decr.test.yml (100%) rename doc/{src => 6}/controllers/ms/decrby/index.md (100%) rename doc/{src => 6}/controllers/ms/decrby/snippets/decrby.js (100%) rename doc/{src => 6}/controllers/ms/decrby/snippets/decrby.test.yml (100%) rename doc/{src => 6}/controllers/ms/del/index.md (100%) rename doc/{src => 6}/controllers/ms/del/snippets/del.js (100%) rename doc/{src => 6}/controllers/ms/del/snippets/del.test.yml (100%) rename doc/{src => 6}/controllers/ms/exists/index.md (100%) rename doc/{src => 6}/controllers/ms/exists/snippets/exists.js (100%) rename doc/{src => 6}/controllers/ms/exists/snippets/exists.test.yml (100%) rename doc/{src => 6}/controllers/ms/expire/index.md (100%) rename doc/{src => 6}/controllers/ms/expire/snippets/expire.js (100%) rename doc/{src => 6}/controllers/ms/expire/snippets/expire.test.yml (100%) rename doc/{src => 6}/controllers/ms/expireat/index.md (100%) rename doc/{src => 6}/controllers/ms/expireat/snippets/expireat.js (100%) rename doc/{src => 6}/controllers/ms/expireat/snippets/expireat.test.yml (100%) rename doc/{src => 6}/controllers/ms/flushdb/index.md (100%) rename doc/{src => 6}/controllers/ms/flushdb/snippets/flushdb.js (100%) rename doc/{src => 6}/controllers/ms/flushdb/snippets/flushdb.test.yml (100%) rename doc/{src => 6}/controllers/ms/geoadd/index.md (100%) rename doc/{src => 6}/controllers/ms/geoadd/snippets/geoadd.js (100%) rename doc/{src => 6}/controllers/ms/geoadd/snippets/geoadd.test.yml (100%) rename doc/{src => 6}/controllers/ms/geodist/index.md (100%) rename doc/{src => 6}/controllers/ms/geodist/snippets/geodist.js (100%) rename doc/{src => 6}/controllers/ms/geodist/snippets/geodist.test.yml (100%) rename doc/{src => 6}/controllers/ms/geohash/index.md (100%) rename doc/{src => 6}/controllers/ms/geohash/snippets/geohash.js (100%) rename doc/{src => 6}/controllers/ms/geohash/snippets/geohash.test.yml (100%) rename doc/{src => 6}/controllers/ms/geopos/index.md (100%) rename doc/{src => 6}/controllers/ms/geopos/snippets/geopos.js (100%) rename doc/{src => 6}/controllers/ms/geopos/snippets/geopos.test.yml (100%) rename doc/{src => 6}/controllers/ms/georadius/index.md (100%) rename doc/{src => 6}/controllers/ms/georadius/snippets/georadius.js (100%) rename doc/{src => 6}/controllers/ms/georadius/snippets/georadius.test.yml (100%) rename doc/{src => 6}/controllers/ms/georadiusbymember/index.md (100%) rename doc/{src => 6}/controllers/ms/georadiusbymember/snippets/georadiusbymember.js (100%) rename doc/{src => 6}/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml (100%) rename doc/{src => 6}/controllers/ms/get/index.md (100%) rename doc/{src => 6}/controllers/ms/get/snippets/get.js (100%) rename doc/{src => 6}/controllers/ms/get/snippets/get.test.yml (100%) rename doc/{src => 6}/controllers/ms/getbit/index.md (100%) rename doc/{src => 6}/controllers/ms/getbit/snippets/getbit.js (100%) rename doc/{src => 6}/controllers/ms/getbit/snippets/getbit.test.yml (100%) rename doc/{src => 6}/controllers/ms/getrange/index.md (100%) rename doc/{src => 6}/controllers/ms/getrange/snippets/getrange.js (100%) rename doc/{src => 6}/controllers/ms/getrange/snippets/getrange.test.yml (100%) rename doc/{src => 6}/controllers/ms/getset/index.md (100%) rename doc/{src => 6}/controllers/ms/getset/snippets/getset.js (100%) rename doc/{src => 6}/controllers/ms/getset/snippets/getset.test.yml (100%) rename doc/{src => 6}/controllers/ms/hdel/index.md (100%) rename doc/{src => 6}/controllers/ms/hdel/snippets/hdel.js (100%) rename doc/{src => 6}/controllers/ms/hdel/snippets/hdel.test.yml (100%) rename doc/{src => 6}/controllers/ms/hexists/index.md (100%) rename doc/{src => 6}/controllers/ms/hexists/snippets/hexists.js (100%) rename doc/{src => 6}/controllers/ms/hexists/snippets/hexists.test.yml (100%) rename doc/{src => 6}/controllers/ms/hget/index.md (100%) rename doc/{src => 6}/controllers/ms/hget/snippets/hget.js (100%) rename doc/{src => 6}/controllers/ms/hget/snippets/hget.test.yml (100%) rename doc/{src => 6}/controllers/ms/hgetall/index.md (100%) rename doc/{src => 6}/controllers/ms/hgetall/snippets/hgetall.js (100%) rename doc/{src => 6}/controllers/ms/hgetall/snippets/hgetall.test.yml (100%) rename doc/{src => 6}/controllers/ms/hincrby/index.md (100%) rename doc/{src => 6}/controllers/ms/hincrby/snippets/hincrby.js (100%) rename doc/{src => 6}/controllers/ms/hincrby/snippets/hincrby.test.yml (100%) rename doc/{src => 6}/controllers/ms/hincrbyfloat/index.md (100%) rename doc/{src => 6}/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js (100%) rename doc/{src => 6}/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml (100%) rename doc/{src => 6}/controllers/ms/hkeys/index.md (100%) rename doc/{src => 6}/controllers/ms/hkeys/snippets/hkeys.js (100%) rename doc/{src => 6}/controllers/ms/hkeys/snippets/hkeys.test.yml (100%) rename doc/{src => 6}/controllers/ms/hlen/index.md (100%) rename doc/{src => 6}/controllers/ms/hlen/snippets/hlen.js (100%) rename doc/{src => 6}/controllers/ms/hlen/snippets/hlen.test.yml (100%) rename doc/{src => 6}/controllers/ms/hmget/index.md (100%) rename doc/{src => 6}/controllers/ms/hmget/snippets/hmget.js (100%) rename doc/{src => 6}/controllers/ms/hmget/snippets/hmget.test.yml (100%) rename doc/{src => 6}/controllers/ms/hmset/index.md (100%) rename doc/{src => 6}/controllers/ms/hmset/snippets/hmset.js (100%) rename doc/{src => 6}/controllers/ms/hmset/snippets/hmset.test.yml (100%) rename doc/{src => 6}/controllers/ms/hscan/index.md (100%) rename doc/{src => 6}/controllers/ms/hscan/snippets/hscan.js (100%) rename doc/{src => 6}/controllers/ms/hscan/snippets/hscan.test.yml (100%) rename doc/{src => 6}/controllers/ms/hset/index.md (100%) rename doc/{src => 6}/controllers/ms/hset/snippets/hset.js (100%) rename doc/{src => 6}/controllers/ms/hset/snippets/hset.test.yml (100%) rename doc/{src => 6}/controllers/ms/hsetnx/index.md (100%) rename doc/{src => 6}/controllers/ms/hsetnx/snippets/hsetnx.js (100%) rename doc/{src => 6}/controllers/ms/hsetnx/snippets/hsetnx.test.yml (100%) rename doc/{src => 6}/controllers/ms/hstrlen/index.md (100%) rename doc/{src => 6}/controllers/ms/hstrlen/snippets/hstrlen.js (100%) rename doc/{src => 6}/controllers/ms/hstrlen/snippets/hstrlen.test.yml (100%) rename doc/{src => 6}/controllers/ms/hvals/index.md (100%) rename doc/{src => 6}/controllers/ms/hvals/snippets/hvals.js (100%) rename doc/{src => 6}/controllers/ms/hvals/snippets/hvals.test.yml (100%) rename doc/{src => 6}/controllers/ms/incr/index.md (100%) rename doc/{src => 6}/controllers/ms/incr/snippets/incr.js (100%) rename doc/{src => 6}/controllers/ms/incr/snippets/incr.test.yml (100%) rename doc/{src => 6}/controllers/ms/incrby/index.md (100%) rename doc/{src => 6}/controllers/ms/incrby/snippets/incrby.js (100%) rename doc/{src => 6}/controllers/ms/incrby/snippets/incrby.test.yml (100%) rename doc/{src => 6}/controllers/ms/incrbyfloat/index.md (100%) rename doc/{src => 6}/controllers/ms/incrbyfloat/snippets/incrbyfloat.js (100%) rename doc/{src => 6}/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml (100%) rename doc/{src => 6}/controllers/ms/index.md (100%) rename doc/{src => 6}/controllers/ms/keys/index.md (100%) rename doc/{src => 6}/controllers/ms/keys/snippets/keys.js (100%) rename doc/{src => 6}/controllers/ms/keys/snippets/keys.test.yml (100%) rename doc/{src => 6}/controllers/ms/lindex/index.md (100%) rename doc/{src => 6}/controllers/ms/lindex/snippets/lindex.js (100%) rename doc/{src => 6}/controllers/ms/lindex/snippets/lindex.test.yml (100%) rename doc/{src => 6}/controllers/ms/linsert/index.md (100%) rename doc/{src => 6}/controllers/ms/linsert/snippets/linsert.js (100%) rename doc/{src => 6}/controllers/ms/linsert/snippets/linsert.test.yml (100%) rename doc/{src => 6}/controllers/ms/llen/index.md (100%) rename doc/{src => 6}/controllers/ms/llen/snippets/llen.js (100%) rename doc/{src => 6}/controllers/ms/llen/snippets/llen.test.yml (100%) rename doc/{src => 6}/controllers/ms/lpop/index.md (100%) rename doc/{src => 6}/controllers/ms/lpop/snippets/lpop.js (100%) rename doc/{src => 6}/controllers/ms/lpop/snippets/lpop.test.yml (100%) rename doc/{src => 6}/controllers/ms/lpush/index.md (100%) rename doc/{src => 6}/controllers/ms/lpush/snippets/lpush.js (100%) rename doc/{src => 6}/controllers/ms/lpush/snippets/lpush.test.yml (100%) rename doc/{src => 6}/controllers/ms/lpushx/index.md (100%) rename doc/{src => 6}/controllers/ms/lpushx/snippets/lpushx.js (100%) rename doc/{src => 6}/controllers/ms/lpushx/snippets/lpushx.test.yml (100%) rename doc/{src => 6}/controllers/ms/lrange/index.md (100%) rename doc/{src => 6}/controllers/ms/lrange/snippets/lrange.js (100%) rename doc/{src => 6}/controllers/ms/lrange/snippets/lrange.test.yml (100%) rename doc/{src => 6}/controllers/ms/lrem/index.md (100%) rename doc/{src => 6}/controllers/ms/lrem/snippets/lrem.js (100%) rename doc/{src => 6}/controllers/ms/lrem/snippets/lrem.test.yml (100%) rename doc/{src => 6}/controllers/ms/lset/index.md (100%) rename doc/{src => 6}/controllers/ms/lset/snippets/lset.js (100%) rename doc/{src => 6}/controllers/ms/lset/snippets/lset.test.yml (100%) rename doc/{src => 6}/controllers/ms/ltrim/index.md (100%) rename doc/{src => 6}/controllers/ms/ltrim/snippets/ltrim.js (100%) rename doc/{src => 6}/controllers/ms/ltrim/snippets/ltrim.test.yml (100%) rename doc/{src => 6}/controllers/ms/mget/index.md (100%) rename doc/{src => 6}/controllers/ms/mget/snippets/mget.js (100%) rename doc/{src => 6}/controllers/ms/mget/snippets/mget.test.yml (100%) rename doc/{src => 6}/controllers/ms/mset/index.md (100%) rename doc/{src => 6}/controllers/ms/mset/snippets/mset.js (100%) rename doc/{src => 6}/controllers/ms/mset/snippets/mset.test.yml (100%) rename doc/{src => 6}/controllers/ms/msetnx/index.md (100%) rename doc/{src => 6}/controllers/ms/msetnx/snippets/msetnx.js (100%) rename doc/{src => 6}/controllers/ms/msetnx/snippets/msetnx.test.yml (100%) rename doc/{src => 6}/controllers/ms/object/index.md (100%) rename doc/{src => 6}/controllers/ms/object/snippets/object.js (100%) rename doc/{src => 6}/controllers/ms/object/snippets/object.test.yml (100%) rename doc/{src => 6}/controllers/ms/persist/index.md (100%) rename doc/{src => 6}/controllers/ms/persist/snippets/persist.js (100%) rename doc/{src => 6}/controllers/ms/persist/snippets/persist.test.yml (100%) rename doc/{src => 6}/controllers/ms/pexpire/index.md (100%) rename doc/{src => 6}/controllers/ms/pexpire/snippets/pexpire.js (100%) rename doc/{src => 6}/controllers/ms/pexpire/snippets/pexpire.test.yml (100%) rename doc/{src => 6}/controllers/ms/pexpireat/index.md (100%) rename doc/{src => 6}/controllers/ms/pexpireat/snippets/pexpireat.js (100%) rename doc/{src => 6}/controllers/ms/pexpireat/snippets/pexpireat.test.yml (100%) rename doc/{src => 6}/controllers/ms/pfadd/index.md (100%) rename doc/{src => 6}/controllers/ms/pfadd/snippets/pfadd.js (100%) rename doc/{src => 6}/controllers/ms/pfadd/snippets/pfadd.test.yml (100%) rename doc/{src => 6}/controllers/ms/pfcount/index.md (100%) rename doc/{src => 6}/controllers/ms/pfcount/snippets/pfcount.js (100%) rename doc/{src => 6}/controllers/ms/pfcount/snippets/pfcount.test.yml (100%) rename doc/{src => 6}/controllers/ms/pfmerge/index.md (100%) rename doc/{src => 6}/controllers/ms/pfmerge/snippets/pfmerge.js (100%) rename doc/{src => 6}/controllers/ms/pfmerge/snippets/pfmerge.test.yml (100%) rename doc/{src => 6}/controllers/ms/ping/index.md (100%) rename doc/{src => 6}/controllers/ms/ping/snippets/ping.js (100%) rename doc/{src => 6}/controllers/ms/ping/snippets/ping.test.yml (100%) rename doc/{src => 6}/controllers/ms/psetex/index.md (100%) rename doc/{src => 6}/controllers/ms/psetex/snippets/psetex.js (100%) rename doc/{src => 6}/controllers/ms/psetex/snippets/psetex.test.yml (100%) rename doc/{src => 6}/controllers/ms/pttl/index.md (100%) rename doc/{src => 6}/controllers/ms/pttl/snippets/pttl.js (100%) rename doc/{src => 6}/controllers/ms/pttl/snippets/pttl.test.yml (100%) rename doc/{src => 6}/controllers/ms/randomkey/index.md (100%) rename doc/{src => 6}/controllers/ms/randomkey/snippets/randomkey.js (100%) rename doc/{src => 6}/controllers/ms/randomkey/snippets/randomkey.test.yml (100%) rename doc/{src => 6}/controllers/ms/rename/index.md (100%) rename doc/{src => 6}/controllers/ms/rename/snippets/rename.js (100%) rename doc/{src => 6}/controllers/ms/rename/snippets/rename.test.yml (100%) rename doc/{src => 6}/controllers/ms/renamenx/index.md (100%) rename doc/{src => 6}/controllers/ms/renamenx/snippets/renamenx.js (100%) rename doc/{src => 6}/controllers/ms/renamenx/snippets/renamenx.test.yml (100%) rename doc/{src => 6}/controllers/ms/rpop/index.md (100%) rename doc/{src => 6}/controllers/ms/rpop/snippets/rpop.js (100%) rename doc/{src => 6}/controllers/ms/rpop/snippets/rpop.test.yml (100%) rename doc/{src => 6}/controllers/ms/rpoplpush/index.md (100%) rename doc/{src => 6}/controllers/ms/rpoplpush/snippets/rpoplpush.js (100%) rename doc/{src => 6}/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml (100%) rename doc/{src => 6}/controllers/ms/rpush/index.md (100%) rename doc/{src => 6}/controllers/ms/rpush/snippets/rpush.js (100%) rename doc/{src => 6}/controllers/ms/rpush/snippets/rpush.test.yml (100%) rename doc/{src => 6}/controllers/ms/rpushx/index.md (100%) rename doc/{src => 6}/controllers/ms/rpushx/snippets/rpushx.js (100%) rename doc/{src => 6}/controllers/ms/rpushx/snippets/rpushx.test.yml (100%) rename doc/{src => 6}/controllers/ms/sadd/index.md (100%) rename doc/{src => 6}/controllers/ms/sadd/snippets/sadd.js (100%) rename doc/{src => 6}/controllers/ms/sadd/snippets/sadd.test.yml (100%) rename doc/{src => 6}/controllers/ms/scan/index.md (100%) rename doc/{src => 6}/controllers/ms/scan/snippets/scan.js (100%) rename doc/{src => 6}/controllers/ms/scan/snippets/scan.test.yml (100%) rename doc/{src => 6}/controllers/ms/scard/index.md (100%) rename doc/{src => 6}/controllers/ms/scard/snippets/scard.js (100%) rename doc/{src => 6}/controllers/ms/scard/snippets/scard.test.yml (100%) rename doc/{src => 6}/controllers/ms/sdiff/index.md (100%) rename doc/{src => 6}/controllers/ms/sdiff/snippets/sdiff.js (100%) rename doc/{src => 6}/controllers/ms/sdiff/snippets/sdiff.test.yml (100%) rename doc/{src => 6}/controllers/ms/sdiffstore/index.md (100%) rename doc/{src => 6}/controllers/ms/sdiffstore/snippets/sdiffstore.js (100%) rename doc/{src => 6}/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml (100%) rename doc/{src => 6}/controllers/ms/set/index.md (100%) rename doc/{src => 6}/controllers/ms/set/snippets/set.js (100%) rename doc/{src => 6}/controllers/ms/set/snippets/set.test.yml (100%) rename doc/{src => 6}/controllers/ms/setex/index.md (100%) rename doc/{src => 6}/controllers/ms/setex/snippets/setex.js (100%) rename doc/{src => 6}/controllers/ms/setex/snippets/setex.test.yml (100%) rename doc/{src => 6}/controllers/ms/setnx/index.md (100%) rename doc/{src => 6}/controllers/ms/setnx/snippets/setnx.js (100%) rename doc/{src => 6}/controllers/ms/setnx/snippets/setnx.test.yml (100%) rename doc/{src => 6}/controllers/ms/sinter/index.md (100%) rename doc/{src => 6}/controllers/ms/sinter/snippets/sinter.js (100%) rename doc/{src => 6}/controllers/ms/sinter/snippets/sinter.test.yml (100%) rename doc/{src => 6}/controllers/ms/sinterstore/index.md (100%) rename doc/{src => 6}/controllers/ms/sinterstore/snippets/sinterstore.js (100%) rename doc/{src => 6}/controllers/ms/sinterstore/snippets/sinterstore.test.yml (100%) rename doc/{src => 6}/controllers/ms/sismember/index.md (100%) rename doc/{src => 6}/controllers/ms/sismember/snippets/sismember.js (100%) rename doc/{src => 6}/controllers/ms/sismember/snippets/sismember.test.yml (100%) rename doc/{src => 6}/controllers/ms/smembers/index.md (100%) rename doc/{src => 6}/controllers/ms/smembers/snippets/smembers.js (100%) rename doc/{src => 6}/controllers/ms/smembers/snippets/smembers.test.yml (100%) rename doc/{src => 6}/controllers/ms/smove/index.md (100%) rename doc/{src => 6}/controllers/ms/smove/snippets/smove.js (100%) rename doc/{src => 6}/controllers/ms/smove/snippets/smove.test.yml (100%) rename doc/{src => 6}/controllers/ms/sort/index.md (100%) rename doc/{src => 6}/controllers/ms/sort/snippets/sort.js (100%) rename doc/{src => 6}/controllers/ms/sort/snippets/sort.test.yml (100%) rename doc/{src => 6}/controllers/ms/spop/index.md (100%) rename doc/{src => 6}/controllers/ms/spop/snippets/spop.js (100%) rename doc/{src => 6}/controllers/ms/spop/snippets/spop.test.yml (100%) rename doc/{src => 6}/controllers/ms/srandmember/index.md (100%) rename doc/{src => 6}/controllers/ms/srandmember/snippets/srandmember.js (100%) rename doc/{src => 6}/controllers/ms/srandmember/snippets/srandmember.test.yml (100%) rename doc/{src => 6}/controllers/ms/srem/index.md (100%) rename doc/{src => 6}/controllers/ms/srem/snippets/srem.js (100%) rename doc/{src => 6}/controllers/ms/srem/snippets/srem.test.yml (100%) rename doc/{src => 6}/controllers/ms/sscan/index.md (100%) rename doc/{src => 6}/controllers/ms/sscan/snippets/sscan.js (100%) rename doc/{src => 6}/controllers/ms/sscan/snippets/sscan.test.yml (100%) rename doc/{src => 6}/controllers/ms/strlen/index.md (100%) rename doc/{src => 6}/controllers/ms/strlen/snippets/strlen.js (100%) rename doc/{src => 6}/controllers/ms/strlen/snippets/strlen.test.yml (100%) rename doc/{src => 6}/controllers/ms/sunion/index.md (100%) rename doc/{src => 6}/controllers/ms/sunion/snippets/sunion.js (100%) rename doc/{src => 6}/controllers/ms/sunion/snippets/sunion.test.yml (100%) rename doc/{src => 6}/controllers/ms/sunionstore/index.md (100%) rename doc/{src => 6}/controllers/ms/sunionstore/snippets/sunionstore.js (100%) rename doc/{src => 6}/controllers/ms/sunionstore/snippets/sunionstore.test.yml (100%) rename doc/{src => 6}/controllers/ms/time/index.md (100%) rename doc/{src => 6}/controllers/ms/time/snippets/time.js (100%) rename doc/{src => 6}/controllers/ms/time/snippets/time.test.yml (100%) rename doc/{src => 6}/controllers/ms/touch/index.md (100%) rename doc/{src => 6}/controllers/ms/touch/snippets/touch.js (100%) rename doc/{src => 6}/controllers/ms/touch/snippets/touch.test.yml (100%) rename doc/{src => 6}/controllers/ms/ttl/index.md (100%) rename doc/{src => 6}/controllers/ms/ttl/snippets/ttl.js (100%) rename doc/{src => 6}/controllers/ms/ttl/snippets/ttl.test.yml (100%) rename doc/{src => 6}/controllers/ms/type/index.md (100%) rename doc/{src => 6}/controllers/ms/type/snippets/type.js (100%) rename doc/{src => 6}/controllers/ms/type/snippets/type.test.yml (100%) rename doc/{src => 6}/controllers/ms/zadd/index.md (100%) rename doc/{src => 6}/controllers/ms/zadd/snippets/zadd.js (100%) rename doc/{src => 6}/controllers/ms/zadd/snippets/zadd.test.yml (100%) rename doc/{src => 6}/controllers/ms/zcard/index.md (100%) rename doc/{src => 6}/controllers/ms/zcard/snippets/zcard.js (100%) rename doc/{src => 6}/controllers/ms/zcard/snippets/zcard.test.yml (100%) rename doc/{src => 6}/controllers/ms/zcount/index.md (100%) rename doc/{src => 6}/controllers/ms/zcount/snippets/zcount.js (100%) rename doc/{src => 6}/controllers/ms/zcount/snippets/zcount.test.yml (100%) rename doc/{src => 6}/controllers/ms/zincrby/index.md (100%) rename doc/{src => 6}/controllers/ms/zincrby/snippets/zincrby.js (100%) rename doc/{src => 6}/controllers/ms/zincrby/snippets/zincrby.test.yml (100%) rename doc/{src => 6}/controllers/ms/zinterstore/index.md (100%) rename doc/{src => 6}/controllers/ms/zinterstore/snippets/zinterstore.js (100%) rename doc/{src => 6}/controllers/ms/zinterstore/snippets/zinterstore.test.yml (100%) rename doc/{src => 6}/controllers/ms/zlexcount/index.md (100%) rename doc/{src => 6}/controllers/ms/zlexcount/snippets/zlexcount.js (100%) rename doc/{src => 6}/controllers/ms/zlexcount/snippets/zlexcount.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrange/index.md (100%) rename doc/{src => 6}/controllers/ms/zrange/snippets/zrange.js (100%) rename doc/{src => 6}/controllers/ms/zrange/snippets/zrange.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrangebylex/index.md (100%) rename doc/{src => 6}/controllers/ms/zrangebylex/snippets/zrangebylex.js (100%) rename doc/{src => 6}/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrangebyscore/index.md (100%) rename doc/{src => 6}/controllers/ms/zrangebyscore/snippets/zrangebyscore.js (100%) rename doc/{src => 6}/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrank/index.md (100%) rename doc/{src => 6}/controllers/ms/zrank/snippets/zrank.js (100%) rename doc/{src => 6}/controllers/ms/zrank/snippets/zrank.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrem/index.md (100%) rename doc/{src => 6}/controllers/ms/zrem/snippets/zrem.js (100%) rename doc/{src => 6}/controllers/ms/zrem/snippets/zrem.test.yml (100%) rename doc/{src => 6}/controllers/ms/zremrangebylex/index.md (100%) rename doc/{src => 6}/controllers/ms/zremrangebylex/snippets/zremrangebylex.js (100%) rename doc/{src => 6}/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml (100%) rename doc/{src => 6}/controllers/ms/zremrangebyrank/index.md (100%) rename doc/{src => 6}/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js (100%) rename doc/{src => 6}/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml (100%) rename doc/{src => 6}/controllers/ms/zremrangebyscore/index.md (100%) rename doc/{src => 6}/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js (100%) rename doc/{src => 6}/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrevrange/index.md (100%) rename doc/{src => 6}/controllers/ms/zrevrange/snippets/zrevrange.js (100%) rename doc/{src => 6}/controllers/ms/zrevrange/snippets/zrevrange.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrevrangebylex/index.md (100%) rename doc/{src => 6}/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js (100%) rename doc/{src => 6}/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrevrangebyscore/index.md (100%) rename doc/{src => 6}/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js (100%) rename doc/{src => 6}/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml (100%) rename doc/{src => 6}/controllers/ms/zrevrank/index.md (100%) rename doc/{src => 6}/controllers/ms/zrevrank/snippets/zrevrank.js (100%) rename doc/{src => 6}/controllers/ms/zrevrank/snippets/zrevrank.test.yml (100%) rename doc/{src => 6}/controllers/ms/zscan/index.md (100%) rename doc/{src => 6}/controllers/ms/zscan/snippets/zscan.js (100%) rename doc/{src => 6}/controllers/ms/zscan/snippets/zscan.test.yml (100%) rename doc/{src => 6}/controllers/ms/zscore/index.md (100%) rename doc/{src => 6}/controllers/ms/zscore/snippets/zscore.js (100%) rename doc/{src => 6}/controllers/ms/zscore/snippets/zscore.test.yml (100%) rename doc/{src => 6}/controllers/ms/zunionstore/index.md (100%) rename doc/{src => 6}/controllers/ms/zunionstore/snippets/zunionstore.js (100%) rename doc/{src => 6}/controllers/ms/zunionstore/snippets/zunionstore.test.yml (100%) rename doc/{src => 6}/controllers/realtime/count/index.md (100%) rename doc/{src => 6}/controllers/realtime/count/snippets/count.js (100%) rename doc/{src => 6}/controllers/realtime/count/snippets/count.test.yml (100%) rename doc/{src => 6}/controllers/realtime/index.md (100%) rename doc/{src => 6}/controllers/realtime/publish/index.md (100%) rename doc/{src => 6}/controllers/realtime/publish/snippets/publish.js (100%) rename doc/{src => 6}/controllers/realtime/publish/snippets/publish.test.yml (100%) rename doc/{src => 6}/controllers/realtime/subscribe/index.md (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/document-notifications.js (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/document-notifications.test.yml (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/message-notifications.js (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/message-notifications.test.yml (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/user-notifications.js (100%) rename doc/{src => 6}/controllers/realtime/subscribe/snippets/user-notifications.test.yml (100%) rename doc/{src => 6}/controllers/realtime/unsubscribe/index.md (100%) rename doc/{src => 6}/controllers/realtime/unsubscribe/snippets/unsubscribe.js (100%) rename doc/{src => 6}/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml (100%) rename doc/{src => 6}/controllers/server/admin-exists/index.md (100%) rename doc/{src => 6}/controllers/server/admin-exists/snippets/admin-exists.js (100%) rename doc/{src => 6}/controllers/server/admin-exists/snippets/admin-exists.test.yml (100%) rename doc/{src => 6}/controllers/server/get-all-stats/index.md (100%) rename doc/{src => 6}/controllers/server/get-all-stats/snippets/get-all-stats.js (100%) rename doc/{src => 6}/controllers/server/get-all-stats/snippets/get-all-stats.test.yml (100%) rename doc/{src => 6}/controllers/server/get-config/index.md (100%) rename doc/{src => 6}/controllers/server/get-config/snippets/get-config.js (100%) rename doc/{src => 6}/controllers/server/get-config/snippets/get-config.test.yml (100%) rename doc/{src => 6}/controllers/server/get-last-stats/index.md (100%) rename doc/{src => 6}/controllers/server/get-last-stats/snippets/get-last-stats.js (100%) rename doc/{src => 6}/controllers/server/get-last-stats/snippets/get-last-stats.test.yml (100%) rename doc/{src => 6}/controllers/server/get-stats/index.md (100%) rename doc/{src => 6}/controllers/server/get-stats/snippets/get-stats.js (100%) rename doc/{src => 6}/controllers/server/get-stats/snippets/get-stats.test.yml (100%) rename doc/{src => 6}/controllers/server/index.md (100%) rename doc/{src => 6}/controllers/server/info/index.md (100%) rename doc/{src => 6}/controllers/server/info/snippets/info.js (100%) rename doc/{src => 6}/controllers/server/info/snippets/info.test.yml (100%) rename doc/{src => 6}/controllers/server/now/index.md (100%) rename doc/{src => 6}/controllers/server/now/snippets/now.js (100%) rename doc/{src => 6}/controllers/server/now/snippets/now.test.yml (100%) rename doc/{src => 6}/core-classes/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-error/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-error/introduction/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/add-once-listener/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/emit/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/emit/snippets/emit.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/introduction/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/listeners/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/on/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/once/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/prepend-listener/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/remove-all-listener/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/remove-listener/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js (100%) rename doc/{src => 6}/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/add-listener/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/add-listener/snippets/add-listener.js (100%) rename doc/{src => 6}/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/connect/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/connect/snippets/connect.js (100%) rename doc/{src => 6}/core-classes/kuzzle/connect/snippets/connect.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/constructor/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/constructor/snippets/constructor.js (100%) rename doc/{src => 6}/core-classes/kuzzle/constructor/snippets/constructor.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/disconnect/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/disconnect/snippets/disconnect.js (100%) rename doc/{src => 6}/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/flush-queue/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/flush-queue/snippets/flush-queue.js (100%) rename doc/{src => 6}/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/introduction/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/play-queue/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/play-queue/snippets/play-queue.js (100%) rename doc/{src => 6}/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/query/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/query/snippets/query.js (100%) rename doc/{src => 6}/core-classes/kuzzle/query/snippets/query.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/start-queuing/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/start-queuing/snippets/start-queuing.js (100%) rename doc/{src => 6}/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml (100%) rename doc/{src => 6}/core-classes/kuzzle/stop-queuing/index.md (100%) rename doc/{src => 6}/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js (100%) rename doc/{src => 6}/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml (100%) rename doc/{src => 6}/core-classes/profile/getRoles/index.md (100%) rename doc/{src => 6}/core-classes/profile/getRoles/snippets/getRoles.js (100%) rename doc/{src => 6}/core-classes/profile/getRoles/snippets/getRoles.test.yml (100%) rename doc/{src => 6}/core-classes/profile/index.md (100%) rename doc/{src => 6}/core-classes/profile/introduction/index.md (100%) rename doc/{src => 6}/core-classes/role/index.md (100%) rename doc/{src => 6}/core-classes/role/introduction/index.md (100%) rename doc/{src => 6}/core-classes/search-result/index.md (100%) rename doc/{src => 6}/core-classes/search-result/introduction/index.md (100%) rename doc/{src => 6}/core-classes/search-result/next/index.md (100%) rename doc/{src => 6}/core-classes/search-result/next/snippets/fromsize.js (100%) rename doc/{src => 6}/core-classes/search-result/next/snippets/fromsize.test.yml (100%) rename doc/{src => 6}/core-classes/search-result/next/snippets/scroll.js (100%) rename doc/{src => 6}/core-classes/search-result/next/snippets/scroll.test.yml (100%) rename doc/{src => 6}/core-classes/user/getProfiles/index.md (100%) rename doc/{src => 6}/core-classes/user/getProfiles/snippets/getProfiles.js (100%) rename doc/{src => 6}/core-classes/user/getProfiles/snippets/getProfiles.test.yml (100%) rename doc/{src => 6}/core-classes/user/index.md (100%) rename doc/{src => 6}/core-classes/user/introduction/index.md (100%) rename doc/{src => 6}/essentials/error-handling/index.md (100%) rename doc/{src => 6}/essentials/error-handling/snippets/error-handling-async.js (100%) rename doc/{src => 6}/essentials/error-handling/snippets/error-handling-async.test.yml (100%) rename doc/{src => 6}/essentials/error-handling/snippets/error-handling.js (100%) rename doc/{src => 6}/essentials/error-handling/snippets/error-handling.test.yml (100%) rename doc/{src => 6}/essentials/events/index.md (100%) rename doc/{src => 6}/essentials/extend-sdk/index.md (100%) rename doc/{src => 6}/essentials/getting-started/index.md (100%) rename doc/{src => 6}/essentials/getting-started/node-js/index.md (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/create.js (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/create.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/init.js (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/init.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/load-sdk.js (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/load-sdk.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/prepare-db.js (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/prepare-db.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/subscribe.js (100%) rename doc/{src => 6}/essentials/getting-started/node-js/snippets/subscribe.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/index.md (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/create.html (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/create.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/load-sdk.html (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/load-sdk.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/prepare-db.html (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/prepare-db.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/subscribe.html (100%) rename doc/{src => 6}/essentials/getting-started/raw-web/snippets/subscribe.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/webpack/index.md (100%) rename doc/{src => 6}/essentials/getting-started/webpack/snippets/create.js (100%) rename doc/{src => 6}/essentials/getting-started/webpack/snippets/create.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/webpack/snippets/init-kuzzle.js (100%) rename doc/{src => 6}/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml (100%) rename doc/{src => 6}/essentials/getting-started/webpack/snippets/subscribe.js (100%) rename doc/{src => 6}/essentials/getting-started/webpack/snippets/subscribe.test.yml (100%) rename doc/{src => 6}/essentials/index.md (100%) rename doc/{src => 6}/essentials/offline-tools/index.md (100%) rename doc/{src => 6}/essentials/realtime-notifications/index.md (100%) rename doc/{src => 6}/index.md (100%) rename doc/{src => 6}/protocols/http/constructor/index.md (100%) rename doc/{src => 6}/protocols/http/constructor/snippets/constructor.js (100%) rename doc/{src => 6}/protocols/http/constructor/snippets/constructor.test.yml (100%) rename doc/{src => 6}/protocols/http/index.md (100%) rename doc/{src => 6}/protocols/http/introduction/index.md (100%) rename doc/{src => 6}/protocols/index.md (100%) rename doc/{src => 6}/protocols/socketio/constructor/index.md (100%) rename doc/{src => 6}/protocols/socketio/constructor/snippets/constructor.js (100%) rename doc/{src => 6}/protocols/socketio/constructor/snippets/constructor.test.yml (100%) rename doc/{src => 6}/protocols/socketio/index.md (100%) rename doc/{src => 6}/protocols/socketio/introduction/index.md (100%) rename doc/{src => 6}/protocols/websocket/constructor/index.md (100%) rename doc/{src => 6}/protocols/websocket/constructor/snippets/constructor.js (100%) rename doc/{src => 6}/protocols/websocket/constructor/snippets/constructor.test.yml (100%) rename doc/{src => 6}/protocols/websocket/index.md (100%) rename doc/{src => 6}/protocols/websocket/introduction/index.md (100%) diff --git a/doc/src/controllers/auth/check-token/index.md b/doc/6/controllers/auth/check-token/index.md similarity index 100% rename from doc/src/controllers/auth/check-token/index.md rename to doc/6/controllers/auth/check-token/index.md diff --git a/doc/src/controllers/auth/check-token/snippets/check-token.js b/doc/6/controllers/auth/check-token/snippets/check-token.js similarity index 100% rename from doc/src/controllers/auth/check-token/snippets/check-token.js rename to doc/6/controllers/auth/check-token/snippets/check-token.js diff --git a/doc/src/controllers/auth/check-token/snippets/check-token.test.yml b/doc/6/controllers/auth/check-token/snippets/check-token.test.yml similarity index 100% rename from doc/src/controllers/auth/check-token/snippets/check-token.test.yml rename to doc/6/controllers/auth/check-token/snippets/check-token.test.yml diff --git a/doc/src/controllers/auth/create-my-credentials/index.md b/doc/6/controllers/auth/create-my-credentials/index.md similarity index 100% rename from doc/src/controllers/auth/create-my-credentials/index.md rename to doc/6/controllers/auth/create-my-credentials/index.md diff --git a/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.js b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js similarity index 100% rename from doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.js rename to doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js diff --git a/doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml similarity index 100% rename from doc/src/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml rename to doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml diff --git a/doc/src/controllers/auth/credentials-exist/index.md b/doc/6/controllers/auth/credentials-exist/index.md similarity index 100% rename from doc/src/controllers/auth/credentials-exist/index.md rename to doc/6/controllers/auth/credentials-exist/index.md diff --git a/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.js b/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.js similarity index 100% rename from doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.js rename to doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.js diff --git a/doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml b/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml similarity index 100% rename from doc/src/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml rename to doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml diff --git a/doc/src/controllers/auth/delete-my-credentials/index.md b/doc/6/controllers/auth/delete-my-credentials/index.md similarity index 100% rename from doc/src/controllers/auth/delete-my-credentials/index.md rename to doc/6/controllers/auth/delete-my-credentials/index.md diff --git a/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js b/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js similarity index 100% rename from doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js rename to doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js diff --git a/doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml b/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml similarity index 100% rename from doc/src/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml rename to doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml diff --git a/doc/src/controllers/auth/get-current-user/index.md b/doc/6/controllers/auth/get-current-user/index.md similarity index 100% rename from doc/src/controllers/auth/get-current-user/index.md rename to doc/6/controllers/auth/get-current-user/index.md diff --git a/doc/src/controllers/auth/get-current-user/snippets/get-current-user.js b/doc/6/controllers/auth/get-current-user/snippets/get-current-user.js similarity index 100% rename from doc/src/controllers/auth/get-current-user/snippets/get-current-user.js rename to doc/6/controllers/auth/get-current-user/snippets/get-current-user.js diff --git a/doc/src/controllers/auth/get-current-user/snippets/get-current-user.test.yml b/doc/6/controllers/auth/get-current-user/snippets/get-current-user.test.yml similarity index 100% rename from doc/src/controllers/auth/get-current-user/snippets/get-current-user.test.yml rename to doc/6/controllers/auth/get-current-user/snippets/get-current-user.test.yml diff --git a/doc/src/controllers/auth/get-my-credentials/index.md b/doc/6/controllers/auth/get-my-credentials/index.md similarity index 100% rename from doc/src/controllers/auth/get-my-credentials/index.md rename to doc/6/controllers/auth/get-my-credentials/index.md diff --git a/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.js b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js similarity index 100% rename from doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.js rename to doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js diff --git a/doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml similarity index 100% rename from doc/src/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml rename to doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml diff --git a/doc/src/controllers/auth/get-my-rights/index.md b/doc/6/controllers/auth/get-my-rights/index.md similarity index 100% rename from doc/src/controllers/auth/get-my-rights/index.md rename to doc/6/controllers/auth/get-my-rights/index.md diff --git a/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.js b/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.js similarity index 100% rename from doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.js rename to doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.js diff --git a/doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml b/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml similarity index 100% rename from doc/src/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml rename to doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml diff --git a/doc/src/controllers/auth/get-strategies/index.md b/doc/6/controllers/auth/get-strategies/index.md similarity index 100% rename from doc/src/controllers/auth/get-strategies/index.md rename to doc/6/controllers/auth/get-strategies/index.md diff --git a/doc/src/controllers/auth/get-strategies/snippets/get-strategies.js b/doc/6/controllers/auth/get-strategies/snippets/get-strategies.js similarity index 100% rename from doc/src/controllers/auth/get-strategies/snippets/get-strategies.js rename to doc/6/controllers/auth/get-strategies/snippets/get-strategies.js diff --git a/doc/src/controllers/auth/get-strategies/snippets/get-strategies.test.yml b/doc/6/controllers/auth/get-strategies/snippets/get-strategies.test.yml similarity index 100% rename from doc/src/controllers/auth/get-strategies/snippets/get-strategies.test.yml rename to doc/6/controllers/auth/get-strategies/snippets/get-strategies.test.yml diff --git a/doc/src/controllers/auth/index.md b/doc/6/controllers/auth/index.md similarity index 100% rename from doc/src/controllers/auth/index.md rename to doc/6/controllers/auth/index.md diff --git a/doc/src/controllers/auth/login/index.md b/doc/6/controllers/auth/login/index.md similarity index 100% rename from doc/src/controllers/auth/login/index.md rename to doc/6/controllers/auth/login/index.md diff --git a/doc/src/controllers/auth/login/snippets/login.js b/doc/6/controllers/auth/login/snippets/login.js similarity index 100% rename from doc/src/controllers/auth/login/snippets/login.js rename to doc/6/controllers/auth/login/snippets/login.js diff --git a/doc/src/controllers/auth/login/snippets/login.test.yml b/doc/6/controllers/auth/login/snippets/login.test.yml similarity index 100% rename from doc/src/controllers/auth/login/snippets/login.test.yml rename to doc/6/controllers/auth/login/snippets/login.test.yml diff --git a/doc/src/controllers/auth/logout/index.md b/doc/6/controllers/auth/logout/index.md similarity index 100% rename from doc/src/controllers/auth/logout/index.md rename to doc/6/controllers/auth/logout/index.md diff --git a/doc/src/controllers/auth/logout/snippets/logout.js b/doc/6/controllers/auth/logout/snippets/logout.js similarity index 100% rename from doc/src/controllers/auth/logout/snippets/logout.js rename to doc/6/controllers/auth/logout/snippets/logout.js diff --git a/doc/src/controllers/auth/logout/snippets/logout.test.yml b/doc/6/controllers/auth/logout/snippets/logout.test.yml similarity index 100% rename from doc/src/controllers/auth/logout/snippets/logout.test.yml rename to doc/6/controllers/auth/logout/snippets/logout.test.yml diff --git a/doc/src/controllers/auth/update-my-credentials/index.md b/doc/6/controllers/auth/update-my-credentials/index.md similarity index 100% rename from doc/src/controllers/auth/update-my-credentials/index.md rename to doc/6/controllers/auth/update-my-credentials/index.md diff --git a/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.js b/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.js similarity index 100% rename from doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.js rename to doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.js diff --git a/doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml b/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml similarity index 100% rename from doc/src/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml rename to doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml diff --git a/doc/src/controllers/auth/update-self/index.md b/doc/6/controllers/auth/update-self/index.md similarity index 100% rename from doc/src/controllers/auth/update-self/index.md rename to doc/6/controllers/auth/update-self/index.md diff --git a/doc/src/controllers/auth/update-self/snippets/update-self.js b/doc/6/controllers/auth/update-self/snippets/update-self.js similarity index 100% rename from doc/src/controllers/auth/update-self/snippets/update-self.js rename to doc/6/controllers/auth/update-self/snippets/update-self.js diff --git a/doc/src/controllers/auth/update-self/snippets/update-self.test.yml b/doc/6/controllers/auth/update-self/snippets/update-self.test.yml similarity index 100% rename from doc/src/controllers/auth/update-self/snippets/update-self.test.yml rename to doc/6/controllers/auth/update-self/snippets/update-self.test.yml diff --git a/doc/src/controllers/auth/validate-my-credentials/index.md b/doc/6/controllers/auth/validate-my-credentials/index.md similarity index 100% rename from doc/src/controllers/auth/validate-my-credentials/index.md rename to doc/6/controllers/auth/validate-my-credentials/index.md diff --git a/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js b/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js similarity index 100% rename from doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js rename to doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js diff --git a/doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml b/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml similarity index 100% rename from doc/src/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml rename to doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml diff --git a/doc/src/controllers/bulk/import/index.md b/doc/6/controllers/bulk/import/index.md similarity index 100% rename from doc/src/controllers/bulk/import/index.md rename to doc/6/controllers/bulk/import/index.md diff --git a/doc/src/controllers/bulk/import/snippets/import.js b/doc/6/controllers/bulk/import/snippets/import.js similarity index 100% rename from doc/src/controllers/bulk/import/snippets/import.js rename to doc/6/controllers/bulk/import/snippets/import.js diff --git a/doc/src/controllers/bulk/import/snippets/import.test.yml b/doc/6/controllers/bulk/import/snippets/import.test.yml similarity index 100% rename from doc/src/controllers/bulk/import/snippets/import.test.yml rename to doc/6/controllers/bulk/import/snippets/import.test.yml diff --git a/doc/src/controllers/bulk/index.md b/doc/6/controllers/bulk/index.md similarity index 100% rename from doc/src/controllers/bulk/index.md rename to doc/6/controllers/bulk/index.md diff --git a/doc/src/controllers/collection/create/index.md b/doc/6/controllers/collection/create/index.md similarity index 100% rename from doc/src/controllers/collection/create/index.md rename to doc/6/controllers/collection/create/index.md diff --git a/doc/src/controllers/collection/create/snippets/create.js b/doc/6/controllers/collection/create/snippets/create.js similarity index 100% rename from doc/src/controllers/collection/create/snippets/create.js rename to doc/6/controllers/collection/create/snippets/create.js diff --git a/doc/src/controllers/collection/create/snippets/create.test.yml b/doc/6/controllers/collection/create/snippets/create.test.yml similarity index 100% rename from doc/src/controllers/collection/create/snippets/create.test.yml rename to doc/6/controllers/collection/create/snippets/create.test.yml diff --git a/doc/src/controllers/collection/delete-specifications/index.md b/doc/6/controllers/collection/delete-specifications/index.md similarity index 100% rename from doc/src/controllers/collection/delete-specifications/index.md rename to doc/6/controllers/collection/delete-specifications/index.md diff --git a/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.js b/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.js similarity index 100% rename from doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.js rename to doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.js diff --git a/doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml b/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml similarity index 100% rename from doc/src/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml rename to doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml diff --git a/doc/src/controllers/collection/exists/index.md b/doc/6/controllers/collection/exists/index.md similarity index 100% rename from doc/src/controllers/collection/exists/index.md rename to doc/6/controllers/collection/exists/index.md diff --git a/doc/src/controllers/collection/exists/snippets/exists.js b/doc/6/controllers/collection/exists/snippets/exists.js similarity index 100% rename from doc/src/controllers/collection/exists/snippets/exists.js rename to doc/6/controllers/collection/exists/snippets/exists.js diff --git a/doc/src/controllers/collection/exists/snippets/exists.test.yml b/doc/6/controllers/collection/exists/snippets/exists.test.yml similarity index 100% rename from doc/src/controllers/collection/exists/snippets/exists.test.yml rename to doc/6/controllers/collection/exists/snippets/exists.test.yml diff --git a/doc/src/controllers/collection/get-mapping/index.md b/doc/6/controllers/collection/get-mapping/index.md similarity index 100% rename from doc/src/controllers/collection/get-mapping/index.md rename to doc/6/controllers/collection/get-mapping/index.md diff --git a/doc/src/controllers/collection/get-mapping/snippets/get-mapping.js b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js similarity index 100% rename from doc/src/controllers/collection/get-mapping/snippets/get-mapping.js rename to doc/6/controllers/collection/get-mapping/snippets/get-mapping.js diff --git a/doc/src/controllers/collection/get-mapping/snippets/get-mapping.test.yml b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.test.yml similarity index 100% rename from doc/src/controllers/collection/get-mapping/snippets/get-mapping.test.yml rename to doc/6/controllers/collection/get-mapping/snippets/get-mapping.test.yml diff --git a/doc/src/controllers/collection/get-specifications/index.md b/doc/6/controllers/collection/get-specifications/index.md similarity index 100% rename from doc/src/controllers/collection/get-specifications/index.md rename to doc/6/controllers/collection/get-specifications/index.md diff --git a/doc/src/controllers/collection/get-specifications/snippets/get-specifications.js b/doc/6/controllers/collection/get-specifications/snippets/get-specifications.js similarity index 100% rename from doc/src/controllers/collection/get-specifications/snippets/get-specifications.js rename to doc/6/controllers/collection/get-specifications/snippets/get-specifications.js diff --git a/doc/src/controllers/collection/get-specifications/snippets/get-specifications.test.yml b/doc/6/controllers/collection/get-specifications/snippets/get-specifications.test.yml similarity index 100% rename from doc/src/controllers/collection/get-specifications/snippets/get-specifications.test.yml rename to doc/6/controllers/collection/get-specifications/snippets/get-specifications.test.yml diff --git a/doc/src/controllers/collection/index.md b/doc/6/controllers/collection/index.md similarity index 100% rename from doc/src/controllers/collection/index.md rename to doc/6/controllers/collection/index.md diff --git a/doc/src/controllers/collection/list/index.md b/doc/6/controllers/collection/list/index.md similarity index 100% rename from doc/src/controllers/collection/list/index.md rename to doc/6/controllers/collection/list/index.md diff --git a/doc/src/controllers/collection/list/snippets/list.js b/doc/6/controllers/collection/list/snippets/list.js similarity index 100% rename from doc/src/controllers/collection/list/snippets/list.js rename to doc/6/controllers/collection/list/snippets/list.js diff --git a/doc/src/controllers/collection/list/snippets/list.test.yml b/doc/6/controllers/collection/list/snippets/list.test.yml similarity index 100% rename from doc/src/controllers/collection/list/snippets/list.test.yml rename to doc/6/controllers/collection/list/snippets/list.test.yml diff --git a/doc/src/controllers/collection/search-specifications/index.md b/doc/6/controllers/collection/search-specifications/index.md similarity index 100% rename from doc/src/controllers/collection/search-specifications/index.md rename to doc/6/controllers/collection/search-specifications/index.md diff --git a/doc/src/controllers/collection/search-specifications/snippets/search-specifications.js b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.js similarity index 100% rename from doc/src/controllers/collection/search-specifications/snippets/search-specifications.js rename to doc/6/controllers/collection/search-specifications/snippets/search-specifications.js diff --git a/doc/src/controllers/collection/search-specifications/snippets/search-specifications.test.yml b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml similarity index 100% rename from doc/src/controllers/collection/search-specifications/snippets/search-specifications.test.yml rename to doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml diff --git a/doc/src/controllers/collection/truncate/index.md b/doc/6/controllers/collection/truncate/index.md similarity index 100% rename from doc/src/controllers/collection/truncate/index.md rename to doc/6/controllers/collection/truncate/index.md diff --git a/doc/src/controllers/collection/truncate/snippets/truncate.js b/doc/6/controllers/collection/truncate/snippets/truncate.js similarity index 100% rename from doc/src/controllers/collection/truncate/snippets/truncate.js rename to doc/6/controllers/collection/truncate/snippets/truncate.js diff --git a/doc/src/controllers/collection/truncate/snippets/truncate.test.yml b/doc/6/controllers/collection/truncate/snippets/truncate.test.yml similarity index 100% rename from doc/src/controllers/collection/truncate/snippets/truncate.test.yml rename to doc/6/controllers/collection/truncate/snippets/truncate.test.yml diff --git a/doc/src/controllers/collection/update-mapping/index.md b/doc/6/controllers/collection/update-mapping/index.md similarity index 100% rename from doc/src/controllers/collection/update-mapping/index.md rename to doc/6/controllers/collection/update-mapping/index.md diff --git a/doc/src/controllers/collection/update-mapping/snippets/update-mapping.js b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js similarity index 100% rename from doc/src/controllers/collection/update-mapping/snippets/update-mapping.js rename to doc/6/controllers/collection/update-mapping/snippets/update-mapping.js diff --git a/doc/src/controllers/collection/update-mapping/snippets/update-mapping.test.yml b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.test.yml similarity index 100% rename from doc/src/controllers/collection/update-mapping/snippets/update-mapping.test.yml rename to doc/6/controllers/collection/update-mapping/snippets/update-mapping.test.yml diff --git a/doc/src/controllers/collection/update-specifications/index.md b/doc/6/controllers/collection/update-specifications/index.md similarity index 100% rename from doc/src/controllers/collection/update-specifications/index.md rename to doc/6/controllers/collection/update-specifications/index.md diff --git a/doc/src/controllers/collection/update-specifications/snippets/update-specifications.js b/doc/6/controllers/collection/update-specifications/snippets/update-specifications.js similarity index 100% rename from doc/src/controllers/collection/update-specifications/snippets/update-specifications.js rename to doc/6/controllers/collection/update-specifications/snippets/update-specifications.js diff --git a/doc/src/controllers/collection/update-specifications/snippets/update-specifications.test.yml b/doc/6/controllers/collection/update-specifications/snippets/update-specifications.test.yml similarity index 100% rename from doc/src/controllers/collection/update-specifications/snippets/update-specifications.test.yml rename to doc/6/controllers/collection/update-specifications/snippets/update-specifications.test.yml diff --git a/doc/src/controllers/collection/validate-specifications/index.md b/doc/6/controllers/collection/validate-specifications/index.md similarity index 100% rename from doc/src/controllers/collection/validate-specifications/index.md rename to doc/6/controllers/collection/validate-specifications/index.md diff --git a/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.js b/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.js similarity index 100% rename from doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.js rename to doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.js diff --git a/doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml b/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml similarity index 100% rename from doc/src/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml rename to doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml diff --git a/doc/src/controllers/document/count/index.md b/doc/6/controllers/document/count/index.md similarity index 100% rename from doc/src/controllers/document/count/index.md rename to doc/6/controllers/document/count/index.md diff --git a/doc/src/controllers/document/count/snippets/count.js b/doc/6/controllers/document/count/snippets/count.js similarity index 100% rename from doc/src/controllers/document/count/snippets/count.js rename to doc/6/controllers/document/count/snippets/count.js diff --git a/doc/src/controllers/document/count/snippets/count.test.yml b/doc/6/controllers/document/count/snippets/count.test.yml similarity index 100% rename from doc/src/controllers/document/count/snippets/count.test.yml rename to doc/6/controllers/document/count/snippets/count.test.yml diff --git a/doc/src/controllers/document/create/index.md b/doc/6/controllers/document/create/index.md similarity index 100% rename from doc/src/controllers/document/create/index.md rename to doc/6/controllers/document/create/index.md diff --git a/doc/src/controllers/document/create/snippets/create.js b/doc/6/controllers/document/create/snippets/create.js similarity index 100% rename from doc/src/controllers/document/create/snippets/create.js rename to doc/6/controllers/document/create/snippets/create.js diff --git a/doc/src/controllers/document/create/snippets/create.test.yml b/doc/6/controllers/document/create/snippets/create.test.yml similarity index 100% rename from doc/src/controllers/document/create/snippets/create.test.yml rename to doc/6/controllers/document/create/snippets/create.test.yml diff --git a/doc/src/controllers/document/createOrReplace/index.md b/doc/6/controllers/document/createOrReplace/index.md similarity index 100% rename from doc/src/controllers/document/createOrReplace/index.md rename to doc/6/controllers/document/createOrReplace/index.md diff --git a/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.js b/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.js similarity index 100% rename from doc/src/controllers/document/createOrReplace/snippets/create-or-replace.js rename to doc/6/controllers/document/createOrReplace/snippets/create-or-replace.js diff --git a/doc/src/controllers/document/createOrReplace/snippets/create-or-replace.test.yml b/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.test.yml similarity index 100% rename from doc/src/controllers/document/createOrReplace/snippets/create-or-replace.test.yml rename to doc/6/controllers/document/createOrReplace/snippets/create-or-replace.test.yml diff --git a/doc/src/controllers/document/delete/index.md b/doc/6/controllers/document/delete/index.md similarity index 100% rename from doc/src/controllers/document/delete/index.md rename to doc/6/controllers/document/delete/index.md diff --git a/doc/src/controllers/document/delete/snippets/delete.js b/doc/6/controllers/document/delete/snippets/delete.js similarity index 100% rename from doc/src/controllers/document/delete/snippets/delete.js rename to doc/6/controllers/document/delete/snippets/delete.js diff --git a/doc/src/controllers/document/delete/snippets/delete.test.yml b/doc/6/controllers/document/delete/snippets/delete.test.yml similarity index 100% rename from doc/src/controllers/document/delete/snippets/delete.test.yml rename to doc/6/controllers/document/delete/snippets/delete.test.yml diff --git a/doc/src/controllers/document/deleteByQuery/index.md b/doc/6/controllers/document/deleteByQuery/index.md similarity index 100% rename from doc/src/controllers/document/deleteByQuery/index.md rename to doc/6/controllers/document/deleteByQuery/index.md diff --git a/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.js b/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.js similarity index 100% rename from doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.js rename to doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.js diff --git a/doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml b/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml similarity index 100% rename from doc/src/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml rename to doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml diff --git a/doc/src/controllers/document/get/index.md b/doc/6/controllers/document/get/index.md similarity index 100% rename from doc/src/controllers/document/get/index.md rename to doc/6/controllers/document/get/index.md diff --git a/doc/src/controllers/document/get/snippets/get.js b/doc/6/controllers/document/get/snippets/get.js similarity index 100% rename from doc/src/controllers/document/get/snippets/get.js rename to doc/6/controllers/document/get/snippets/get.js diff --git a/doc/src/controllers/document/get/snippets/get.test.yml b/doc/6/controllers/document/get/snippets/get.test.yml similarity index 100% rename from doc/src/controllers/document/get/snippets/get.test.yml rename to doc/6/controllers/document/get/snippets/get.test.yml diff --git a/doc/src/controllers/document/index.md b/doc/6/controllers/document/index.md similarity index 100% rename from doc/src/controllers/document/index.md rename to doc/6/controllers/document/index.md diff --git a/doc/src/controllers/document/mCreate/index.md b/doc/6/controllers/document/mCreate/index.md similarity index 100% rename from doc/src/controllers/document/mCreate/index.md rename to doc/6/controllers/document/mCreate/index.md diff --git a/doc/src/controllers/document/mCreate/snippets/m-create.js b/doc/6/controllers/document/mCreate/snippets/m-create.js similarity index 100% rename from doc/src/controllers/document/mCreate/snippets/m-create.js rename to doc/6/controllers/document/mCreate/snippets/m-create.js diff --git a/doc/src/controllers/document/mCreate/snippets/m-create.test.yml b/doc/6/controllers/document/mCreate/snippets/m-create.test.yml similarity index 100% rename from doc/src/controllers/document/mCreate/snippets/m-create.test.yml rename to doc/6/controllers/document/mCreate/snippets/m-create.test.yml diff --git a/doc/src/controllers/document/mCreateOrReplace/index.md b/doc/6/controllers/document/mCreateOrReplace/index.md similarity index 100% rename from doc/src/controllers/document/mCreateOrReplace/index.md rename to doc/6/controllers/document/mCreateOrReplace/index.md diff --git a/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js b/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js similarity index 100% rename from doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js rename to doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js diff --git a/doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml b/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml similarity index 100% rename from doc/src/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml rename to doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml diff --git a/doc/src/controllers/document/mDelete/index.md b/doc/6/controllers/document/mDelete/index.md similarity index 100% rename from doc/src/controllers/document/mDelete/index.md rename to doc/6/controllers/document/mDelete/index.md diff --git a/doc/src/controllers/document/mDelete/snippets/m-delete.js b/doc/6/controllers/document/mDelete/snippets/m-delete.js similarity index 100% rename from doc/src/controllers/document/mDelete/snippets/m-delete.js rename to doc/6/controllers/document/mDelete/snippets/m-delete.js diff --git a/doc/src/controllers/document/mDelete/snippets/m-delete.test.yml b/doc/6/controllers/document/mDelete/snippets/m-delete.test.yml similarity index 100% rename from doc/src/controllers/document/mDelete/snippets/m-delete.test.yml rename to doc/6/controllers/document/mDelete/snippets/m-delete.test.yml diff --git a/doc/src/controllers/document/mGet/index.md b/doc/6/controllers/document/mGet/index.md similarity index 100% rename from doc/src/controllers/document/mGet/index.md rename to doc/6/controllers/document/mGet/index.md diff --git a/doc/src/controllers/document/mGet/snippets/m-get.js b/doc/6/controllers/document/mGet/snippets/m-get.js similarity index 100% rename from doc/src/controllers/document/mGet/snippets/m-get.js rename to doc/6/controllers/document/mGet/snippets/m-get.js diff --git a/doc/src/controllers/document/mGet/snippets/m-get.test.yml b/doc/6/controllers/document/mGet/snippets/m-get.test.yml similarity index 100% rename from doc/src/controllers/document/mGet/snippets/m-get.test.yml rename to doc/6/controllers/document/mGet/snippets/m-get.test.yml diff --git a/doc/src/controllers/document/mReplace/index.md b/doc/6/controllers/document/mReplace/index.md similarity index 100% rename from doc/src/controllers/document/mReplace/index.md rename to doc/6/controllers/document/mReplace/index.md diff --git a/doc/src/controllers/document/mReplace/snippets/m-replace.js b/doc/6/controllers/document/mReplace/snippets/m-replace.js similarity index 100% rename from doc/src/controllers/document/mReplace/snippets/m-replace.js rename to doc/6/controllers/document/mReplace/snippets/m-replace.js diff --git a/doc/src/controllers/document/mReplace/snippets/m-replace.test.yml b/doc/6/controllers/document/mReplace/snippets/m-replace.test.yml similarity index 100% rename from doc/src/controllers/document/mReplace/snippets/m-replace.test.yml rename to doc/6/controllers/document/mReplace/snippets/m-replace.test.yml diff --git a/doc/src/controllers/document/mUpdate/index.md b/doc/6/controllers/document/mUpdate/index.md similarity index 100% rename from doc/src/controllers/document/mUpdate/index.md rename to doc/6/controllers/document/mUpdate/index.md diff --git a/doc/src/controllers/document/mUpdate/snippets/m-update.js b/doc/6/controllers/document/mUpdate/snippets/m-update.js similarity index 100% rename from doc/src/controllers/document/mUpdate/snippets/m-update.js rename to doc/6/controllers/document/mUpdate/snippets/m-update.js diff --git a/doc/src/controllers/document/mUpdate/snippets/m-update.test.yml b/doc/6/controllers/document/mUpdate/snippets/m-update.test.yml similarity index 100% rename from doc/src/controllers/document/mUpdate/snippets/m-update.test.yml rename to doc/6/controllers/document/mUpdate/snippets/m-update.test.yml diff --git a/doc/src/controllers/document/replace/index.md b/doc/6/controllers/document/replace/index.md similarity index 100% rename from doc/src/controllers/document/replace/index.md rename to doc/6/controllers/document/replace/index.md diff --git a/doc/src/controllers/document/replace/snippets/replace.js b/doc/6/controllers/document/replace/snippets/replace.js similarity index 100% rename from doc/src/controllers/document/replace/snippets/replace.js rename to doc/6/controllers/document/replace/snippets/replace.js diff --git a/doc/src/controllers/document/replace/snippets/replace.test.yml b/doc/6/controllers/document/replace/snippets/replace.test.yml similarity index 100% rename from doc/src/controllers/document/replace/snippets/replace.test.yml rename to doc/6/controllers/document/replace/snippets/replace.test.yml diff --git a/doc/src/controllers/document/search/index.md b/doc/6/controllers/document/search/index.md similarity index 100% rename from doc/src/controllers/document/search/index.md rename to doc/6/controllers/document/search/index.md diff --git a/doc/src/controllers/document/search/snippets/search.js b/doc/6/controllers/document/search/snippets/search.js similarity index 100% rename from doc/src/controllers/document/search/snippets/search.js rename to doc/6/controllers/document/search/snippets/search.js diff --git a/doc/src/controllers/document/search/snippets/search.test.yml b/doc/6/controllers/document/search/snippets/search.test.yml similarity index 100% rename from doc/src/controllers/document/search/snippets/search.test.yml rename to doc/6/controllers/document/search/snippets/search.test.yml diff --git a/doc/src/controllers/document/update/index.md b/doc/6/controllers/document/update/index.md similarity index 100% rename from doc/src/controllers/document/update/index.md rename to doc/6/controllers/document/update/index.md diff --git a/doc/src/controllers/document/update/snippets/update.js b/doc/6/controllers/document/update/snippets/update.js similarity index 100% rename from doc/src/controllers/document/update/snippets/update.js rename to doc/6/controllers/document/update/snippets/update.js diff --git a/doc/src/controllers/document/update/snippets/update.test.yml b/doc/6/controllers/document/update/snippets/update.test.yml similarity index 100% rename from doc/src/controllers/document/update/snippets/update.test.yml rename to doc/6/controllers/document/update/snippets/update.test.yml diff --git a/doc/src/controllers/document/validate/index.md b/doc/6/controllers/document/validate/index.md similarity index 100% rename from doc/src/controllers/document/validate/index.md rename to doc/6/controllers/document/validate/index.md diff --git a/doc/src/controllers/document/validate/snippets/validate.js b/doc/6/controllers/document/validate/snippets/validate.js similarity index 100% rename from doc/src/controllers/document/validate/snippets/validate.js rename to doc/6/controllers/document/validate/snippets/validate.js diff --git a/doc/src/controllers/document/validate/snippets/validate.test.yml b/doc/6/controllers/document/validate/snippets/validate.test.yml similarity index 100% rename from doc/src/controllers/document/validate/snippets/validate.test.yml rename to doc/6/controllers/document/validate/snippets/validate.test.yml diff --git a/doc/src/controllers/index.md b/doc/6/controllers/index.md similarity index 100% rename from doc/src/controllers/index.md rename to doc/6/controllers/index.md diff --git a/doc/src/controllers/index/create/index.md b/doc/6/controllers/index/create/index.md similarity index 100% rename from doc/src/controllers/index/create/index.md rename to doc/6/controllers/index/create/index.md diff --git a/doc/src/controllers/index/create/snippets/create.js b/doc/6/controllers/index/create/snippets/create.js similarity index 100% rename from doc/src/controllers/index/create/snippets/create.js rename to doc/6/controllers/index/create/snippets/create.js diff --git a/doc/src/controllers/index/create/snippets/create.test.yml b/doc/6/controllers/index/create/snippets/create.test.yml similarity index 100% rename from doc/src/controllers/index/create/snippets/create.test.yml rename to doc/6/controllers/index/create/snippets/create.test.yml diff --git a/doc/src/controllers/index/delete/index.md b/doc/6/controllers/index/delete/index.md similarity index 100% rename from doc/src/controllers/index/delete/index.md rename to doc/6/controllers/index/delete/index.md diff --git a/doc/src/controllers/index/delete/snippets/delete.js b/doc/6/controllers/index/delete/snippets/delete.js similarity index 100% rename from doc/src/controllers/index/delete/snippets/delete.js rename to doc/6/controllers/index/delete/snippets/delete.js diff --git a/doc/src/controllers/index/delete/snippets/delete.test.yml b/doc/6/controllers/index/delete/snippets/delete.test.yml similarity index 100% rename from doc/src/controllers/index/delete/snippets/delete.test.yml rename to doc/6/controllers/index/delete/snippets/delete.test.yml diff --git a/doc/src/controllers/index/exists/index.md b/doc/6/controllers/index/exists/index.md similarity index 100% rename from doc/src/controllers/index/exists/index.md rename to doc/6/controllers/index/exists/index.md diff --git a/doc/src/controllers/index/exists/snippets/exists.js b/doc/6/controllers/index/exists/snippets/exists.js similarity index 100% rename from doc/src/controllers/index/exists/snippets/exists.js rename to doc/6/controllers/index/exists/snippets/exists.js diff --git a/doc/src/controllers/index/exists/snippets/exists.test.yml b/doc/6/controllers/index/exists/snippets/exists.test.yml similarity index 100% rename from doc/src/controllers/index/exists/snippets/exists.test.yml rename to doc/6/controllers/index/exists/snippets/exists.test.yml diff --git a/doc/src/controllers/index/get-auto-refresh/index.md b/doc/6/controllers/index/get-auto-refresh/index.md similarity index 100% rename from doc/src/controllers/index/get-auto-refresh/index.md rename to doc/6/controllers/index/get-auto-refresh/index.md diff --git a/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js b/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js similarity index 100% rename from doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js rename to doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js diff --git a/doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml b/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml similarity index 100% rename from doc/src/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml rename to doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml diff --git a/doc/src/controllers/index/index.md b/doc/6/controllers/index/index.md similarity index 100% rename from doc/src/controllers/index/index.md rename to doc/6/controllers/index/index.md diff --git a/doc/src/controllers/index/list/index.md b/doc/6/controllers/index/list/index.md similarity index 100% rename from doc/src/controllers/index/list/index.md rename to doc/6/controllers/index/list/index.md diff --git a/doc/src/controllers/index/list/snippets/list.js b/doc/6/controllers/index/list/snippets/list.js similarity index 100% rename from doc/src/controllers/index/list/snippets/list.js rename to doc/6/controllers/index/list/snippets/list.js diff --git a/doc/src/controllers/index/list/snippets/list.test.yml b/doc/6/controllers/index/list/snippets/list.test.yml similarity index 100% rename from doc/src/controllers/index/list/snippets/list.test.yml rename to doc/6/controllers/index/list/snippets/list.test.yml diff --git a/doc/src/controllers/index/m-delete/index.md b/doc/6/controllers/index/m-delete/index.md similarity index 100% rename from doc/src/controllers/index/m-delete/index.md rename to doc/6/controllers/index/m-delete/index.md diff --git a/doc/src/controllers/index/m-delete/snippets/mDelete.js b/doc/6/controllers/index/m-delete/snippets/mDelete.js similarity index 100% rename from doc/src/controllers/index/m-delete/snippets/mDelete.js rename to doc/6/controllers/index/m-delete/snippets/mDelete.js diff --git a/doc/src/controllers/index/m-delete/snippets/mDelete.test.yml b/doc/6/controllers/index/m-delete/snippets/mDelete.test.yml similarity index 100% rename from doc/src/controllers/index/m-delete/snippets/mDelete.test.yml rename to doc/6/controllers/index/m-delete/snippets/mDelete.test.yml diff --git a/doc/src/controllers/index/refresh-internal/index.md b/doc/6/controllers/index/refresh-internal/index.md similarity index 100% rename from doc/src/controllers/index/refresh-internal/index.md rename to doc/6/controllers/index/refresh-internal/index.md diff --git a/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.js b/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.js similarity index 100% rename from doc/src/controllers/index/refresh-internal/snippets/refreshInternal.js rename to doc/6/controllers/index/refresh-internal/snippets/refreshInternal.js diff --git a/doc/src/controllers/index/refresh-internal/snippets/refreshInternal.test.yml b/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.test.yml similarity index 100% rename from doc/src/controllers/index/refresh-internal/snippets/refreshInternal.test.yml rename to doc/6/controllers/index/refresh-internal/snippets/refreshInternal.test.yml diff --git a/doc/src/controllers/index/refresh/index.md b/doc/6/controllers/index/refresh/index.md similarity index 100% rename from doc/src/controllers/index/refresh/index.md rename to doc/6/controllers/index/refresh/index.md diff --git a/doc/src/controllers/index/refresh/snippets/refresh.js b/doc/6/controllers/index/refresh/snippets/refresh.js similarity index 100% rename from doc/src/controllers/index/refresh/snippets/refresh.js rename to doc/6/controllers/index/refresh/snippets/refresh.js diff --git a/doc/src/controllers/index/refresh/snippets/refresh.test.yml b/doc/6/controllers/index/refresh/snippets/refresh.test.yml similarity index 100% rename from doc/src/controllers/index/refresh/snippets/refresh.test.yml rename to doc/6/controllers/index/refresh/snippets/refresh.test.yml diff --git a/doc/src/controllers/index/set-auto-refresh/index.md b/doc/6/controllers/index/set-auto-refresh/index.md similarity index 100% rename from doc/src/controllers/index/set-auto-refresh/index.md rename to doc/6/controllers/index/set-auto-refresh/index.md diff --git a/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js b/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js similarity index 100% rename from doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js rename to doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js diff --git a/doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml b/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml similarity index 100% rename from doc/src/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml rename to doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml diff --git a/doc/src/controllers/ms/append/index.md b/doc/6/controllers/ms/append/index.md similarity index 100% rename from doc/src/controllers/ms/append/index.md rename to doc/6/controllers/ms/append/index.md diff --git a/doc/src/controllers/ms/append/snippets/append.js b/doc/6/controllers/ms/append/snippets/append.js similarity index 100% rename from doc/src/controllers/ms/append/snippets/append.js rename to doc/6/controllers/ms/append/snippets/append.js diff --git a/doc/src/controllers/ms/append/snippets/append.test.yml b/doc/6/controllers/ms/append/snippets/append.test.yml similarity index 100% rename from doc/src/controllers/ms/append/snippets/append.test.yml rename to doc/6/controllers/ms/append/snippets/append.test.yml diff --git a/doc/src/controllers/ms/bitcount/index.md b/doc/6/controllers/ms/bitcount/index.md similarity index 100% rename from doc/src/controllers/ms/bitcount/index.md rename to doc/6/controllers/ms/bitcount/index.md diff --git a/doc/src/controllers/ms/bitcount/snippets/bitcount.js b/doc/6/controllers/ms/bitcount/snippets/bitcount.js similarity index 100% rename from doc/src/controllers/ms/bitcount/snippets/bitcount.js rename to doc/6/controllers/ms/bitcount/snippets/bitcount.js diff --git a/doc/src/controllers/ms/bitcount/snippets/bitcount.test.yml b/doc/6/controllers/ms/bitcount/snippets/bitcount.test.yml similarity index 100% rename from doc/src/controllers/ms/bitcount/snippets/bitcount.test.yml rename to doc/6/controllers/ms/bitcount/snippets/bitcount.test.yml diff --git a/doc/src/controllers/ms/bitop/index.md b/doc/6/controllers/ms/bitop/index.md similarity index 100% rename from doc/src/controllers/ms/bitop/index.md rename to doc/6/controllers/ms/bitop/index.md diff --git a/doc/src/controllers/ms/bitop/snippets/bitop.js b/doc/6/controllers/ms/bitop/snippets/bitop.js similarity index 100% rename from doc/src/controllers/ms/bitop/snippets/bitop.js rename to doc/6/controllers/ms/bitop/snippets/bitop.js diff --git a/doc/src/controllers/ms/bitop/snippets/bitop.test.yml b/doc/6/controllers/ms/bitop/snippets/bitop.test.yml similarity index 100% rename from doc/src/controllers/ms/bitop/snippets/bitop.test.yml rename to doc/6/controllers/ms/bitop/snippets/bitop.test.yml diff --git a/doc/src/controllers/ms/bitpos/index.md b/doc/6/controllers/ms/bitpos/index.md similarity index 100% rename from doc/src/controllers/ms/bitpos/index.md rename to doc/6/controllers/ms/bitpos/index.md diff --git a/doc/src/controllers/ms/bitpos/snippets/bitpos.js b/doc/6/controllers/ms/bitpos/snippets/bitpos.js similarity index 100% rename from doc/src/controllers/ms/bitpos/snippets/bitpos.js rename to doc/6/controllers/ms/bitpos/snippets/bitpos.js diff --git a/doc/src/controllers/ms/bitpos/snippets/bitpos.test.yml b/doc/6/controllers/ms/bitpos/snippets/bitpos.test.yml similarity index 100% rename from doc/src/controllers/ms/bitpos/snippets/bitpos.test.yml rename to doc/6/controllers/ms/bitpos/snippets/bitpos.test.yml diff --git a/doc/src/controllers/ms/dbsize/index.md b/doc/6/controllers/ms/dbsize/index.md similarity index 100% rename from doc/src/controllers/ms/dbsize/index.md rename to doc/6/controllers/ms/dbsize/index.md diff --git a/doc/src/controllers/ms/dbsize/snippets/dbsize.js b/doc/6/controllers/ms/dbsize/snippets/dbsize.js similarity index 100% rename from doc/src/controllers/ms/dbsize/snippets/dbsize.js rename to doc/6/controllers/ms/dbsize/snippets/dbsize.js diff --git a/doc/src/controllers/ms/dbsize/snippets/dbsize.test.yml b/doc/6/controllers/ms/dbsize/snippets/dbsize.test.yml similarity index 100% rename from doc/src/controllers/ms/dbsize/snippets/dbsize.test.yml rename to doc/6/controllers/ms/dbsize/snippets/dbsize.test.yml diff --git a/doc/src/controllers/ms/decr/index.md b/doc/6/controllers/ms/decr/index.md similarity index 100% rename from doc/src/controllers/ms/decr/index.md rename to doc/6/controllers/ms/decr/index.md diff --git a/doc/src/controllers/ms/decr/snippets/decr.js b/doc/6/controllers/ms/decr/snippets/decr.js similarity index 100% rename from doc/src/controllers/ms/decr/snippets/decr.js rename to doc/6/controllers/ms/decr/snippets/decr.js diff --git a/doc/src/controllers/ms/decr/snippets/decr.test.yml b/doc/6/controllers/ms/decr/snippets/decr.test.yml similarity index 100% rename from doc/src/controllers/ms/decr/snippets/decr.test.yml rename to doc/6/controllers/ms/decr/snippets/decr.test.yml diff --git a/doc/src/controllers/ms/decrby/index.md b/doc/6/controllers/ms/decrby/index.md similarity index 100% rename from doc/src/controllers/ms/decrby/index.md rename to doc/6/controllers/ms/decrby/index.md diff --git a/doc/src/controllers/ms/decrby/snippets/decrby.js b/doc/6/controllers/ms/decrby/snippets/decrby.js similarity index 100% rename from doc/src/controllers/ms/decrby/snippets/decrby.js rename to doc/6/controllers/ms/decrby/snippets/decrby.js diff --git a/doc/src/controllers/ms/decrby/snippets/decrby.test.yml b/doc/6/controllers/ms/decrby/snippets/decrby.test.yml similarity index 100% rename from doc/src/controllers/ms/decrby/snippets/decrby.test.yml rename to doc/6/controllers/ms/decrby/snippets/decrby.test.yml diff --git a/doc/src/controllers/ms/del/index.md b/doc/6/controllers/ms/del/index.md similarity index 100% rename from doc/src/controllers/ms/del/index.md rename to doc/6/controllers/ms/del/index.md diff --git a/doc/src/controllers/ms/del/snippets/del.js b/doc/6/controllers/ms/del/snippets/del.js similarity index 100% rename from doc/src/controllers/ms/del/snippets/del.js rename to doc/6/controllers/ms/del/snippets/del.js diff --git a/doc/src/controllers/ms/del/snippets/del.test.yml b/doc/6/controllers/ms/del/snippets/del.test.yml similarity index 100% rename from doc/src/controllers/ms/del/snippets/del.test.yml rename to doc/6/controllers/ms/del/snippets/del.test.yml diff --git a/doc/src/controllers/ms/exists/index.md b/doc/6/controllers/ms/exists/index.md similarity index 100% rename from doc/src/controllers/ms/exists/index.md rename to doc/6/controllers/ms/exists/index.md diff --git a/doc/src/controllers/ms/exists/snippets/exists.js b/doc/6/controllers/ms/exists/snippets/exists.js similarity index 100% rename from doc/src/controllers/ms/exists/snippets/exists.js rename to doc/6/controllers/ms/exists/snippets/exists.js diff --git a/doc/src/controllers/ms/exists/snippets/exists.test.yml b/doc/6/controllers/ms/exists/snippets/exists.test.yml similarity index 100% rename from doc/src/controllers/ms/exists/snippets/exists.test.yml rename to doc/6/controllers/ms/exists/snippets/exists.test.yml diff --git a/doc/src/controllers/ms/expire/index.md b/doc/6/controllers/ms/expire/index.md similarity index 100% rename from doc/src/controllers/ms/expire/index.md rename to doc/6/controllers/ms/expire/index.md diff --git a/doc/src/controllers/ms/expire/snippets/expire.js b/doc/6/controllers/ms/expire/snippets/expire.js similarity index 100% rename from doc/src/controllers/ms/expire/snippets/expire.js rename to doc/6/controllers/ms/expire/snippets/expire.js diff --git a/doc/src/controllers/ms/expire/snippets/expire.test.yml b/doc/6/controllers/ms/expire/snippets/expire.test.yml similarity index 100% rename from doc/src/controllers/ms/expire/snippets/expire.test.yml rename to doc/6/controllers/ms/expire/snippets/expire.test.yml diff --git a/doc/src/controllers/ms/expireat/index.md b/doc/6/controllers/ms/expireat/index.md similarity index 100% rename from doc/src/controllers/ms/expireat/index.md rename to doc/6/controllers/ms/expireat/index.md diff --git a/doc/src/controllers/ms/expireat/snippets/expireat.js b/doc/6/controllers/ms/expireat/snippets/expireat.js similarity index 100% rename from doc/src/controllers/ms/expireat/snippets/expireat.js rename to doc/6/controllers/ms/expireat/snippets/expireat.js diff --git a/doc/src/controllers/ms/expireat/snippets/expireat.test.yml b/doc/6/controllers/ms/expireat/snippets/expireat.test.yml similarity index 100% rename from doc/src/controllers/ms/expireat/snippets/expireat.test.yml rename to doc/6/controllers/ms/expireat/snippets/expireat.test.yml diff --git a/doc/src/controllers/ms/flushdb/index.md b/doc/6/controllers/ms/flushdb/index.md similarity index 100% rename from doc/src/controllers/ms/flushdb/index.md rename to doc/6/controllers/ms/flushdb/index.md diff --git a/doc/src/controllers/ms/flushdb/snippets/flushdb.js b/doc/6/controllers/ms/flushdb/snippets/flushdb.js similarity index 100% rename from doc/src/controllers/ms/flushdb/snippets/flushdb.js rename to doc/6/controllers/ms/flushdb/snippets/flushdb.js diff --git a/doc/src/controllers/ms/flushdb/snippets/flushdb.test.yml b/doc/6/controllers/ms/flushdb/snippets/flushdb.test.yml similarity index 100% rename from doc/src/controllers/ms/flushdb/snippets/flushdb.test.yml rename to doc/6/controllers/ms/flushdb/snippets/flushdb.test.yml diff --git a/doc/src/controllers/ms/geoadd/index.md b/doc/6/controllers/ms/geoadd/index.md similarity index 100% rename from doc/src/controllers/ms/geoadd/index.md rename to doc/6/controllers/ms/geoadd/index.md diff --git a/doc/src/controllers/ms/geoadd/snippets/geoadd.js b/doc/6/controllers/ms/geoadd/snippets/geoadd.js similarity index 100% rename from doc/src/controllers/ms/geoadd/snippets/geoadd.js rename to doc/6/controllers/ms/geoadd/snippets/geoadd.js diff --git a/doc/src/controllers/ms/geoadd/snippets/geoadd.test.yml b/doc/6/controllers/ms/geoadd/snippets/geoadd.test.yml similarity index 100% rename from doc/src/controllers/ms/geoadd/snippets/geoadd.test.yml rename to doc/6/controllers/ms/geoadd/snippets/geoadd.test.yml diff --git a/doc/src/controllers/ms/geodist/index.md b/doc/6/controllers/ms/geodist/index.md similarity index 100% rename from doc/src/controllers/ms/geodist/index.md rename to doc/6/controllers/ms/geodist/index.md diff --git a/doc/src/controllers/ms/geodist/snippets/geodist.js b/doc/6/controllers/ms/geodist/snippets/geodist.js similarity index 100% rename from doc/src/controllers/ms/geodist/snippets/geodist.js rename to doc/6/controllers/ms/geodist/snippets/geodist.js diff --git a/doc/src/controllers/ms/geodist/snippets/geodist.test.yml b/doc/6/controllers/ms/geodist/snippets/geodist.test.yml similarity index 100% rename from doc/src/controllers/ms/geodist/snippets/geodist.test.yml rename to doc/6/controllers/ms/geodist/snippets/geodist.test.yml diff --git a/doc/src/controllers/ms/geohash/index.md b/doc/6/controllers/ms/geohash/index.md similarity index 100% rename from doc/src/controllers/ms/geohash/index.md rename to doc/6/controllers/ms/geohash/index.md diff --git a/doc/src/controllers/ms/geohash/snippets/geohash.js b/doc/6/controllers/ms/geohash/snippets/geohash.js similarity index 100% rename from doc/src/controllers/ms/geohash/snippets/geohash.js rename to doc/6/controllers/ms/geohash/snippets/geohash.js diff --git a/doc/src/controllers/ms/geohash/snippets/geohash.test.yml b/doc/6/controllers/ms/geohash/snippets/geohash.test.yml similarity index 100% rename from doc/src/controllers/ms/geohash/snippets/geohash.test.yml rename to doc/6/controllers/ms/geohash/snippets/geohash.test.yml diff --git a/doc/src/controllers/ms/geopos/index.md b/doc/6/controllers/ms/geopos/index.md similarity index 100% rename from doc/src/controllers/ms/geopos/index.md rename to doc/6/controllers/ms/geopos/index.md diff --git a/doc/src/controllers/ms/geopos/snippets/geopos.js b/doc/6/controllers/ms/geopos/snippets/geopos.js similarity index 100% rename from doc/src/controllers/ms/geopos/snippets/geopos.js rename to doc/6/controllers/ms/geopos/snippets/geopos.js diff --git a/doc/src/controllers/ms/geopos/snippets/geopos.test.yml b/doc/6/controllers/ms/geopos/snippets/geopos.test.yml similarity index 100% rename from doc/src/controllers/ms/geopos/snippets/geopos.test.yml rename to doc/6/controllers/ms/geopos/snippets/geopos.test.yml diff --git a/doc/src/controllers/ms/georadius/index.md b/doc/6/controllers/ms/georadius/index.md similarity index 100% rename from doc/src/controllers/ms/georadius/index.md rename to doc/6/controllers/ms/georadius/index.md diff --git a/doc/src/controllers/ms/georadius/snippets/georadius.js b/doc/6/controllers/ms/georadius/snippets/georadius.js similarity index 100% rename from doc/src/controllers/ms/georadius/snippets/georadius.js rename to doc/6/controllers/ms/georadius/snippets/georadius.js diff --git a/doc/src/controllers/ms/georadius/snippets/georadius.test.yml b/doc/6/controllers/ms/georadius/snippets/georadius.test.yml similarity index 100% rename from doc/src/controllers/ms/georadius/snippets/georadius.test.yml rename to doc/6/controllers/ms/georadius/snippets/georadius.test.yml diff --git a/doc/src/controllers/ms/georadiusbymember/index.md b/doc/6/controllers/ms/georadiusbymember/index.md similarity index 100% rename from doc/src/controllers/ms/georadiusbymember/index.md rename to doc/6/controllers/ms/georadiusbymember/index.md diff --git a/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.js b/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.js similarity index 100% rename from doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.js rename to doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.js diff --git a/doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml b/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml similarity index 100% rename from doc/src/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml rename to doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml diff --git a/doc/src/controllers/ms/get/index.md b/doc/6/controllers/ms/get/index.md similarity index 100% rename from doc/src/controllers/ms/get/index.md rename to doc/6/controllers/ms/get/index.md diff --git a/doc/src/controllers/ms/get/snippets/get.js b/doc/6/controllers/ms/get/snippets/get.js similarity index 100% rename from doc/src/controllers/ms/get/snippets/get.js rename to doc/6/controllers/ms/get/snippets/get.js diff --git a/doc/src/controllers/ms/get/snippets/get.test.yml b/doc/6/controllers/ms/get/snippets/get.test.yml similarity index 100% rename from doc/src/controllers/ms/get/snippets/get.test.yml rename to doc/6/controllers/ms/get/snippets/get.test.yml diff --git a/doc/src/controllers/ms/getbit/index.md b/doc/6/controllers/ms/getbit/index.md similarity index 100% rename from doc/src/controllers/ms/getbit/index.md rename to doc/6/controllers/ms/getbit/index.md diff --git a/doc/src/controllers/ms/getbit/snippets/getbit.js b/doc/6/controllers/ms/getbit/snippets/getbit.js similarity index 100% rename from doc/src/controllers/ms/getbit/snippets/getbit.js rename to doc/6/controllers/ms/getbit/snippets/getbit.js diff --git a/doc/src/controllers/ms/getbit/snippets/getbit.test.yml b/doc/6/controllers/ms/getbit/snippets/getbit.test.yml similarity index 100% rename from doc/src/controllers/ms/getbit/snippets/getbit.test.yml rename to doc/6/controllers/ms/getbit/snippets/getbit.test.yml diff --git a/doc/src/controllers/ms/getrange/index.md b/doc/6/controllers/ms/getrange/index.md similarity index 100% rename from doc/src/controllers/ms/getrange/index.md rename to doc/6/controllers/ms/getrange/index.md diff --git a/doc/src/controllers/ms/getrange/snippets/getrange.js b/doc/6/controllers/ms/getrange/snippets/getrange.js similarity index 100% rename from doc/src/controllers/ms/getrange/snippets/getrange.js rename to doc/6/controllers/ms/getrange/snippets/getrange.js diff --git a/doc/src/controllers/ms/getrange/snippets/getrange.test.yml b/doc/6/controllers/ms/getrange/snippets/getrange.test.yml similarity index 100% rename from doc/src/controllers/ms/getrange/snippets/getrange.test.yml rename to doc/6/controllers/ms/getrange/snippets/getrange.test.yml diff --git a/doc/src/controllers/ms/getset/index.md b/doc/6/controllers/ms/getset/index.md similarity index 100% rename from doc/src/controllers/ms/getset/index.md rename to doc/6/controllers/ms/getset/index.md diff --git a/doc/src/controllers/ms/getset/snippets/getset.js b/doc/6/controllers/ms/getset/snippets/getset.js similarity index 100% rename from doc/src/controllers/ms/getset/snippets/getset.js rename to doc/6/controllers/ms/getset/snippets/getset.js diff --git a/doc/src/controllers/ms/getset/snippets/getset.test.yml b/doc/6/controllers/ms/getset/snippets/getset.test.yml similarity index 100% rename from doc/src/controllers/ms/getset/snippets/getset.test.yml rename to doc/6/controllers/ms/getset/snippets/getset.test.yml diff --git a/doc/src/controllers/ms/hdel/index.md b/doc/6/controllers/ms/hdel/index.md similarity index 100% rename from doc/src/controllers/ms/hdel/index.md rename to doc/6/controllers/ms/hdel/index.md diff --git a/doc/src/controllers/ms/hdel/snippets/hdel.js b/doc/6/controllers/ms/hdel/snippets/hdel.js similarity index 100% rename from doc/src/controllers/ms/hdel/snippets/hdel.js rename to doc/6/controllers/ms/hdel/snippets/hdel.js diff --git a/doc/src/controllers/ms/hdel/snippets/hdel.test.yml b/doc/6/controllers/ms/hdel/snippets/hdel.test.yml similarity index 100% rename from doc/src/controllers/ms/hdel/snippets/hdel.test.yml rename to doc/6/controllers/ms/hdel/snippets/hdel.test.yml diff --git a/doc/src/controllers/ms/hexists/index.md b/doc/6/controllers/ms/hexists/index.md similarity index 100% rename from doc/src/controllers/ms/hexists/index.md rename to doc/6/controllers/ms/hexists/index.md diff --git a/doc/src/controllers/ms/hexists/snippets/hexists.js b/doc/6/controllers/ms/hexists/snippets/hexists.js similarity index 100% rename from doc/src/controllers/ms/hexists/snippets/hexists.js rename to doc/6/controllers/ms/hexists/snippets/hexists.js diff --git a/doc/src/controllers/ms/hexists/snippets/hexists.test.yml b/doc/6/controllers/ms/hexists/snippets/hexists.test.yml similarity index 100% rename from doc/src/controllers/ms/hexists/snippets/hexists.test.yml rename to doc/6/controllers/ms/hexists/snippets/hexists.test.yml diff --git a/doc/src/controllers/ms/hget/index.md b/doc/6/controllers/ms/hget/index.md similarity index 100% rename from doc/src/controllers/ms/hget/index.md rename to doc/6/controllers/ms/hget/index.md diff --git a/doc/src/controllers/ms/hget/snippets/hget.js b/doc/6/controllers/ms/hget/snippets/hget.js similarity index 100% rename from doc/src/controllers/ms/hget/snippets/hget.js rename to doc/6/controllers/ms/hget/snippets/hget.js diff --git a/doc/src/controllers/ms/hget/snippets/hget.test.yml b/doc/6/controllers/ms/hget/snippets/hget.test.yml similarity index 100% rename from doc/src/controllers/ms/hget/snippets/hget.test.yml rename to doc/6/controllers/ms/hget/snippets/hget.test.yml diff --git a/doc/src/controllers/ms/hgetall/index.md b/doc/6/controllers/ms/hgetall/index.md similarity index 100% rename from doc/src/controllers/ms/hgetall/index.md rename to doc/6/controllers/ms/hgetall/index.md diff --git a/doc/src/controllers/ms/hgetall/snippets/hgetall.js b/doc/6/controllers/ms/hgetall/snippets/hgetall.js similarity index 100% rename from doc/src/controllers/ms/hgetall/snippets/hgetall.js rename to doc/6/controllers/ms/hgetall/snippets/hgetall.js diff --git a/doc/src/controllers/ms/hgetall/snippets/hgetall.test.yml b/doc/6/controllers/ms/hgetall/snippets/hgetall.test.yml similarity index 100% rename from doc/src/controllers/ms/hgetall/snippets/hgetall.test.yml rename to doc/6/controllers/ms/hgetall/snippets/hgetall.test.yml diff --git a/doc/src/controllers/ms/hincrby/index.md b/doc/6/controllers/ms/hincrby/index.md similarity index 100% rename from doc/src/controllers/ms/hincrby/index.md rename to doc/6/controllers/ms/hincrby/index.md diff --git a/doc/src/controllers/ms/hincrby/snippets/hincrby.js b/doc/6/controllers/ms/hincrby/snippets/hincrby.js similarity index 100% rename from doc/src/controllers/ms/hincrby/snippets/hincrby.js rename to doc/6/controllers/ms/hincrby/snippets/hincrby.js diff --git a/doc/src/controllers/ms/hincrby/snippets/hincrby.test.yml b/doc/6/controllers/ms/hincrby/snippets/hincrby.test.yml similarity index 100% rename from doc/src/controllers/ms/hincrby/snippets/hincrby.test.yml rename to doc/6/controllers/ms/hincrby/snippets/hincrby.test.yml diff --git a/doc/src/controllers/ms/hincrbyfloat/index.md b/doc/6/controllers/ms/hincrbyfloat/index.md similarity index 100% rename from doc/src/controllers/ms/hincrbyfloat/index.md rename to doc/6/controllers/ms/hincrbyfloat/index.md diff --git a/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js b/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js similarity index 100% rename from doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js rename to doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js diff --git a/doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml b/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml similarity index 100% rename from doc/src/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml rename to doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml diff --git a/doc/src/controllers/ms/hkeys/index.md b/doc/6/controllers/ms/hkeys/index.md similarity index 100% rename from doc/src/controllers/ms/hkeys/index.md rename to doc/6/controllers/ms/hkeys/index.md diff --git a/doc/src/controllers/ms/hkeys/snippets/hkeys.js b/doc/6/controllers/ms/hkeys/snippets/hkeys.js similarity index 100% rename from doc/src/controllers/ms/hkeys/snippets/hkeys.js rename to doc/6/controllers/ms/hkeys/snippets/hkeys.js diff --git a/doc/src/controllers/ms/hkeys/snippets/hkeys.test.yml b/doc/6/controllers/ms/hkeys/snippets/hkeys.test.yml similarity index 100% rename from doc/src/controllers/ms/hkeys/snippets/hkeys.test.yml rename to doc/6/controllers/ms/hkeys/snippets/hkeys.test.yml diff --git a/doc/src/controllers/ms/hlen/index.md b/doc/6/controllers/ms/hlen/index.md similarity index 100% rename from doc/src/controllers/ms/hlen/index.md rename to doc/6/controllers/ms/hlen/index.md diff --git a/doc/src/controllers/ms/hlen/snippets/hlen.js b/doc/6/controllers/ms/hlen/snippets/hlen.js similarity index 100% rename from doc/src/controllers/ms/hlen/snippets/hlen.js rename to doc/6/controllers/ms/hlen/snippets/hlen.js diff --git a/doc/src/controllers/ms/hlen/snippets/hlen.test.yml b/doc/6/controllers/ms/hlen/snippets/hlen.test.yml similarity index 100% rename from doc/src/controllers/ms/hlen/snippets/hlen.test.yml rename to doc/6/controllers/ms/hlen/snippets/hlen.test.yml diff --git a/doc/src/controllers/ms/hmget/index.md b/doc/6/controllers/ms/hmget/index.md similarity index 100% rename from doc/src/controllers/ms/hmget/index.md rename to doc/6/controllers/ms/hmget/index.md diff --git a/doc/src/controllers/ms/hmget/snippets/hmget.js b/doc/6/controllers/ms/hmget/snippets/hmget.js similarity index 100% rename from doc/src/controllers/ms/hmget/snippets/hmget.js rename to doc/6/controllers/ms/hmget/snippets/hmget.js diff --git a/doc/src/controllers/ms/hmget/snippets/hmget.test.yml b/doc/6/controllers/ms/hmget/snippets/hmget.test.yml similarity index 100% rename from doc/src/controllers/ms/hmget/snippets/hmget.test.yml rename to doc/6/controllers/ms/hmget/snippets/hmget.test.yml diff --git a/doc/src/controllers/ms/hmset/index.md b/doc/6/controllers/ms/hmset/index.md similarity index 100% rename from doc/src/controllers/ms/hmset/index.md rename to doc/6/controllers/ms/hmset/index.md diff --git a/doc/src/controllers/ms/hmset/snippets/hmset.js b/doc/6/controllers/ms/hmset/snippets/hmset.js similarity index 100% rename from doc/src/controllers/ms/hmset/snippets/hmset.js rename to doc/6/controllers/ms/hmset/snippets/hmset.js diff --git a/doc/src/controllers/ms/hmset/snippets/hmset.test.yml b/doc/6/controllers/ms/hmset/snippets/hmset.test.yml similarity index 100% rename from doc/src/controllers/ms/hmset/snippets/hmset.test.yml rename to doc/6/controllers/ms/hmset/snippets/hmset.test.yml diff --git a/doc/src/controllers/ms/hscan/index.md b/doc/6/controllers/ms/hscan/index.md similarity index 100% rename from doc/src/controllers/ms/hscan/index.md rename to doc/6/controllers/ms/hscan/index.md diff --git a/doc/src/controllers/ms/hscan/snippets/hscan.js b/doc/6/controllers/ms/hscan/snippets/hscan.js similarity index 100% rename from doc/src/controllers/ms/hscan/snippets/hscan.js rename to doc/6/controllers/ms/hscan/snippets/hscan.js diff --git a/doc/src/controllers/ms/hscan/snippets/hscan.test.yml b/doc/6/controllers/ms/hscan/snippets/hscan.test.yml similarity index 100% rename from doc/src/controllers/ms/hscan/snippets/hscan.test.yml rename to doc/6/controllers/ms/hscan/snippets/hscan.test.yml diff --git a/doc/src/controllers/ms/hset/index.md b/doc/6/controllers/ms/hset/index.md similarity index 100% rename from doc/src/controllers/ms/hset/index.md rename to doc/6/controllers/ms/hset/index.md diff --git a/doc/src/controllers/ms/hset/snippets/hset.js b/doc/6/controllers/ms/hset/snippets/hset.js similarity index 100% rename from doc/src/controllers/ms/hset/snippets/hset.js rename to doc/6/controllers/ms/hset/snippets/hset.js diff --git a/doc/src/controllers/ms/hset/snippets/hset.test.yml b/doc/6/controllers/ms/hset/snippets/hset.test.yml similarity index 100% rename from doc/src/controllers/ms/hset/snippets/hset.test.yml rename to doc/6/controllers/ms/hset/snippets/hset.test.yml diff --git a/doc/src/controllers/ms/hsetnx/index.md b/doc/6/controllers/ms/hsetnx/index.md similarity index 100% rename from doc/src/controllers/ms/hsetnx/index.md rename to doc/6/controllers/ms/hsetnx/index.md diff --git a/doc/src/controllers/ms/hsetnx/snippets/hsetnx.js b/doc/6/controllers/ms/hsetnx/snippets/hsetnx.js similarity index 100% rename from doc/src/controllers/ms/hsetnx/snippets/hsetnx.js rename to doc/6/controllers/ms/hsetnx/snippets/hsetnx.js diff --git a/doc/src/controllers/ms/hsetnx/snippets/hsetnx.test.yml b/doc/6/controllers/ms/hsetnx/snippets/hsetnx.test.yml similarity index 100% rename from doc/src/controllers/ms/hsetnx/snippets/hsetnx.test.yml rename to doc/6/controllers/ms/hsetnx/snippets/hsetnx.test.yml diff --git a/doc/src/controllers/ms/hstrlen/index.md b/doc/6/controllers/ms/hstrlen/index.md similarity index 100% rename from doc/src/controllers/ms/hstrlen/index.md rename to doc/6/controllers/ms/hstrlen/index.md diff --git a/doc/src/controllers/ms/hstrlen/snippets/hstrlen.js b/doc/6/controllers/ms/hstrlen/snippets/hstrlen.js similarity index 100% rename from doc/src/controllers/ms/hstrlen/snippets/hstrlen.js rename to doc/6/controllers/ms/hstrlen/snippets/hstrlen.js diff --git a/doc/src/controllers/ms/hstrlen/snippets/hstrlen.test.yml b/doc/6/controllers/ms/hstrlen/snippets/hstrlen.test.yml similarity index 100% rename from doc/src/controllers/ms/hstrlen/snippets/hstrlen.test.yml rename to doc/6/controllers/ms/hstrlen/snippets/hstrlen.test.yml diff --git a/doc/src/controllers/ms/hvals/index.md b/doc/6/controllers/ms/hvals/index.md similarity index 100% rename from doc/src/controllers/ms/hvals/index.md rename to doc/6/controllers/ms/hvals/index.md diff --git a/doc/src/controllers/ms/hvals/snippets/hvals.js b/doc/6/controllers/ms/hvals/snippets/hvals.js similarity index 100% rename from doc/src/controllers/ms/hvals/snippets/hvals.js rename to doc/6/controllers/ms/hvals/snippets/hvals.js diff --git a/doc/src/controllers/ms/hvals/snippets/hvals.test.yml b/doc/6/controllers/ms/hvals/snippets/hvals.test.yml similarity index 100% rename from doc/src/controllers/ms/hvals/snippets/hvals.test.yml rename to doc/6/controllers/ms/hvals/snippets/hvals.test.yml diff --git a/doc/src/controllers/ms/incr/index.md b/doc/6/controllers/ms/incr/index.md similarity index 100% rename from doc/src/controllers/ms/incr/index.md rename to doc/6/controllers/ms/incr/index.md diff --git a/doc/src/controllers/ms/incr/snippets/incr.js b/doc/6/controllers/ms/incr/snippets/incr.js similarity index 100% rename from doc/src/controllers/ms/incr/snippets/incr.js rename to doc/6/controllers/ms/incr/snippets/incr.js diff --git a/doc/src/controllers/ms/incr/snippets/incr.test.yml b/doc/6/controllers/ms/incr/snippets/incr.test.yml similarity index 100% rename from doc/src/controllers/ms/incr/snippets/incr.test.yml rename to doc/6/controllers/ms/incr/snippets/incr.test.yml diff --git a/doc/src/controllers/ms/incrby/index.md b/doc/6/controllers/ms/incrby/index.md similarity index 100% rename from doc/src/controllers/ms/incrby/index.md rename to doc/6/controllers/ms/incrby/index.md diff --git a/doc/src/controllers/ms/incrby/snippets/incrby.js b/doc/6/controllers/ms/incrby/snippets/incrby.js similarity index 100% rename from doc/src/controllers/ms/incrby/snippets/incrby.js rename to doc/6/controllers/ms/incrby/snippets/incrby.js diff --git a/doc/src/controllers/ms/incrby/snippets/incrby.test.yml b/doc/6/controllers/ms/incrby/snippets/incrby.test.yml similarity index 100% rename from doc/src/controllers/ms/incrby/snippets/incrby.test.yml rename to doc/6/controllers/ms/incrby/snippets/incrby.test.yml diff --git a/doc/src/controllers/ms/incrbyfloat/index.md b/doc/6/controllers/ms/incrbyfloat/index.md similarity index 100% rename from doc/src/controllers/ms/incrbyfloat/index.md rename to doc/6/controllers/ms/incrbyfloat/index.md diff --git a/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.js b/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.js similarity index 100% rename from doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.js rename to doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.js diff --git a/doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml b/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml similarity index 100% rename from doc/src/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml rename to doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml diff --git a/doc/src/controllers/ms/index.md b/doc/6/controllers/ms/index.md similarity index 100% rename from doc/src/controllers/ms/index.md rename to doc/6/controllers/ms/index.md diff --git a/doc/src/controllers/ms/keys/index.md b/doc/6/controllers/ms/keys/index.md similarity index 100% rename from doc/src/controllers/ms/keys/index.md rename to doc/6/controllers/ms/keys/index.md diff --git a/doc/src/controllers/ms/keys/snippets/keys.js b/doc/6/controllers/ms/keys/snippets/keys.js similarity index 100% rename from doc/src/controllers/ms/keys/snippets/keys.js rename to doc/6/controllers/ms/keys/snippets/keys.js diff --git a/doc/src/controllers/ms/keys/snippets/keys.test.yml b/doc/6/controllers/ms/keys/snippets/keys.test.yml similarity index 100% rename from doc/src/controllers/ms/keys/snippets/keys.test.yml rename to doc/6/controllers/ms/keys/snippets/keys.test.yml diff --git a/doc/src/controllers/ms/lindex/index.md b/doc/6/controllers/ms/lindex/index.md similarity index 100% rename from doc/src/controllers/ms/lindex/index.md rename to doc/6/controllers/ms/lindex/index.md diff --git a/doc/src/controllers/ms/lindex/snippets/lindex.js b/doc/6/controllers/ms/lindex/snippets/lindex.js similarity index 100% rename from doc/src/controllers/ms/lindex/snippets/lindex.js rename to doc/6/controllers/ms/lindex/snippets/lindex.js diff --git a/doc/src/controllers/ms/lindex/snippets/lindex.test.yml b/doc/6/controllers/ms/lindex/snippets/lindex.test.yml similarity index 100% rename from doc/src/controllers/ms/lindex/snippets/lindex.test.yml rename to doc/6/controllers/ms/lindex/snippets/lindex.test.yml diff --git a/doc/src/controllers/ms/linsert/index.md b/doc/6/controllers/ms/linsert/index.md similarity index 100% rename from doc/src/controllers/ms/linsert/index.md rename to doc/6/controllers/ms/linsert/index.md diff --git a/doc/src/controllers/ms/linsert/snippets/linsert.js b/doc/6/controllers/ms/linsert/snippets/linsert.js similarity index 100% rename from doc/src/controllers/ms/linsert/snippets/linsert.js rename to doc/6/controllers/ms/linsert/snippets/linsert.js diff --git a/doc/src/controllers/ms/linsert/snippets/linsert.test.yml b/doc/6/controllers/ms/linsert/snippets/linsert.test.yml similarity index 100% rename from doc/src/controllers/ms/linsert/snippets/linsert.test.yml rename to doc/6/controllers/ms/linsert/snippets/linsert.test.yml diff --git a/doc/src/controllers/ms/llen/index.md b/doc/6/controllers/ms/llen/index.md similarity index 100% rename from doc/src/controllers/ms/llen/index.md rename to doc/6/controllers/ms/llen/index.md diff --git a/doc/src/controllers/ms/llen/snippets/llen.js b/doc/6/controllers/ms/llen/snippets/llen.js similarity index 100% rename from doc/src/controllers/ms/llen/snippets/llen.js rename to doc/6/controllers/ms/llen/snippets/llen.js diff --git a/doc/src/controllers/ms/llen/snippets/llen.test.yml b/doc/6/controllers/ms/llen/snippets/llen.test.yml similarity index 100% rename from doc/src/controllers/ms/llen/snippets/llen.test.yml rename to doc/6/controllers/ms/llen/snippets/llen.test.yml diff --git a/doc/src/controllers/ms/lpop/index.md b/doc/6/controllers/ms/lpop/index.md similarity index 100% rename from doc/src/controllers/ms/lpop/index.md rename to doc/6/controllers/ms/lpop/index.md diff --git a/doc/src/controllers/ms/lpop/snippets/lpop.js b/doc/6/controllers/ms/lpop/snippets/lpop.js similarity index 100% rename from doc/src/controllers/ms/lpop/snippets/lpop.js rename to doc/6/controllers/ms/lpop/snippets/lpop.js diff --git a/doc/src/controllers/ms/lpop/snippets/lpop.test.yml b/doc/6/controllers/ms/lpop/snippets/lpop.test.yml similarity index 100% rename from doc/src/controllers/ms/lpop/snippets/lpop.test.yml rename to doc/6/controllers/ms/lpop/snippets/lpop.test.yml diff --git a/doc/src/controllers/ms/lpush/index.md b/doc/6/controllers/ms/lpush/index.md similarity index 100% rename from doc/src/controllers/ms/lpush/index.md rename to doc/6/controllers/ms/lpush/index.md diff --git a/doc/src/controllers/ms/lpush/snippets/lpush.js b/doc/6/controllers/ms/lpush/snippets/lpush.js similarity index 100% rename from doc/src/controllers/ms/lpush/snippets/lpush.js rename to doc/6/controllers/ms/lpush/snippets/lpush.js diff --git a/doc/src/controllers/ms/lpush/snippets/lpush.test.yml b/doc/6/controllers/ms/lpush/snippets/lpush.test.yml similarity index 100% rename from doc/src/controllers/ms/lpush/snippets/lpush.test.yml rename to doc/6/controllers/ms/lpush/snippets/lpush.test.yml diff --git a/doc/src/controllers/ms/lpushx/index.md b/doc/6/controllers/ms/lpushx/index.md similarity index 100% rename from doc/src/controllers/ms/lpushx/index.md rename to doc/6/controllers/ms/lpushx/index.md diff --git a/doc/src/controllers/ms/lpushx/snippets/lpushx.js b/doc/6/controllers/ms/lpushx/snippets/lpushx.js similarity index 100% rename from doc/src/controllers/ms/lpushx/snippets/lpushx.js rename to doc/6/controllers/ms/lpushx/snippets/lpushx.js diff --git a/doc/src/controllers/ms/lpushx/snippets/lpushx.test.yml b/doc/6/controllers/ms/lpushx/snippets/lpushx.test.yml similarity index 100% rename from doc/src/controllers/ms/lpushx/snippets/lpushx.test.yml rename to doc/6/controllers/ms/lpushx/snippets/lpushx.test.yml diff --git a/doc/src/controllers/ms/lrange/index.md b/doc/6/controllers/ms/lrange/index.md similarity index 100% rename from doc/src/controllers/ms/lrange/index.md rename to doc/6/controllers/ms/lrange/index.md diff --git a/doc/src/controllers/ms/lrange/snippets/lrange.js b/doc/6/controllers/ms/lrange/snippets/lrange.js similarity index 100% rename from doc/src/controllers/ms/lrange/snippets/lrange.js rename to doc/6/controllers/ms/lrange/snippets/lrange.js diff --git a/doc/src/controllers/ms/lrange/snippets/lrange.test.yml b/doc/6/controllers/ms/lrange/snippets/lrange.test.yml similarity index 100% rename from doc/src/controllers/ms/lrange/snippets/lrange.test.yml rename to doc/6/controllers/ms/lrange/snippets/lrange.test.yml diff --git a/doc/src/controllers/ms/lrem/index.md b/doc/6/controllers/ms/lrem/index.md similarity index 100% rename from doc/src/controllers/ms/lrem/index.md rename to doc/6/controllers/ms/lrem/index.md diff --git a/doc/src/controllers/ms/lrem/snippets/lrem.js b/doc/6/controllers/ms/lrem/snippets/lrem.js similarity index 100% rename from doc/src/controllers/ms/lrem/snippets/lrem.js rename to doc/6/controllers/ms/lrem/snippets/lrem.js diff --git a/doc/src/controllers/ms/lrem/snippets/lrem.test.yml b/doc/6/controllers/ms/lrem/snippets/lrem.test.yml similarity index 100% rename from doc/src/controllers/ms/lrem/snippets/lrem.test.yml rename to doc/6/controllers/ms/lrem/snippets/lrem.test.yml diff --git a/doc/src/controllers/ms/lset/index.md b/doc/6/controllers/ms/lset/index.md similarity index 100% rename from doc/src/controllers/ms/lset/index.md rename to doc/6/controllers/ms/lset/index.md diff --git a/doc/src/controllers/ms/lset/snippets/lset.js b/doc/6/controllers/ms/lset/snippets/lset.js similarity index 100% rename from doc/src/controllers/ms/lset/snippets/lset.js rename to doc/6/controllers/ms/lset/snippets/lset.js diff --git a/doc/src/controllers/ms/lset/snippets/lset.test.yml b/doc/6/controllers/ms/lset/snippets/lset.test.yml similarity index 100% rename from doc/src/controllers/ms/lset/snippets/lset.test.yml rename to doc/6/controllers/ms/lset/snippets/lset.test.yml diff --git a/doc/src/controllers/ms/ltrim/index.md b/doc/6/controllers/ms/ltrim/index.md similarity index 100% rename from doc/src/controllers/ms/ltrim/index.md rename to doc/6/controllers/ms/ltrim/index.md diff --git a/doc/src/controllers/ms/ltrim/snippets/ltrim.js b/doc/6/controllers/ms/ltrim/snippets/ltrim.js similarity index 100% rename from doc/src/controllers/ms/ltrim/snippets/ltrim.js rename to doc/6/controllers/ms/ltrim/snippets/ltrim.js diff --git a/doc/src/controllers/ms/ltrim/snippets/ltrim.test.yml b/doc/6/controllers/ms/ltrim/snippets/ltrim.test.yml similarity index 100% rename from doc/src/controllers/ms/ltrim/snippets/ltrim.test.yml rename to doc/6/controllers/ms/ltrim/snippets/ltrim.test.yml diff --git a/doc/src/controllers/ms/mget/index.md b/doc/6/controllers/ms/mget/index.md similarity index 100% rename from doc/src/controllers/ms/mget/index.md rename to doc/6/controllers/ms/mget/index.md diff --git a/doc/src/controllers/ms/mget/snippets/mget.js b/doc/6/controllers/ms/mget/snippets/mget.js similarity index 100% rename from doc/src/controllers/ms/mget/snippets/mget.js rename to doc/6/controllers/ms/mget/snippets/mget.js diff --git a/doc/src/controllers/ms/mget/snippets/mget.test.yml b/doc/6/controllers/ms/mget/snippets/mget.test.yml similarity index 100% rename from doc/src/controllers/ms/mget/snippets/mget.test.yml rename to doc/6/controllers/ms/mget/snippets/mget.test.yml diff --git a/doc/src/controllers/ms/mset/index.md b/doc/6/controllers/ms/mset/index.md similarity index 100% rename from doc/src/controllers/ms/mset/index.md rename to doc/6/controllers/ms/mset/index.md diff --git a/doc/src/controllers/ms/mset/snippets/mset.js b/doc/6/controllers/ms/mset/snippets/mset.js similarity index 100% rename from doc/src/controllers/ms/mset/snippets/mset.js rename to doc/6/controllers/ms/mset/snippets/mset.js diff --git a/doc/src/controllers/ms/mset/snippets/mset.test.yml b/doc/6/controllers/ms/mset/snippets/mset.test.yml similarity index 100% rename from doc/src/controllers/ms/mset/snippets/mset.test.yml rename to doc/6/controllers/ms/mset/snippets/mset.test.yml diff --git a/doc/src/controllers/ms/msetnx/index.md b/doc/6/controllers/ms/msetnx/index.md similarity index 100% rename from doc/src/controllers/ms/msetnx/index.md rename to doc/6/controllers/ms/msetnx/index.md diff --git a/doc/src/controllers/ms/msetnx/snippets/msetnx.js b/doc/6/controllers/ms/msetnx/snippets/msetnx.js similarity index 100% rename from doc/src/controllers/ms/msetnx/snippets/msetnx.js rename to doc/6/controllers/ms/msetnx/snippets/msetnx.js diff --git a/doc/src/controllers/ms/msetnx/snippets/msetnx.test.yml b/doc/6/controllers/ms/msetnx/snippets/msetnx.test.yml similarity index 100% rename from doc/src/controllers/ms/msetnx/snippets/msetnx.test.yml rename to doc/6/controllers/ms/msetnx/snippets/msetnx.test.yml diff --git a/doc/src/controllers/ms/object/index.md b/doc/6/controllers/ms/object/index.md similarity index 100% rename from doc/src/controllers/ms/object/index.md rename to doc/6/controllers/ms/object/index.md diff --git a/doc/src/controllers/ms/object/snippets/object.js b/doc/6/controllers/ms/object/snippets/object.js similarity index 100% rename from doc/src/controllers/ms/object/snippets/object.js rename to doc/6/controllers/ms/object/snippets/object.js diff --git a/doc/src/controllers/ms/object/snippets/object.test.yml b/doc/6/controllers/ms/object/snippets/object.test.yml similarity index 100% rename from doc/src/controllers/ms/object/snippets/object.test.yml rename to doc/6/controllers/ms/object/snippets/object.test.yml diff --git a/doc/src/controllers/ms/persist/index.md b/doc/6/controllers/ms/persist/index.md similarity index 100% rename from doc/src/controllers/ms/persist/index.md rename to doc/6/controllers/ms/persist/index.md diff --git a/doc/src/controllers/ms/persist/snippets/persist.js b/doc/6/controllers/ms/persist/snippets/persist.js similarity index 100% rename from doc/src/controllers/ms/persist/snippets/persist.js rename to doc/6/controllers/ms/persist/snippets/persist.js diff --git a/doc/src/controllers/ms/persist/snippets/persist.test.yml b/doc/6/controllers/ms/persist/snippets/persist.test.yml similarity index 100% rename from doc/src/controllers/ms/persist/snippets/persist.test.yml rename to doc/6/controllers/ms/persist/snippets/persist.test.yml diff --git a/doc/src/controllers/ms/pexpire/index.md b/doc/6/controllers/ms/pexpire/index.md similarity index 100% rename from doc/src/controllers/ms/pexpire/index.md rename to doc/6/controllers/ms/pexpire/index.md diff --git a/doc/src/controllers/ms/pexpire/snippets/pexpire.js b/doc/6/controllers/ms/pexpire/snippets/pexpire.js similarity index 100% rename from doc/src/controllers/ms/pexpire/snippets/pexpire.js rename to doc/6/controllers/ms/pexpire/snippets/pexpire.js diff --git a/doc/src/controllers/ms/pexpire/snippets/pexpire.test.yml b/doc/6/controllers/ms/pexpire/snippets/pexpire.test.yml similarity index 100% rename from doc/src/controllers/ms/pexpire/snippets/pexpire.test.yml rename to doc/6/controllers/ms/pexpire/snippets/pexpire.test.yml diff --git a/doc/src/controllers/ms/pexpireat/index.md b/doc/6/controllers/ms/pexpireat/index.md similarity index 100% rename from doc/src/controllers/ms/pexpireat/index.md rename to doc/6/controllers/ms/pexpireat/index.md diff --git a/doc/src/controllers/ms/pexpireat/snippets/pexpireat.js b/doc/6/controllers/ms/pexpireat/snippets/pexpireat.js similarity index 100% rename from doc/src/controllers/ms/pexpireat/snippets/pexpireat.js rename to doc/6/controllers/ms/pexpireat/snippets/pexpireat.js diff --git a/doc/src/controllers/ms/pexpireat/snippets/pexpireat.test.yml b/doc/6/controllers/ms/pexpireat/snippets/pexpireat.test.yml similarity index 100% rename from doc/src/controllers/ms/pexpireat/snippets/pexpireat.test.yml rename to doc/6/controllers/ms/pexpireat/snippets/pexpireat.test.yml diff --git a/doc/src/controllers/ms/pfadd/index.md b/doc/6/controllers/ms/pfadd/index.md similarity index 100% rename from doc/src/controllers/ms/pfadd/index.md rename to doc/6/controllers/ms/pfadd/index.md diff --git a/doc/src/controllers/ms/pfadd/snippets/pfadd.js b/doc/6/controllers/ms/pfadd/snippets/pfadd.js similarity index 100% rename from doc/src/controllers/ms/pfadd/snippets/pfadd.js rename to doc/6/controllers/ms/pfadd/snippets/pfadd.js diff --git a/doc/src/controllers/ms/pfadd/snippets/pfadd.test.yml b/doc/6/controllers/ms/pfadd/snippets/pfadd.test.yml similarity index 100% rename from doc/src/controllers/ms/pfadd/snippets/pfadd.test.yml rename to doc/6/controllers/ms/pfadd/snippets/pfadd.test.yml diff --git a/doc/src/controllers/ms/pfcount/index.md b/doc/6/controllers/ms/pfcount/index.md similarity index 100% rename from doc/src/controllers/ms/pfcount/index.md rename to doc/6/controllers/ms/pfcount/index.md diff --git a/doc/src/controllers/ms/pfcount/snippets/pfcount.js b/doc/6/controllers/ms/pfcount/snippets/pfcount.js similarity index 100% rename from doc/src/controllers/ms/pfcount/snippets/pfcount.js rename to doc/6/controllers/ms/pfcount/snippets/pfcount.js diff --git a/doc/src/controllers/ms/pfcount/snippets/pfcount.test.yml b/doc/6/controllers/ms/pfcount/snippets/pfcount.test.yml similarity index 100% rename from doc/src/controllers/ms/pfcount/snippets/pfcount.test.yml rename to doc/6/controllers/ms/pfcount/snippets/pfcount.test.yml diff --git a/doc/src/controllers/ms/pfmerge/index.md b/doc/6/controllers/ms/pfmerge/index.md similarity index 100% rename from doc/src/controllers/ms/pfmerge/index.md rename to doc/6/controllers/ms/pfmerge/index.md diff --git a/doc/src/controllers/ms/pfmerge/snippets/pfmerge.js b/doc/6/controllers/ms/pfmerge/snippets/pfmerge.js similarity index 100% rename from doc/src/controllers/ms/pfmerge/snippets/pfmerge.js rename to doc/6/controllers/ms/pfmerge/snippets/pfmerge.js diff --git a/doc/src/controllers/ms/pfmerge/snippets/pfmerge.test.yml b/doc/6/controllers/ms/pfmerge/snippets/pfmerge.test.yml similarity index 100% rename from doc/src/controllers/ms/pfmerge/snippets/pfmerge.test.yml rename to doc/6/controllers/ms/pfmerge/snippets/pfmerge.test.yml diff --git a/doc/src/controllers/ms/ping/index.md b/doc/6/controllers/ms/ping/index.md similarity index 100% rename from doc/src/controllers/ms/ping/index.md rename to doc/6/controllers/ms/ping/index.md diff --git a/doc/src/controllers/ms/ping/snippets/ping.js b/doc/6/controllers/ms/ping/snippets/ping.js similarity index 100% rename from doc/src/controllers/ms/ping/snippets/ping.js rename to doc/6/controllers/ms/ping/snippets/ping.js diff --git a/doc/src/controllers/ms/ping/snippets/ping.test.yml b/doc/6/controllers/ms/ping/snippets/ping.test.yml similarity index 100% rename from doc/src/controllers/ms/ping/snippets/ping.test.yml rename to doc/6/controllers/ms/ping/snippets/ping.test.yml diff --git a/doc/src/controllers/ms/psetex/index.md b/doc/6/controllers/ms/psetex/index.md similarity index 100% rename from doc/src/controllers/ms/psetex/index.md rename to doc/6/controllers/ms/psetex/index.md diff --git a/doc/src/controllers/ms/psetex/snippets/psetex.js b/doc/6/controllers/ms/psetex/snippets/psetex.js similarity index 100% rename from doc/src/controllers/ms/psetex/snippets/psetex.js rename to doc/6/controllers/ms/psetex/snippets/psetex.js diff --git a/doc/src/controllers/ms/psetex/snippets/psetex.test.yml b/doc/6/controllers/ms/psetex/snippets/psetex.test.yml similarity index 100% rename from doc/src/controllers/ms/psetex/snippets/psetex.test.yml rename to doc/6/controllers/ms/psetex/snippets/psetex.test.yml diff --git a/doc/src/controllers/ms/pttl/index.md b/doc/6/controllers/ms/pttl/index.md similarity index 100% rename from doc/src/controllers/ms/pttl/index.md rename to doc/6/controllers/ms/pttl/index.md diff --git a/doc/src/controllers/ms/pttl/snippets/pttl.js b/doc/6/controllers/ms/pttl/snippets/pttl.js similarity index 100% rename from doc/src/controllers/ms/pttl/snippets/pttl.js rename to doc/6/controllers/ms/pttl/snippets/pttl.js diff --git a/doc/src/controllers/ms/pttl/snippets/pttl.test.yml b/doc/6/controllers/ms/pttl/snippets/pttl.test.yml similarity index 100% rename from doc/src/controllers/ms/pttl/snippets/pttl.test.yml rename to doc/6/controllers/ms/pttl/snippets/pttl.test.yml diff --git a/doc/src/controllers/ms/randomkey/index.md b/doc/6/controllers/ms/randomkey/index.md similarity index 100% rename from doc/src/controllers/ms/randomkey/index.md rename to doc/6/controllers/ms/randomkey/index.md diff --git a/doc/src/controllers/ms/randomkey/snippets/randomkey.js b/doc/6/controllers/ms/randomkey/snippets/randomkey.js similarity index 100% rename from doc/src/controllers/ms/randomkey/snippets/randomkey.js rename to doc/6/controllers/ms/randomkey/snippets/randomkey.js diff --git a/doc/src/controllers/ms/randomkey/snippets/randomkey.test.yml b/doc/6/controllers/ms/randomkey/snippets/randomkey.test.yml similarity index 100% rename from doc/src/controllers/ms/randomkey/snippets/randomkey.test.yml rename to doc/6/controllers/ms/randomkey/snippets/randomkey.test.yml diff --git a/doc/src/controllers/ms/rename/index.md b/doc/6/controllers/ms/rename/index.md similarity index 100% rename from doc/src/controllers/ms/rename/index.md rename to doc/6/controllers/ms/rename/index.md diff --git a/doc/src/controllers/ms/rename/snippets/rename.js b/doc/6/controllers/ms/rename/snippets/rename.js similarity index 100% rename from doc/src/controllers/ms/rename/snippets/rename.js rename to doc/6/controllers/ms/rename/snippets/rename.js diff --git a/doc/src/controllers/ms/rename/snippets/rename.test.yml b/doc/6/controllers/ms/rename/snippets/rename.test.yml similarity index 100% rename from doc/src/controllers/ms/rename/snippets/rename.test.yml rename to doc/6/controllers/ms/rename/snippets/rename.test.yml diff --git a/doc/src/controllers/ms/renamenx/index.md b/doc/6/controllers/ms/renamenx/index.md similarity index 100% rename from doc/src/controllers/ms/renamenx/index.md rename to doc/6/controllers/ms/renamenx/index.md diff --git a/doc/src/controllers/ms/renamenx/snippets/renamenx.js b/doc/6/controllers/ms/renamenx/snippets/renamenx.js similarity index 100% rename from doc/src/controllers/ms/renamenx/snippets/renamenx.js rename to doc/6/controllers/ms/renamenx/snippets/renamenx.js diff --git a/doc/src/controllers/ms/renamenx/snippets/renamenx.test.yml b/doc/6/controllers/ms/renamenx/snippets/renamenx.test.yml similarity index 100% rename from doc/src/controllers/ms/renamenx/snippets/renamenx.test.yml rename to doc/6/controllers/ms/renamenx/snippets/renamenx.test.yml diff --git a/doc/src/controllers/ms/rpop/index.md b/doc/6/controllers/ms/rpop/index.md similarity index 100% rename from doc/src/controllers/ms/rpop/index.md rename to doc/6/controllers/ms/rpop/index.md diff --git a/doc/src/controllers/ms/rpop/snippets/rpop.js b/doc/6/controllers/ms/rpop/snippets/rpop.js similarity index 100% rename from doc/src/controllers/ms/rpop/snippets/rpop.js rename to doc/6/controllers/ms/rpop/snippets/rpop.js diff --git a/doc/src/controllers/ms/rpop/snippets/rpop.test.yml b/doc/6/controllers/ms/rpop/snippets/rpop.test.yml similarity index 100% rename from doc/src/controllers/ms/rpop/snippets/rpop.test.yml rename to doc/6/controllers/ms/rpop/snippets/rpop.test.yml diff --git a/doc/src/controllers/ms/rpoplpush/index.md b/doc/6/controllers/ms/rpoplpush/index.md similarity index 100% rename from doc/src/controllers/ms/rpoplpush/index.md rename to doc/6/controllers/ms/rpoplpush/index.md diff --git a/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.js b/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.js similarity index 100% rename from doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.js rename to doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.js diff --git a/doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml b/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml similarity index 100% rename from doc/src/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml rename to doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml diff --git a/doc/src/controllers/ms/rpush/index.md b/doc/6/controllers/ms/rpush/index.md similarity index 100% rename from doc/src/controllers/ms/rpush/index.md rename to doc/6/controllers/ms/rpush/index.md diff --git a/doc/src/controllers/ms/rpush/snippets/rpush.js b/doc/6/controllers/ms/rpush/snippets/rpush.js similarity index 100% rename from doc/src/controllers/ms/rpush/snippets/rpush.js rename to doc/6/controllers/ms/rpush/snippets/rpush.js diff --git a/doc/src/controllers/ms/rpush/snippets/rpush.test.yml b/doc/6/controllers/ms/rpush/snippets/rpush.test.yml similarity index 100% rename from doc/src/controllers/ms/rpush/snippets/rpush.test.yml rename to doc/6/controllers/ms/rpush/snippets/rpush.test.yml diff --git a/doc/src/controllers/ms/rpushx/index.md b/doc/6/controllers/ms/rpushx/index.md similarity index 100% rename from doc/src/controllers/ms/rpushx/index.md rename to doc/6/controllers/ms/rpushx/index.md diff --git a/doc/src/controllers/ms/rpushx/snippets/rpushx.js b/doc/6/controllers/ms/rpushx/snippets/rpushx.js similarity index 100% rename from doc/src/controllers/ms/rpushx/snippets/rpushx.js rename to doc/6/controllers/ms/rpushx/snippets/rpushx.js diff --git a/doc/src/controllers/ms/rpushx/snippets/rpushx.test.yml b/doc/6/controllers/ms/rpushx/snippets/rpushx.test.yml similarity index 100% rename from doc/src/controllers/ms/rpushx/snippets/rpushx.test.yml rename to doc/6/controllers/ms/rpushx/snippets/rpushx.test.yml diff --git a/doc/src/controllers/ms/sadd/index.md b/doc/6/controllers/ms/sadd/index.md similarity index 100% rename from doc/src/controllers/ms/sadd/index.md rename to doc/6/controllers/ms/sadd/index.md diff --git a/doc/src/controllers/ms/sadd/snippets/sadd.js b/doc/6/controllers/ms/sadd/snippets/sadd.js similarity index 100% rename from doc/src/controllers/ms/sadd/snippets/sadd.js rename to doc/6/controllers/ms/sadd/snippets/sadd.js diff --git a/doc/src/controllers/ms/sadd/snippets/sadd.test.yml b/doc/6/controllers/ms/sadd/snippets/sadd.test.yml similarity index 100% rename from doc/src/controllers/ms/sadd/snippets/sadd.test.yml rename to doc/6/controllers/ms/sadd/snippets/sadd.test.yml diff --git a/doc/src/controllers/ms/scan/index.md b/doc/6/controllers/ms/scan/index.md similarity index 100% rename from doc/src/controllers/ms/scan/index.md rename to doc/6/controllers/ms/scan/index.md diff --git a/doc/src/controllers/ms/scan/snippets/scan.js b/doc/6/controllers/ms/scan/snippets/scan.js similarity index 100% rename from doc/src/controllers/ms/scan/snippets/scan.js rename to doc/6/controllers/ms/scan/snippets/scan.js diff --git a/doc/src/controllers/ms/scan/snippets/scan.test.yml b/doc/6/controllers/ms/scan/snippets/scan.test.yml similarity index 100% rename from doc/src/controllers/ms/scan/snippets/scan.test.yml rename to doc/6/controllers/ms/scan/snippets/scan.test.yml diff --git a/doc/src/controllers/ms/scard/index.md b/doc/6/controllers/ms/scard/index.md similarity index 100% rename from doc/src/controllers/ms/scard/index.md rename to doc/6/controllers/ms/scard/index.md diff --git a/doc/src/controllers/ms/scard/snippets/scard.js b/doc/6/controllers/ms/scard/snippets/scard.js similarity index 100% rename from doc/src/controllers/ms/scard/snippets/scard.js rename to doc/6/controllers/ms/scard/snippets/scard.js diff --git a/doc/src/controllers/ms/scard/snippets/scard.test.yml b/doc/6/controllers/ms/scard/snippets/scard.test.yml similarity index 100% rename from doc/src/controllers/ms/scard/snippets/scard.test.yml rename to doc/6/controllers/ms/scard/snippets/scard.test.yml diff --git a/doc/src/controllers/ms/sdiff/index.md b/doc/6/controllers/ms/sdiff/index.md similarity index 100% rename from doc/src/controllers/ms/sdiff/index.md rename to doc/6/controllers/ms/sdiff/index.md diff --git a/doc/src/controllers/ms/sdiff/snippets/sdiff.js b/doc/6/controllers/ms/sdiff/snippets/sdiff.js similarity index 100% rename from doc/src/controllers/ms/sdiff/snippets/sdiff.js rename to doc/6/controllers/ms/sdiff/snippets/sdiff.js diff --git a/doc/src/controllers/ms/sdiff/snippets/sdiff.test.yml b/doc/6/controllers/ms/sdiff/snippets/sdiff.test.yml similarity index 100% rename from doc/src/controllers/ms/sdiff/snippets/sdiff.test.yml rename to doc/6/controllers/ms/sdiff/snippets/sdiff.test.yml diff --git a/doc/src/controllers/ms/sdiffstore/index.md b/doc/6/controllers/ms/sdiffstore/index.md similarity index 100% rename from doc/src/controllers/ms/sdiffstore/index.md rename to doc/6/controllers/ms/sdiffstore/index.md diff --git a/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.js b/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.js similarity index 100% rename from doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.js rename to doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.js diff --git a/doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml b/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml similarity index 100% rename from doc/src/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml rename to doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml diff --git a/doc/src/controllers/ms/set/index.md b/doc/6/controllers/ms/set/index.md similarity index 100% rename from doc/src/controllers/ms/set/index.md rename to doc/6/controllers/ms/set/index.md diff --git a/doc/src/controllers/ms/set/snippets/set.js b/doc/6/controllers/ms/set/snippets/set.js similarity index 100% rename from doc/src/controllers/ms/set/snippets/set.js rename to doc/6/controllers/ms/set/snippets/set.js diff --git a/doc/src/controllers/ms/set/snippets/set.test.yml b/doc/6/controllers/ms/set/snippets/set.test.yml similarity index 100% rename from doc/src/controllers/ms/set/snippets/set.test.yml rename to doc/6/controllers/ms/set/snippets/set.test.yml diff --git a/doc/src/controllers/ms/setex/index.md b/doc/6/controllers/ms/setex/index.md similarity index 100% rename from doc/src/controllers/ms/setex/index.md rename to doc/6/controllers/ms/setex/index.md diff --git a/doc/src/controllers/ms/setex/snippets/setex.js b/doc/6/controllers/ms/setex/snippets/setex.js similarity index 100% rename from doc/src/controllers/ms/setex/snippets/setex.js rename to doc/6/controllers/ms/setex/snippets/setex.js diff --git a/doc/src/controllers/ms/setex/snippets/setex.test.yml b/doc/6/controllers/ms/setex/snippets/setex.test.yml similarity index 100% rename from doc/src/controllers/ms/setex/snippets/setex.test.yml rename to doc/6/controllers/ms/setex/snippets/setex.test.yml diff --git a/doc/src/controllers/ms/setnx/index.md b/doc/6/controllers/ms/setnx/index.md similarity index 100% rename from doc/src/controllers/ms/setnx/index.md rename to doc/6/controllers/ms/setnx/index.md diff --git a/doc/src/controllers/ms/setnx/snippets/setnx.js b/doc/6/controllers/ms/setnx/snippets/setnx.js similarity index 100% rename from doc/src/controllers/ms/setnx/snippets/setnx.js rename to doc/6/controllers/ms/setnx/snippets/setnx.js diff --git a/doc/src/controllers/ms/setnx/snippets/setnx.test.yml b/doc/6/controllers/ms/setnx/snippets/setnx.test.yml similarity index 100% rename from doc/src/controllers/ms/setnx/snippets/setnx.test.yml rename to doc/6/controllers/ms/setnx/snippets/setnx.test.yml diff --git a/doc/src/controllers/ms/sinter/index.md b/doc/6/controllers/ms/sinter/index.md similarity index 100% rename from doc/src/controllers/ms/sinter/index.md rename to doc/6/controllers/ms/sinter/index.md diff --git a/doc/src/controllers/ms/sinter/snippets/sinter.js b/doc/6/controllers/ms/sinter/snippets/sinter.js similarity index 100% rename from doc/src/controllers/ms/sinter/snippets/sinter.js rename to doc/6/controllers/ms/sinter/snippets/sinter.js diff --git a/doc/src/controllers/ms/sinter/snippets/sinter.test.yml b/doc/6/controllers/ms/sinter/snippets/sinter.test.yml similarity index 100% rename from doc/src/controllers/ms/sinter/snippets/sinter.test.yml rename to doc/6/controllers/ms/sinter/snippets/sinter.test.yml diff --git a/doc/src/controllers/ms/sinterstore/index.md b/doc/6/controllers/ms/sinterstore/index.md similarity index 100% rename from doc/src/controllers/ms/sinterstore/index.md rename to doc/6/controllers/ms/sinterstore/index.md diff --git a/doc/src/controllers/ms/sinterstore/snippets/sinterstore.js b/doc/6/controllers/ms/sinterstore/snippets/sinterstore.js similarity index 100% rename from doc/src/controllers/ms/sinterstore/snippets/sinterstore.js rename to doc/6/controllers/ms/sinterstore/snippets/sinterstore.js diff --git a/doc/src/controllers/ms/sinterstore/snippets/sinterstore.test.yml b/doc/6/controllers/ms/sinterstore/snippets/sinterstore.test.yml similarity index 100% rename from doc/src/controllers/ms/sinterstore/snippets/sinterstore.test.yml rename to doc/6/controllers/ms/sinterstore/snippets/sinterstore.test.yml diff --git a/doc/src/controllers/ms/sismember/index.md b/doc/6/controllers/ms/sismember/index.md similarity index 100% rename from doc/src/controllers/ms/sismember/index.md rename to doc/6/controllers/ms/sismember/index.md diff --git a/doc/src/controllers/ms/sismember/snippets/sismember.js b/doc/6/controllers/ms/sismember/snippets/sismember.js similarity index 100% rename from doc/src/controllers/ms/sismember/snippets/sismember.js rename to doc/6/controllers/ms/sismember/snippets/sismember.js diff --git a/doc/src/controllers/ms/sismember/snippets/sismember.test.yml b/doc/6/controllers/ms/sismember/snippets/sismember.test.yml similarity index 100% rename from doc/src/controllers/ms/sismember/snippets/sismember.test.yml rename to doc/6/controllers/ms/sismember/snippets/sismember.test.yml diff --git a/doc/src/controllers/ms/smembers/index.md b/doc/6/controllers/ms/smembers/index.md similarity index 100% rename from doc/src/controllers/ms/smembers/index.md rename to doc/6/controllers/ms/smembers/index.md diff --git a/doc/src/controllers/ms/smembers/snippets/smembers.js b/doc/6/controllers/ms/smembers/snippets/smembers.js similarity index 100% rename from doc/src/controllers/ms/smembers/snippets/smembers.js rename to doc/6/controllers/ms/smembers/snippets/smembers.js diff --git a/doc/src/controllers/ms/smembers/snippets/smembers.test.yml b/doc/6/controllers/ms/smembers/snippets/smembers.test.yml similarity index 100% rename from doc/src/controllers/ms/smembers/snippets/smembers.test.yml rename to doc/6/controllers/ms/smembers/snippets/smembers.test.yml diff --git a/doc/src/controllers/ms/smove/index.md b/doc/6/controllers/ms/smove/index.md similarity index 100% rename from doc/src/controllers/ms/smove/index.md rename to doc/6/controllers/ms/smove/index.md diff --git a/doc/src/controllers/ms/smove/snippets/smove.js b/doc/6/controllers/ms/smove/snippets/smove.js similarity index 100% rename from doc/src/controllers/ms/smove/snippets/smove.js rename to doc/6/controllers/ms/smove/snippets/smove.js diff --git a/doc/src/controllers/ms/smove/snippets/smove.test.yml b/doc/6/controllers/ms/smove/snippets/smove.test.yml similarity index 100% rename from doc/src/controllers/ms/smove/snippets/smove.test.yml rename to doc/6/controllers/ms/smove/snippets/smove.test.yml diff --git a/doc/src/controllers/ms/sort/index.md b/doc/6/controllers/ms/sort/index.md similarity index 100% rename from doc/src/controllers/ms/sort/index.md rename to doc/6/controllers/ms/sort/index.md diff --git a/doc/src/controllers/ms/sort/snippets/sort.js b/doc/6/controllers/ms/sort/snippets/sort.js similarity index 100% rename from doc/src/controllers/ms/sort/snippets/sort.js rename to doc/6/controllers/ms/sort/snippets/sort.js diff --git a/doc/src/controllers/ms/sort/snippets/sort.test.yml b/doc/6/controllers/ms/sort/snippets/sort.test.yml similarity index 100% rename from doc/src/controllers/ms/sort/snippets/sort.test.yml rename to doc/6/controllers/ms/sort/snippets/sort.test.yml diff --git a/doc/src/controllers/ms/spop/index.md b/doc/6/controllers/ms/spop/index.md similarity index 100% rename from doc/src/controllers/ms/spop/index.md rename to doc/6/controllers/ms/spop/index.md diff --git a/doc/src/controllers/ms/spop/snippets/spop.js b/doc/6/controllers/ms/spop/snippets/spop.js similarity index 100% rename from doc/src/controllers/ms/spop/snippets/spop.js rename to doc/6/controllers/ms/spop/snippets/spop.js diff --git a/doc/src/controllers/ms/spop/snippets/spop.test.yml b/doc/6/controllers/ms/spop/snippets/spop.test.yml similarity index 100% rename from doc/src/controllers/ms/spop/snippets/spop.test.yml rename to doc/6/controllers/ms/spop/snippets/spop.test.yml diff --git a/doc/src/controllers/ms/srandmember/index.md b/doc/6/controllers/ms/srandmember/index.md similarity index 100% rename from doc/src/controllers/ms/srandmember/index.md rename to doc/6/controllers/ms/srandmember/index.md diff --git a/doc/src/controllers/ms/srandmember/snippets/srandmember.js b/doc/6/controllers/ms/srandmember/snippets/srandmember.js similarity index 100% rename from doc/src/controllers/ms/srandmember/snippets/srandmember.js rename to doc/6/controllers/ms/srandmember/snippets/srandmember.js diff --git a/doc/src/controllers/ms/srandmember/snippets/srandmember.test.yml b/doc/6/controllers/ms/srandmember/snippets/srandmember.test.yml similarity index 100% rename from doc/src/controllers/ms/srandmember/snippets/srandmember.test.yml rename to doc/6/controllers/ms/srandmember/snippets/srandmember.test.yml diff --git a/doc/src/controllers/ms/srem/index.md b/doc/6/controllers/ms/srem/index.md similarity index 100% rename from doc/src/controllers/ms/srem/index.md rename to doc/6/controllers/ms/srem/index.md diff --git a/doc/src/controllers/ms/srem/snippets/srem.js b/doc/6/controllers/ms/srem/snippets/srem.js similarity index 100% rename from doc/src/controllers/ms/srem/snippets/srem.js rename to doc/6/controllers/ms/srem/snippets/srem.js diff --git a/doc/src/controllers/ms/srem/snippets/srem.test.yml b/doc/6/controllers/ms/srem/snippets/srem.test.yml similarity index 100% rename from doc/src/controllers/ms/srem/snippets/srem.test.yml rename to doc/6/controllers/ms/srem/snippets/srem.test.yml diff --git a/doc/src/controllers/ms/sscan/index.md b/doc/6/controllers/ms/sscan/index.md similarity index 100% rename from doc/src/controllers/ms/sscan/index.md rename to doc/6/controllers/ms/sscan/index.md diff --git a/doc/src/controllers/ms/sscan/snippets/sscan.js b/doc/6/controllers/ms/sscan/snippets/sscan.js similarity index 100% rename from doc/src/controllers/ms/sscan/snippets/sscan.js rename to doc/6/controllers/ms/sscan/snippets/sscan.js diff --git a/doc/src/controllers/ms/sscan/snippets/sscan.test.yml b/doc/6/controllers/ms/sscan/snippets/sscan.test.yml similarity index 100% rename from doc/src/controllers/ms/sscan/snippets/sscan.test.yml rename to doc/6/controllers/ms/sscan/snippets/sscan.test.yml diff --git a/doc/src/controllers/ms/strlen/index.md b/doc/6/controllers/ms/strlen/index.md similarity index 100% rename from doc/src/controllers/ms/strlen/index.md rename to doc/6/controllers/ms/strlen/index.md diff --git a/doc/src/controllers/ms/strlen/snippets/strlen.js b/doc/6/controllers/ms/strlen/snippets/strlen.js similarity index 100% rename from doc/src/controllers/ms/strlen/snippets/strlen.js rename to doc/6/controllers/ms/strlen/snippets/strlen.js diff --git a/doc/src/controllers/ms/strlen/snippets/strlen.test.yml b/doc/6/controllers/ms/strlen/snippets/strlen.test.yml similarity index 100% rename from doc/src/controllers/ms/strlen/snippets/strlen.test.yml rename to doc/6/controllers/ms/strlen/snippets/strlen.test.yml diff --git a/doc/src/controllers/ms/sunion/index.md b/doc/6/controllers/ms/sunion/index.md similarity index 100% rename from doc/src/controllers/ms/sunion/index.md rename to doc/6/controllers/ms/sunion/index.md diff --git a/doc/src/controllers/ms/sunion/snippets/sunion.js b/doc/6/controllers/ms/sunion/snippets/sunion.js similarity index 100% rename from doc/src/controllers/ms/sunion/snippets/sunion.js rename to doc/6/controllers/ms/sunion/snippets/sunion.js diff --git a/doc/src/controllers/ms/sunion/snippets/sunion.test.yml b/doc/6/controllers/ms/sunion/snippets/sunion.test.yml similarity index 100% rename from doc/src/controllers/ms/sunion/snippets/sunion.test.yml rename to doc/6/controllers/ms/sunion/snippets/sunion.test.yml diff --git a/doc/src/controllers/ms/sunionstore/index.md b/doc/6/controllers/ms/sunionstore/index.md similarity index 100% rename from doc/src/controllers/ms/sunionstore/index.md rename to doc/6/controllers/ms/sunionstore/index.md diff --git a/doc/src/controllers/ms/sunionstore/snippets/sunionstore.js b/doc/6/controllers/ms/sunionstore/snippets/sunionstore.js similarity index 100% rename from doc/src/controllers/ms/sunionstore/snippets/sunionstore.js rename to doc/6/controllers/ms/sunionstore/snippets/sunionstore.js diff --git a/doc/src/controllers/ms/sunionstore/snippets/sunionstore.test.yml b/doc/6/controllers/ms/sunionstore/snippets/sunionstore.test.yml similarity index 100% rename from doc/src/controllers/ms/sunionstore/snippets/sunionstore.test.yml rename to doc/6/controllers/ms/sunionstore/snippets/sunionstore.test.yml diff --git a/doc/src/controllers/ms/time/index.md b/doc/6/controllers/ms/time/index.md similarity index 100% rename from doc/src/controllers/ms/time/index.md rename to doc/6/controllers/ms/time/index.md diff --git a/doc/src/controllers/ms/time/snippets/time.js b/doc/6/controllers/ms/time/snippets/time.js similarity index 100% rename from doc/src/controllers/ms/time/snippets/time.js rename to doc/6/controllers/ms/time/snippets/time.js diff --git a/doc/src/controllers/ms/time/snippets/time.test.yml b/doc/6/controllers/ms/time/snippets/time.test.yml similarity index 100% rename from doc/src/controllers/ms/time/snippets/time.test.yml rename to doc/6/controllers/ms/time/snippets/time.test.yml diff --git a/doc/src/controllers/ms/touch/index.md b/doc/6/controllers/ms/touch/index.md similarity index 100% rename from doc/src/controllers/ms/touch/index.md rename to doc/6/controllers/ms/touch/index.md diff --git a/doc/src/controllers/ms/touch/snippets/touch.js b/doc/6/controllers/ms/touch/snippets/touch.js similarity index 100% rename from doc/src/controllers/ms/touch/snippets/touch.js rename to doc/6/controllers/ms/touch/snippets/touch.js diff --git a/doc/src/controllers/ms/touch/snippets/touch.test.yml b/doc/6/controllers/ms/touch/snippets/touch.test.yml similarity index 100% rename from doc/src/controllers/ms/touch/snippets/touch.test.yml rename to doc/6/controllers/ms/touch/snippets/touch.test.yml diff --git a/doc/src/controllers/ms/ttl/index.md b/doc/6/controllers/ms/ttl/index.md similarity index 100% rename from doc/src/controllers/ms/ttl/index.md rename to doc/6/controllers/ms/ttl/index.md diff --git a/doc/src/controllers/ms/ttl/snippets/ttl.js b/doc/6/controllers/ms/ttl/snippets/ttl.js similarity index 100% rename from doc/src/controllers/ms/ttl/snippets/ttl.js rename to doc/6/controllers/ms/ttl/snippets/ttl.js diff --git a/doc/src/controllers/ms/ttl/snippets/ttl.test.yml b/doc/6/controllers/ms/ttl/snippets/ttl.test.yml similarity index 100% rename from doc/src/controllers/ms/ttl/snippets/ttl.test.yml rename to doc/6/controllers/ms/ttl/snippets/ttl.test.yml diff --git a/doc/src/controllers/ms/type/index.md b/doc/6/controllers/ms/type/index.md similarity index 100% rename from doc/src/controllers/ms/type/index.md rename to doc/6/controllers/ms/type/index.md diff --git a/doc/src/controllers/ms/type/snippets/type.js b/doc/6/controllers/ms/type/snippets/type.js similarity index 100% rename from doc/src/controllers/ms/type/snippets/type.js rename to doc/6/controllers/ms/type/snippets/type.js diff --git a/doc/src/controllers/ms/type/snippets/type.test.yml b/doc/6/controllers/ms/type/snippets/type.test.yml similarity index 100% rename from doc/src/controllers/ms/type/snippets/type.test.yml rename to doc/6/controllers/ms/type/snippets/type.test.yml diff --git a/doc/src/controllers/ms/zadd/index.md b/doc/6/controllers/ms/zadd/index.md similarity index 100% rename from doc/src/controllers/ms/zadd/index.md rename to doc/6/controllers/ms/zadd/index.md diff --git a/doc/src/controllers/ms/zadd/snippets/zadd.js b/doc/6/controllers/ms/zadd/snippets/zadd.js similarity index 100% rename from doc/src/controllers/ms/zadd/snippets/zadd.js rename to doc/6/controllers/ms/zadd/snippets/zadd.js diff --git a/doc/src/controllers/ms/zadd/snippets/zadd.test.yml b/doc/6/controllers/ms/zadd/snippets/zadd.test.yml similarity index 100% rename from doc/src/controllers/ms/zadd/snippets/zadd.test.yml rename to doc/6/controllers/ms/zadd/snippets/zadd.test.yml diff --git a/doc/src/controllers/ms/zcard/index.md b/doc/6/controllers/ms/zcard/index.md similarity index 100% rename from doc/src/controllers/ms/zcard/index.md rename to doc/6/controllers/ms/zcard/index.md diff --git a/doc/src/controllers/ms/zcard/snippets/zcard.js b/doc/6/controllers/ms/zcard/snippets/zcard.js similarity index 100% rename from doc/src/controllers/ms/zcard/snippets/zcard.js rename to doc/6/controllers/ms/zcard/snippets/zcard.js diff --git a/doc/src/controllers/ms/zcard/snippets/zcard.test.yml b/doc/6/controllers/ms/zcard/snippets/zcard.test.yml similarity index 100% rename from doc/src/controllers/ms/zcard/snippets/zcard.test.yml rename to doc/6/controllers/ms/zcard/snippets/zcard.test.yml diff --git a/doc/src/controllers/ms/zcount/index.md b/doc/6/controllers/ms/zcount/index.md similarity index 100% rename from doc/src/controllers/ms/zcount/index.md rename to doc/6/controllers/ms/zcount/index.md diff --git a/doc/src/controllers/ms/zcount/snippets/zcount.js b/doc/6/controllers/ms/zcount/snippets/zcount.js similarity index 100% rename from doc/src/controllers/ms/zcount/snippets/zcount.js rename to doc/6/controllers/ms/zcount/snippets/zcount.js diff --git a/doc/src/controllers/ms/zcount/snippets/zcount.test.yml b/doc/6/controllers/ms/zcount/snippets/zcount.test.yml similarity index 100% rename from doc/src/controllers/ms/zcount/snippets/zcount.test.yml rename to doc/6/controllers/ms/zcount/snippets/zcount.test.yml diff --git a/doc/src/controllers/ms/zincrby/index.md b/doc/6/controllers/ms/zincrby/index.md similarity index 100% rename from doc/src/controllers/ms/zincrby/index.md rename to doc/6/controllers/ms/zincrby/index.md diff --git a/doc/src/controllers/ms/zincrby/snippets/zincrby.js b/doc/6/controllers/ms/zincrby/snippets/zincrby.js similarity index 100% rename from doc/src/controllers/ms/zincrby/snippets/zincrby.js rename to doc/6/controllers/ms/zincrby/snippets/zincrby.js diff --git a/doc/src/controllers/ms/zincrby/snippets/zincrby.test.yml b/doc/6/controllers/ms/zincrby/snippets/zincrby.test.yml similarity index 100% rename from doc/src/controllers/ms/zincrby/snippets/zincrby.test.yml rename to doc/6/controllers/ms/zincrby/snippets/zincrby.test.yml diff --git a/doc/src/controllers/ms/zinterstore/index.md b/doc/6/controllers/ms/zinterstore/index.md similarity index 100% rename from doc/src/controllers/ms/zinterstore/index.md rename to doc/6/controllers/ms/zinterstore/index.md diff --git a/doc/src/controllers/ms/zinterstore/snippets/zinterstore.js b/doc/6/controllers/ms/zinterstore/snippets/zinterstore.js similarity index 100% rename from doc/src/controllers/ms/zinterstore/snippets/zinterstore.js rename to doc/6/controllers/ms/zinterstore/snippets/zinterstore.js diff --git a/doc/src/controllers/ms/zinterstore/snippets/zinterstore.test.yml b/doc/6/controllers/ms/zinterstore/snippets/zinterstore.test.yml similarity index 100% rename from doc/src/controllers/ms/zinterstore/snippets/zinterstore.test.yml rename to doc/6/controllers/ms/zinterstore/snippets/zinterstore.test.yml diff --git a/doc/src/controllers/ms/zlexcount/index.md b/doc/6/controllers/ms/zlexcount/index.md similarity index 100% rename from doc/src/controllers/ms/zlexcount/index.md rename to doc/6/controllers/ms/zlexcount/index.md diff --git a/doc/src/controllers/ms/zlexcount/snippets/zlexcount.js b/doc/6/controllers/ms/zlexcount/snippets/zlexcount.js similarity index 100% rename from doc/src/controllers/ms/zlexcount/snippets/zlexcount.js rename to doc/6/controllers/ms/zlexcount/snippets/zlexcount.js diff --git a/doc/src/controllers/ms/zlexcount/snippets/zlexcount.test.yml b/doc/6/controllers/ms/zlexcount/snippets/zlexcount.test.yml similarity index 100% rename from doc/src/controllers/ms/zlexcount/snippets/zlexcount.test.yml rename to doc/6/controllers/ms/zlexcount/snippets/zlexcount.test.yml diff --git a/doc/src/controllers/ms/zrange/index.md b/doc/6/controllers/ms/zrange/index.md similarity index 100% rename from doc/src/controllers/ms/zrange/index.md rename to doc/6/controllers/ms/zrange/index.md diff --git a/doc/src/controllers/ms/zrange/snippets/zrange.js b/doc/6/controllers/ms/zrange/snippets/zrange.js similarity index 100% rename from doc/src/controllers/ms/zrange/snippets/zrange.js rename to doc/6/controllers/ms/zrange/snippets/zrange.js diff --git a/doc/src/controllers/ms/zrange/snippets/zrange.test.yml b/doc/6/controllers/ms/zrange/snippets/zrange.test.yml similarity index 100% rename from doc/src/controllers/ms/zrange/snippets/zrange.test.yml rename to doc/6/controllers/ms/zrange/snippets/zrange.test.yml diff --git a/doc/src/controllers/ms/zrangebylex/index.md b/doc/6/controllers/ms/zrangebylex/index.md similarity index 100% rename from doc/src/controllers/ms/zrangebylex/index.md rename to doc/6/controllers/ms/zrangebylex/index.md diff --git a/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.js b/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.js similarity index 100% rename from doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.js rename to doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.js diff --git a/doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml b/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml similarity index 100% rename from doc/src/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml rename to doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml diff --git a/doc/src/controllers/ms/zrangebyscore/index.md b/doc/6/controllers/ms/zrangebyscore/index.md similarity index 100% rename from doc/src/controllers/ms/zrangebyscore/index.md rename to doc/6/controllers/ms/zrangebyscore/index.md diff --git a/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.js b/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.js similarity index 100% rename from doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.js rename to doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.js diff --git a/doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml b/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml similarity index 100% rename from doc/src/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml rename to doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml diff --git a/doc/src/controllers/ms/zrank/index.md b/doc/6/controllers/ms/zrank/index.md similarity index 100% rename from doc/src/controllers/ms/zrank/index.md rename to doc/6/controllers/ms/zrank/index.md diff --git a/doc/src/controllers/ms/zrank/snippets/zrank.js b/doc/6/controllers/ms/zrank/snippets/zrank.js similarity index 100% rename from doc/src/controllers/ms/zrank/snippets/zrank.js rename to doc/6/controllers/ms/zrank/snippets/zrank.js diff --git a/doc/src/controllers/ms/zrank/snippets/zrank.test.yml b/doc/6/controllers/ms/zrank/snippets/zrank.test.yml similarity index 100% rename from doc/src/controllers/ms/zrank/snippets/zrank.test.yml rename to doc/6/controllers/ms/zrank/snippets/zrank.test.yml diff --git a/doc/src/controllers/ms/zrem/index.md b/doc/6/controllers/ms/zrem/index.md similarity index 100% rename from doc/src/controllers/ms/zrem/index.md rename to doc/6/controllers/ms/zrem/index.md diff --git a/doc/src/controllers/ms/zrem/snippets/zrem.js b/doc/6/controllers/ms/zrem/snippets/zrem.js similarity index 100% rename from doc/src/controllers/ms/zrem/snippets/zrem.js rename to doc/6/controllers/ms/zrem/snippets/zrem.js diff --git a/doc/src/controllers/ms/zrem/snippets/zrem.test.yml b/doc/6/controllers/ms/zrem/snippets/zrem.test.yml similarity index 100% rename from doc/src/controllers/ms/zrem/snippets/zrem.test.yml rename to doc/6/controllers/ms/zrem/snippets/zrem.test.yml diff --git a/doc/src/controllers/ms/zremrangebylex/index.md b/doc/6/controllers/ms/zremrangebylex/index.md similarity index 100% rename from doc/src/controllers/ms/zremrangebylex/index.md rename to doc/6/controllers/ms/zremrangebylex/index.md diff --git a/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.js b/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.js similarity index 100% rename from doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.js rename to doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.js diff --git a/doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml b/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml similarity index 100% rename from doc/src/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml rename to doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml diff --git a/doc/src/controllers/ms/zremrangebyrank/index.md b/doc/6/controllers/ms/zremrangebyrank/index.md similarity index 100% rename from doc/src/controllers/ms/zremrangebyrank/index.md rename to doc/6/controllers/ms/zremrangebyrank/index.md diff --git a/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js b/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js similarity index 100% rename from doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js rename to doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js diff --git a/doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml b/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml similarity index 100% rename from doc/src/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml rename to doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml diff --git a/doc/src/controllers/ms/zremrangebyscore/index.md b/doc/6/controllers/ms/zremrangebyscore/index.md similarity index 100% rename from doc/src/controllers/ms/zremrangebyscore/index.md rename to doc/6/controllers/ms/zremrangebyscore/index.md diff --git a/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js b/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js similarity index 100% rename from doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js rename to doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js diff --git a/doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml b/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml similarity index 100% rename from doc/src/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml rename to doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml diff --git a/doc/src/controllers/ms/zrevrange/index.md b/doc/6/controllers/ms/zrevrange/index.md similarity index 100% rename from doc/src/controllers/ms/zrevrange/index.md rename to doc/6/controllers/ms/zrevrange/index.md diff --git a/doc/src/controllers/ms/zrevrange/snippets/zrevrange.js b/doc/6/controllers/ms/zrevrange/snippets/zrevrange.js similarity index 100% rename from doc/src/controllers/ms/zrevrange/snippets/zrevrange.js rename to doc/6/controllers/ms/zrevrange/snippets/zrevrange.js diff --git a/doc/src/controllers/ms/zrevrange/snippets/zrevrange.test.yml b/doc/6/controllers/ms/zrevrange/snippets/zrevrange.test.yml similarity index 100% rename from doc/src/controllers/ms/zrevrange/snippets/zrevrange.test.yml rename to doc/6/controllers/ms/zrevrange/snippets/zrevrange.test.yml diff --git a/doc/src/controllers/ms/zrevrangebylex/index.md b/doc/6/controllers/ms/zrevrangebylex/index.md similarity index 100% rename from doc/src/controllers/ms/zrevrangebylex/index.md rename to doc/6/controllers/ms/zrevrangebylex/index.md diff --git a/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js b/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js similarity index 100% rename from doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js rename to doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js diff --git a/doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml b/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml similarity index 100% rename from doc/src/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml rename to doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml diff --git a/doc/src/controllers/ms/zrevrangebyscore/index.md b/doc/6/controllers/ms/zrevrangebyscore/index.md similarity index 100% rename from doc/src/controllers/ms/zrevrangebyscore/index.md rename to doc/6/controllers/ms/zrevrangebyscore/index.md diff --git a/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js b/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js similarity index 100% rename from doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js rename to doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js diff --git a/doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml b/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml similarity index 100% rename from doc/src/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml rename to doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml diff --git a/doc/src/controllers/ms/zrevrank/index.md b/doc/6/controllers/ms/zrevrank/index.md similarity index 100% rename from doc/src/controllers/ms/zrevrank/index.md rename to doc/6/controllers/ms/zrevrank/index.md diff --git a/doc/src/controllers/ms/zrevrank/snippets/zrevrank.js b/doc/6/controllers/ms/zrevrank/snippets/zrevrank.js similarity index 100% rename from doc/src/controllers/ms/zrevrank/snippets/zrevrank.js rename to doc/6/controllers/ms/zrevrank/snippets/zrevrank.js diff --git a/doc/src/controllers/ms/zrevrank/snippets/zrevrank.test.yml b/doc/6/controllers/ms/zrevrank/snippets/zrevrank.test.yml similarity index 100% rename from doc/src/controllers/ms/zrevrank/snippets/zrevrank.test.yml rename to doc/6/controllers/ms/zrevrank/snippets/zrevrank.test.yml diff --git a/doc/src/controllers/ms/zscan/index.md b/doc/6/controllers/ms/zscan/index.md similarity index 100% rename from doc/src/controllers/ms/zscan/index.md rename to doc/6/controllers/ms/zscan/index.md diff --git a/doc/src/controllers/ms/zscan/snippets/zscan.js b/doc/6/controllers/ms/zscan/snippets/zscan.js similarity index 100% rename from doc/src/controllers/ms/zscan/snippets/zscan.js rename to doc/6/controllers/ms/zscan/snippets/zscan.js diff --git a/doc/src/controllers/ms/zscan/snippets/zscan.test.yml b/doc/6/controllers/ms/zscan/snippets/zscan.test.yml similarity index 100% rename from doc/src/controllers/ms/zscan/snippets/zscan.test.yml rename to doc/6/controllers/ms/zscan/snippets/zscan.test.yml diff --git a/doc/src/controllers/ms/zscore/index.md b/doc/6/controllers/ms/zscore/index.md similarity index 100% rename from doc/src/controllers/ms/zscore/index.md rename to doc/6/controllers/ms/zscore/index.md diff --git a/doc/src/controllers/ms/zscore/snippets/zscore.js b/doc/6/controllers/ms/zscore/snippets/zscore.js similarity index 100% rename from doc/src/controllers/ms/zscore/snippets/zscore.js rename to doc/6/controllers/ms/zscore/snippets/zscore.js diff --git a/doc/src/controllers/ms/zscore/snippets/zscore.test.yml b/doc/6/controllers/ms/zscore/snippets/zscore.test.yml similarity index 100% rename from doc/src/controllers/ms/zscore/snippets/zscore.test.yml rename to doc/6/controllers/ms/zscore/snippets/zscore.test.yml diff --git a/doc/src/controllers/ms/zunionstore/index.md b/doc/6/controllers/ms/zunionstore/index.md similarity index 100% rename from doc/src/controllers/ms/zunionstore/index.md rename to doc/6/controllers/ms/zunionstore/index.md diff --git a/doc/src/controllers/ms/zunionstore/snippets/zunionstore.js b/doc/6/controllers/ms/zunionstore/snippets/zunionstore.js similarity index 100% rename from doc/src/controllers/ms/zunionstore/snippets/zunionstore.js rename to doc/6/controllers/ms/zunionstore/snippets/zunionstore.js diff --git a/doc/src/controllers/ms/zunionstore/snippets/zunionstore.test.yml b/doc/6/controllers/ms/zunionstore/snippets/zunionstore.test.yml similarity index 100% rename from doc/src/controllers/ms/zunionstore/snippets/zunionstore.test.yml rename to doc/6/controllers/ms/zunionstore/snippets/zunionstore.test.yml diff --git a/doc/src/controllers/realtime/count/index.md b/doc/6/controllers/realtime/count/index.md similarity index 100% rename from doc/src/controllers/realtime/count/index.md rename to doc/6/controllers/realtime/count/index.md diff --git a/doc/src/controllers/realtime/count/snippets/count.js b/doc/6/controllers/realtime/count/snippets/count.js similarity index 100% rename from doc/src/controllers/realtime/count/snippets/count.js rename to doc/6/controllers/realtime/count/snippets/count.js diff --git a/doc/src/controllers/realtime/count/snippets/count.test.yml b/doc/6/controllers/realtime/count/snippets/count.test.yml similarity index 100% rename from doc/src/controllers/realtime/count/snippets/count.test.yml rename to doc/6/controllers/realtime/count/snippets/count.test.yml diff --git a/doc/src/controllers/realtime/index.md b/doc/6/controllers/realtime/index.md similarity index 100% rename from doc/src/controllers/realtime/index.md rename to doc/6/controllers/realtime/index.md diff --git a/doc/src/controllers/realtime/publish/index.md b/doc/6/controllers/realtime/publish/index.md similarity index 100% rename from doc/src/controllers/realtime/publish/index.md rename to doc/6/controllers/realtime/publish/index.md diff --git a/doc/src/controllers/realtime/publish/snippets/publish.js b/doc/6/controllers/realtime/publish/snippets/publish.js similarity index 100% rename from doc/src/controllers/realtime/publish/snippets/publish.js rename to doc/6/controllers/realtime/publish/snippets/publish.js diff --git a/doc/src/controllers/realtime/publish/snippets/publish.test.yml b/doc/6/controllers/realtime/publish/snippets/publish.test.yml similarity index 100% rename from doc/src/controllers/realtime/publish/snippets/publish.test.yml rename to doc/6/controllers/realtime/publish/snippets/publish.test.yml diff --git a/doc/src/controllers/realtime/subscribe/index.md b/doc/6/controllers/realtime/subscribe/index.md similarity index 100% rename from doc/src/controllers/realtime/subscribe/index.md rename to doc/6/controllers/realtime/subscribe/index.md diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js b/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js rename to doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml b/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml rename to doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications.js b/doc/6/controllers/realtime/subscribe/snippets/document-notifications.js similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/document-notifications.js rename to doc/6/controllers/realtime/subscribe/snippets/document-notifications.js diff --git a/doc/src/controllers/realtime/subscribe/snippets/document-notifications.test.yml b/doc/6/controllers/realtime/subscribe/snippets/document-notifications.test.yml similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/document-notifications.test.yml rename to doc/6/controllers/realtime/subscribe/snippets/document-notifications.test.yml diff --git a/doc/src/controllers/realtime/subscribe/snippets/message-notifications.js b/doc/6/controllers/realtime/subscribe/snippets/message-notifications.js similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/message-notifications.js rename to doc/6/controllers/realtime/subscribe/snippets/message-notifications.js diff --git a/doc/src/controllers/realtime/subscribe/snippets/message-notifications.test.yml b/doc/6/controllers/realtime/subscribe/snippets/message-notifications.test.yml similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/message-notifications.test.yml rename to doc/6/controllers/realtime/subscribe/snippets/message-notifications.test.yml diff --git a/doc/src/controllers/realtime/subscribe/snippets/user-notifications.js b/doc/6/controllers/realtime/subscribe/snippets/user-notifications.js similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/user-notifications.js rename to doc/6/controllers/realtime/subscribe/snippets/user-notifications.js diff --git a/doc/src/controllers/realtime/subscribe/snippets/user-notifications.test.yml b/doc/6/controllers/realtime/subscribe/snippets/user-notifications.test.yml similarity index 100% rename from doc/src/controllers/realtime/subscribe/snippets/user-notifications.test.yml rename to doc/6/controllers/realtime/subscribe/snippets/user-notifications.test.yml diff --git a/doc/src/controllers/realtime/unsubscribe/index.md b/doc/6/controllers/realtime/unsubscribe/index.md similarity index 100% rename from doc/src/controllers/realtime/unsubscribe/index.md rename to doc/6/controllers/realtime/unsubscribe/index.md diff --git a/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.js b/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.js similarity index 100% rename from doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.js rename to doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.js diff --git a/doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml b/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml similarity index 100% rename from doc/src/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml rename to doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml diff --git a/doc/src/controllers/server/admin-exists/index.md b/doc/6/controllers/server/admin-exists/index.md similarity index 100% rename from doc/src/controllers/server/admin-exists/index.md rename to doc/6/controllers/server/admin-exists/index.md diff --git a/doc/src/controllers/server/admin-exists/snippets/admin-exists.js b/doc/6/controllers/server/admin-exists/snippets/admin-exists.js similarity index 100% rename from doc/src/controllers/server/admin-exists/snippets/admin-exists.js rename to doc/6/controllers/server/admin-exists/snippets/admin-exists.js diff --git a/doc/src/controllers/server/admin-exists/snippets/admin-exists.test.yml b/doc/6/controllers/server/admin-exists/snippets/admin-exists.test.yml similarity index 100% rename from doc/src/controllers/server/admin-exists/snippets/admin-exists.test.yml rename to doc/6/controllers/server/admin-exists/snippets/admin-exists.test.yml diff --git a/doc/src/controllers/server/get-all-stats/index.md b/doc/6/controllers/server/get-all-stats/index.md similarity index 100% rename from doc/src/controllers/server/get-all-stats/index.md rename to doc/6/controllers/server/get-all-stats/index.md diff --git a/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.js b/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.js similarity index 100% rename from doc/src/controllers/server/get-all-stats/snippets/get-all-stats.js rename to doc/6/controllers/server/get-all-stats/snippets/get-all-stats.js diff --git a/doc/src/controllers/server/get-all-stats/snippets/get-all-stats.test.yml b/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.test.yml similarity index 100% rename from doc/src/controllers/server/get-all-stats/snippets/get-all-stats.test.yml rename to doc/6/controllers/server/get-all-stats/snippets/get-all-stats.test.yml diff --git a/doc/src/controllers/server/get-config/index.md b/doc/6/controllers/server/get-config/index.md similarity index 100% rename from doc/src/controllers/server/get-config/index.md rename to doc/6/controllers/server/get-config/index.md diff --git a/doc/src/controllers/server/get-config/snippets/get-config.js b/doc/6/controllers/server/get-config/snippets/get-config.js similarity index 100% rename from doc/src/controllers/server/get-config/snippets/get-config.js rename to doc/6/controllers/server/get-config/snippets/get-config.js diff --git a/doc/src/controllers/server/get-config/snippets/get-config.test.yml b/doc/6/controllers/server/get-config/snippets/get-config.test.yml similarity index 100% rename from doc/src/controllers/server/get-config/snippets/get-config.test.yml rename to doc/6/controllers/server/get-config/snippets/get-config.test.yml diff --git a/doc/src/controllers/server/get-last-stats/index.md b/doc/6/controllers/server/get-last-stats/index.md similarity index 100% rename from doc/src/controllers/server/get-last-stats/index.md rename to doc/6/controllers/server/get-last-stats/index.md diff --git a/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.js b/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.js similarity index 100% rename from doc/src/controllers/server/get-last-stats/snippets/get-last-stats.js rename to doc/6/controllers/server/get-last-stats/snippets/get-last-stats.js diff --git a/doc/src/controllers/server/get-last-stats/snippets/get-last-stats.test.yml b/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.test.yml similarity index 100% rename from doc/src/controllers/server/get-last-stats/snippets/get-last-stats.test.yml rename to doc/6/controllers/server/get-last-stats/snippets/get-last-stats.test.yml diff --git a/doc/src/controllers/server/get-stats/index.md b/doc/6/controllers/server/get-stats/index.md similarity index 100% rename from doc/src/controllers/server/get-stats/index.md rename to doc/6/controllers/server/get-stats/index.md diff --git a/doc/src/controllers/server/get-stats/snippets/get-stats.js b/doc/6/controllers/server/get-stats/snippets/get-stats.js similarity index 100% rename from doc/src/controllers/server/get-stats/snippets/get-stats.js rename to doc/6/controllers/server/get-stats/snippets/get-stats.js diff --git a/doc/src/controllers/server/get-stats/snippets/get-stats.test.yml b/doc/6/controllers/server/get-stats/snippets/get-stats.test.yml similarity index 100% rename from doc/src/controllers/server/get-stats/snippets/get-stats.test.yml rename to doc/6/controllers/server/get-stats/snippets/get-stats.test.yml diff --git a/doc/src/controllers/server/index.md b/doc/6/controllers/server/index.md similarity index 100% rename from doc/src/controllers/server/index.md rename to doc/6/controllers/server/index.md diff --git a/doc/src/controllers/server/info/index.md b/doc/6/controllers/server/info/index.md similarity index 100% rename from doc/src/controllers/server/info/index.md rename to doc/6/controllers/server/info/index.md diff --git a/doc/src/controllers/server/info/snippets/info.js b/doc/6/controllers/server/info/snippets/info.js similarity index 100% rename from doc/src/controllers/server/info/snippets/info.js rename to doc/6/controllers/server/info/snippets/info.js diff --git a/doc/src/controllers/server/info/snippets/info.test.yml b/doc/6/controllers/server/info/snippets/info.test.yml similarity index 100% rename from doc/src/controllers/server/info/snippets/info.test.yml rename to doc/6/controllers/server/info/snippets/info.test.yml diff --git a/doc/src/controllers/server/now/index.md b/doc/6/controllers/server/now/index.md similarity index 100% rename from doc/src/controllers/server/now/index.md rename to doc/6/controllers/server/now/index.md diff --git a/doc/src/controllers/server/now/snippets/now.js b/doc/6/controllers/server/now/snippets/now.js similarity index 100% rename from doc/src/controllers/server/now/snippets/now.js rename to doc/6/controllers/server/now/snippets/now.js diff --git a/doc/src/controllers/server/now/snippets/now.test.yml b/doc/6/controllers/server/now/snippets/now.test.yml similarity index 100% rename from doc/src/controllers/server/now/snippets/now.test.yml rename to doc/6/controllers/server/now/snippets/now.test.yml diff --git a/doc/src/core-classes/index.md b/doc/6/core-classes/index.md similarity index 100% rename from doc/src/core-classes/index.md rename to doc/6/core-classes/index.md diff --git a/doc/src/core-classes/kuzzle-error/index.md b/doc/6/core-classes/kuzzle-error/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-error/index.md rename to doc/6/core-classes/kuzzle-error/index.md diff --git a/doc/src/core-classes/kuzzle-error/introduction/index.md b/doc/6/core-classes/kuzzle-error/introduction/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-error/introduction/index.md rename to doc/6/core-classes/kuzzle-error/introduction/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/add-once-listener/index.md rename to doc/6/core-classes/kuzzle-event-emitter/add-once-listener/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js rename to doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml diff --git a/doc/src/core-classes/kuzzle-event-emitter/emit/index.md b/doc/6/core-classes/kuzzle-event-emitter/emit/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/emit/index.md rename to doc/6/core-classes/kuzzle-event-emitter/emit/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.js b/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.js rename to doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml b/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml diff --git a/doc/src/core-classes/kuzzle-event-emitter/index.md b/doc/6/core-classes/kuzzle-event-emitter/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/index.md rename to doc/6/core-classes/kuzzle-event-emitter/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/introduction/index.md b/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/introduction/index.md rename to doc/6/core-classes/kuzzle-event-emitter/introduction/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/listeners/index.md b/doc/6/core-classes/kuzzle-event-emitter/listeners/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/listeners/index.md rename to doc/6/core-classes/kuzzle-event-emitter/listeners/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js b/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js rename to doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml b/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml diff --git a/doc/src/core-classes/kuzzle-event-emitter/on/index.md b/doc/6/core-classes/kuzzle-event-emitter/on/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/on/index.md rename to doc/6/core-classes/kuzzle-event-emitter/on/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/once/index.md b/doc/6/core-classes/kuzzle-event-emitter/once/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/once/index.md rename to doc/6/core-classes/kuzzle-event-emitter/once/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/prepend-listener/index.md rename to doc/6/core-classes/kuzzle-event-emitter/prepend-listener/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js rename to doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md rename to doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js rename to doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/index.md rename to doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js rename to doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/index.md similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/remove-listener/index.md rename to doc/6/core-classes/kuzzle-event-emitter/remove-listener/index.md diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js rename to doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js diff --git a/doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml rename to doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml diff --git a/doc/src/core-classes/kuzzle/add-listener/index.md b/doc/6/core-classes/kuzzle/add-listener/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/add-listener/index.md rename to doc/6/core-classes/kuzzle/add-listener/index.md diff --git a/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.js b/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.js similarity index 100% rename from doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.js rename to doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.js diff --git a/doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml b/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml rename to doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml diff --git a/doc/src/core-classes/kuzzle/connect/index.md b/doc/6/core-classes/kuzzle/connect/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/connect/index.md rename to doc/6/core-classes/kuzzle/connect/index.md diff --git a/doc/src/core-classes/kuzzle/connect/snippets/connect.js b/doc/6/core-classes/kuzzle/connect/snippets/connect.js similarity index 100% rename from doc/src/core-classes/kuzzle/connect/snippets/connect.js rename to doc/6/core-classes/kuzzle/connect/snippets/connect.js diff --git a/doc/src/core-classes/kuzzle/connect/snippets/connect.test.yml b/doc/6/core-classes/kuzzle/connect/snippets/connect.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/connect/snippets/connect.test.yml rename to doc/6/core-classes/kuzzle/connect/snippets/connect.test.yml diff --git a/doc/src/core-classes/kuzzle/constructor/index.md b/doc/6/core-classes/kuzzle/constructor/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/constructor/index.md rename to doc/6/core-classes/kuzzle/constructor/index.md diff --git a/doc/src/core-classes/kuzzle/constructor/snippets/constructor.js b/doc/6/core-classes/kuzzle/constructor/snippets/constructor.js similarity index 100% rename from doc/src/core-classes/kuzzle/constructor/snippets/constructor.js rename to doc/6/core-classes/kuzzle/constructor/snippets/constructor.js diff --git a/doc/src/core-classes/kuzzle/constructor/snippets/constructor.test.yml b/doc/6/core-classes/kuzzle/constructor/snippets/constructor.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/constructor/snippets/constructor.test.yml rename to doc/6/core-classes/kuzzle/constructor/snippets/constructor.test.yml diff --git a/doc/src/core-classes/kuzzle/disconnect/index.md b/doc/6/core-classes/kuzzle/disconnect/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/disconnect/index.md rename to doc/6/core-classes/kuzzle/disconnect/index.md diff --git a/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.js b/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.js similarity index 100% rename from doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.js rename to doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.js diff --git a/doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml b/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml rename to doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml diff --git a/doc/src/core-classes/kuzzle/flush-queue/index.md b/doc/6/core-classes/kuzzle/flush-queue/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/flush-queue/index.md rename to doc/6/core-classes/kuzzle/flush-queue/index.md diff --git a/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.js b/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.js similarity index 100% rename from doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.js rename to doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.js diff --git a/doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml b/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml rename to doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml diff --git a/doc/src/core-classes/kuzzle/index.md b/doc/6/core-classes/kuzzle/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/index.md rename to doc/6/core-classes/kuzzle/index.md diff --git a/doc/src/core-classes/kuzzle/introduction/index.md b/doc/6/core-classes/kuzzle/introduction/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/introduction/index.md rename to doc/6/core-classes/kuzzle/introduction/index.md diff --git a/doc/src/core-classes/kuzzle/play-queue/index.md b/doc/6/core-classes/kuzzle/play-queue/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/play-queue/index.md rename to doc/6/core-classes/kuzzle/play-queue/index.md diff --git a/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.js b/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.js similarity index 100% rename from doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.js rename to doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.js diff --git a/doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml b/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml rename to doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml diff --git a/doc/src/core-classes/kuzzle/query/index.md b/doc/6/core-classes/kuzzle/query/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/query/index.md rename to doc/6/core-classes/kuzzle/query/index.md diff --git a/doc/src/core-classes/kuzzle/query/snippets/query.js b/doc/6/core-classes/kuzzle/query/snippets/query.js similarity index 100% rename from doc/src/core-classes/kuzzle/query/snippets/query.js rename to doc/6/core-classes/kuzzle/query/snippets/query.js diff --git a/doc/src/core-classes/kuzzle/query/snippets/query.test.yml b/doc/6/core-classes/kuzzle/query/snippets/query.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/query/snippets/query.test.yml rename to doc/6/core-classes/kuzzle/query/snippets/query.test.yml diff --git a/doc/src/core-classes/kuzzle/start-queuing/index.md b/doc/6/core-classes/kuzzle/start-queuing/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/start-queuing/index.md rename to doc/6/core-classes/kuzzle/start-queuing/index.md diff --git a/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.js b/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.js similarity index 100% rename from doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.js rename to doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.js diff --git a/doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml b/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml rename to doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml diff --git a/doc/src/core-classes/kuzzle/stop-queuing/index.md b/doc/6/core-classes/kuzzle/stop-queuing/index.md similarity index 100% rename from doc/src/core-classes/kuzzle/stop-queuing/index.md rename to doc/6/core-classes/kuzzle/stop-queuing/index.md diff --git a/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js b/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js similarity index 100% rename from doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js rename to doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js diff --git a/doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml b/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml similarity index 100% rename from doc/src/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml rename to doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml diff --git a/doc/src/core-classes/profile/getRoles/index.md b/doc/6/core-classes/profile/getRoles/index.md similarity index 100% rename from doc/src/core-classes/profile/getRoles/index.md rename to doc/6/core-classes/profile/getRoles/index.md diff --git a/doc/src/core-classes/profile/getRoles/snippets/getRoles.js b/doc/6/core-classes/profile/getRoles/snippets/getRoles.js similarity index 100% rename from doc/src/core-classes/profile/getRoles/snippets/getRoles.js rename to doc/6/core-classes/profile/getRoles/snippets/getRoles.js diff --git a/doc/src/core-classes/profile/getRoles/snippets/getRoles.test.yml b/doc/6/core-classes/profile/getRoles/snippets/getRoles.test.yml similarity index 100% rename from doc/src/core-classes/profile/getRoles/snippets/getRoles.test.yml rename to doc/6/core-classes/profile/getRoles/snippets/getRoles.test.yml diff --git a/doc/src/core-classes/profile/index.md b/doc/6/core-classes/profile/index.md similarity index 100% rename from doc/src/core-classes/profile/index.md rename to doc/6/core-classes/profile/index.md diff --git a/doc/src/core-classes/profile/introduction/index.md b/doc/6/core-classes/profile/introduction/index.md similarity index 100% rename from doc/src/core-classes/profile/introduction/index.md rename to doc/6/core-classes/profile/introduction/index.md diff --git a/doc/src/core-classes/role/index.md b/doc/6/core-classes/role/index.md similarity index 100% rename from doc/src/core-classes/role/index.md rename to doc/6/core-classes/role/index.md diff --git a/doc/src/core-classes/role/introduction/index.md b/doc/6/core-classes/role/introduction/index.md similarity index 100% rename from doc/src/core-classes/role/introduction/index.md rename to doc/6/core-classes/role/introduction/index.md diff --git a/doc/src/core-classes/search-result/index.md b/doc/6/core-classes/search-result/index.md similarity index 100% rename from doc/src/core-classes/search-result/index.md rename to doc/6/core-classes/search-result/index.md diff --git a/doc/src/core-classes/search-result/introduction/index.md b/doc/6/core-classes/search-result/introduction/index.md similarity index 100% rename from doc/src/core-classes/search-result/introduction/index.md rename to doc/6/core-classes/search-result/introduction/index.md diff --git a/doc/src/core-classes/search-result/next/index.md b/doc/6/core-classes/search-result/next/index.md similarity index 100% rename from doc/src/core-classes/search-result/next/index.md rename to doc/6/core-classes/search-result/next/index.md diff --git a/doc/src/core-classes/search-result/next/snippets/fromsize.js b/doc/6/core-classes/search-result/next/snippets/fromsize.js similarity index 100% rename from doc/src/core-classes/search-result/next/snippets/fromsize.js rename to doc/6/core-classes/search-result/next/snippets/fromsize.js diff --git a/doc/src/core-classes/search-result/next/snippets/fromsize.test.yml b/doc/6/core-classes/search-result/next/snippets/fromsize.test.yml similarity index 100% rename from doc/src/core-classes/search-result/next/snippets/fromsize.test.yml rename to doc/6/core-classes/search-result/next/snippets/fromsize.test.yml diff --git a/doc/src/core-classes/search-result/next/snippets/scroll.js b/doc/6/core-classes/search-result/next/snippets/scroll.js similarity index 100% rename from doc/src/core-classes/search-result/next/snippets/scroll.js rename to doc/6/core-classes/search-result/next/snippets/scroll.js diff --git a/doc/src/core-classes/search-result/next/snippets/scroll.test.yml b/doc/6/core-classes/search-result/next/snippets/scroll.test.yml similarity index 100% rename from doc/src/core-classes/search-result/next/snippets/scroll.test.yml rename to doc/6/core-classes/search-result/next/snippets/scroll.test.yml diff --git a/doc/src/core-classes/user/getProfiles/index.md b/doc/6/core-classes/user/getProfiles/index.md similarity index 100% rename from doc/src/core-classes/user/getProfiles/index.md rename to doc/6/core-classes/user/getProfiles/index.md diff --git a/doc/src/core-classes/user/getProfiles/snippets/getProfiles.js b/doc/6/core-classes/user/getProfiles/snippets/getProfiles.js similarity index 100% rename from doc/src/core-classes/user/getProfiles/snippets/getProfiles.js rename to doc/6/core-classes/user/getProfiles/snippets/getProfiles.js diff --git a/doc/src/core-classes/user/getProfiles/snippets/getProfiles.test.yml b/doc/6/core-classes/user/getProfiles/snippets/getProfiles.test.yml similarity index 100% rename from doc/src/core-classes/user/getProfiles/snippets/getProfiles.test.yml rename to doc/6/core-classes/user/getProfiles/snippets/getProfiles.test.yml diff --git a/doc/src/core-classes/user/index.md b/doc/6/core-classes/user/index.md similarity index 100% rename from doc/src/core-classes/user/index.md rename to doc/6/core-classes/user/index.md diff --git a/doc/src/core-classes/user/introduction/index.md b/doc/6/core-classes/user/introduction/index.md similarity index 100% rename from doc/src/core-classes/user/introduction/index.md rename to doc/6/core-classes/user/introduction/index.md diff --git a/doc/src/essentials/error-handling/index.md b/doc/6/essentials/error-handling/index.md similarity index 100% rename from doc/src/essentials/error-handling/index.md rename to doc/6/essentials/error-handling/index.md diff --git a/doc/src/essentials/error-handling/snippets/error-handling-async.js b/doc/6/essentials/error-handling/snippets/error-handling-async.js similarity index 100% rename from doc/src/essentials/error-handling/snippets/error-handling-async.js rename to doc/6/essentials/error-handling/snippets/error-handling-async.js diff --git a/doc/src/essentials/error-handling/snippets/error-handling-async.test.yml b/doc/6/essentials/error-handling/snippets/error-handling-async.test.yml similarity index 100% rename from doc/src/essentials/error-handling/snippets/error-handling-async.test.yml rename to doc/6/essentials/error-handling/snippets/error-handling-async.test.yml diff --git a/doc/src/essentials/error-handling/snippets/error-handling.js b/doc/6/essentials/error-handling/snippets/error-handling.js similarity index 100% rename from doc/src/essentials/error-handling/snippets/error-handling.js rename to doc/6/essentials/error-handling/snippets/error-handling.js diff --git a/doc/src/essentials/error-handling/snippets/error-handling.test.yml b/doc/6/essentials/error-handling/snippets/error-handling.test.yml similarity index 100% rename from doc/src/essentials/error-handling/snippets/error-handling.test.yml rename to doc/6/essentials/error-handling/snippets/error-handling.test.yml diff --git a/doc/src/essentials/events/index.md b/doc/6/essentials/events/index.md similarity index 100% rename from doc/src/essentials/events/index.md rename to doc/6/essentials/events/index.md diff --git a/doc/src/essentials/extend-sdk/index.md b/doc/6/essentials/extend-sdk/index.md similarity index 100% rename from doc/src/essentials/extend-sdk/index.md rename to doc/6/essentials/extend-sdk/index.md diff --git a/doc/src/essentials/getting-started/index.md b/doc/6/essentials/getting-started/index.md similarity index 100% rename from doc/src/essentials/getting-started/index.md rename to doc/6/essentials/getting-started/index.md diff --git a/doc/src/essentials/getting-started/node-js/index.md b/doc/6/essentials/getting-started/node-js/index.md similarity index 100% rename from doc/src/essentials/getting-started/node-js/index.md rename to doc/6/essentials/getting-started/node-js/index.md diff --git a/doc/src/essentials/getting-started/node-js/snippets/create.js b/doc/6/essentials/getting-started/node-js/snippets/create.js similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/create.js rename to doc/6/essentials/getting-started/node-js/snippets/create.js diff --git a/doc/src/essentials/getting-started/node-js/snippets/create.test.yml b/doc/6/essentials/getting-started/node-js/snippets/create.test.yml similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/create.test.yml rename to doc/6/essentials/getting-started/node-js/snippets/create.test.yml diff --git a/doc/src/essentials/getting-started/node-js/snippets/init.js b/doc/6/essentials/getting-started/node-js/snippets/init.js similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/init.js rename to doc/6/essentials/getting-started/node-js/snippets/init.js diff --git a/doc/src/essentials/getting-started/node-js/snippets/init.test.yml b/doc/6/essentials/getting-started/node-js/snippets/init.test.yml similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/init.test.yml rename to doc/6/essentials/getting-started/node-js/snippets/init.test.yml diff --git a/doc/src/essentials/getting-started/node-js/snippets/load-sdk.js b/doc/6/essentials/getting-started/node-js/snippets/load-sdk.js similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/load-sdk.js rename to doc/6/essentials/getting-started/node-js/snippets/load-sdk.js diff --git a/doc/src/essentials/getting-started/node-js/snippets/load-sdk.test.yml b/doc/6/essentials/getting-started/node-js/snippets/load-sdk.test.yml similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/load-sdk.test.yml rename to doc/6/essentials/getting-started/node-js/snippets/load-sdk.test.yml diff --git a/doc/src/essentials/getting-started/node-js/snippets/prepare-db.js b/doc/6/essentials/getting-started/node-js/snippets/prepare-db.js similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/prepare-db.js rename to doc/6/essentials/getting-started/node-js/snippets/prepare-db.js diff --git a/doc/src/essentials/getting-started/node-js/snippets/prepare-db.test.yml b/doc/6/essentials/getting-started/node-js/snippets/prepare-db.test.yml similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/prepare-db.test.yml rename to doc/6/essentials/getting-started/node-js/snippets/prepare-db.test.yml diff --git a/doc/src/essentials/getting-started/node-js/snippets/subscribe.js b/doc/6/essentials/getting-started/node-js/snippets/subscribe.js similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/subscribe.js rename to doc/6/essentials/getting-started/node-js/snippets/subscribe.js diff --git a/doc/src/essentials/getting-started/node-js/snippets/subscribe.test.yml b/doc/6/essentials/getting-started/node-js/snippets/subscribe.test.yml similarity index 100% rename from doc/src/essentials/getting-started/node-js/snippets/subscribe.test.yml rename to doc/6/essentials/getting-started/node-js/snippets/subscribe.test.yml diff --git a/doc/src/essentials/getting-started/raw-web/index.md b/doc/6/essentials/getting-started/raw-web/index.md similarity index 100% rename from doc/src/essentials/getting-started/raw-web/index.md rename to doc/6/essentials/getting-started/raw-web/index.md diff --git a/doc/src/essentials/getting-started/raw-web/snippets/create.html b/doc/6/essentials/getting-started/raw-web/snippets/create.html similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/create.html rename to doc/6/essentials/getting-started/raw-web/snippets/create.html diff --git a/doc/src/essentials/getting-started/raw-web/snippets/create.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/create.test.yml similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/create.test.yml rename to doc/6/essentials/getting-started/raw-web/snippets/create.test.yml diff --git a/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.html b/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.html similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/load-sdk.html rename to doc/6/essentials/getting-started/raw-web/snippets/load-sdk.html diff --git a/doc/src/essentials/getting-started/raw-web/snippets/load-sdk.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.test.yml similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/load-sdk.test.yml rename to doc/6/essentials/getting-started/raw-web/snippets/load-sdk.test.yml diff --git a/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.html b/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.html similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/prepare-db.html rename to doc/6/essentials/getting-started/raw-web/snippets/prepare-db.html diff --git a/doc/src/essentials/getting-started/raw-web/snippets/prepare-db.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.test.yml similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/prepare-db.test.yml rename to doc/6/essentials/getting-started/raw-web/snippets/prepare-db.test.yml diff --git a/doc/src/essentials/getting-started/raw-web/snippets/subscribe.html b/doc/6/essentials/getting-started/raw-web/snippets/subscribe.html similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/subscribe.html rename to doc/6/essentials/getting-started/raw-web/snippets/subscribe.html diff --git a/doc/src/essentials/getting-started/raw-web/snippets/subscribe.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/subscribe.test.yml similarity index 100% rename from doc/src/essentials/getting-started/raw-web/snippets/subscribe.test.yml rename to doc/6/essentials/getting-started/raw-web/snippets/subscribe.test.yml diff --git a/doc/src/essentials/getting-started/webpack/index.md b/doc/6/essentials/getting-started/webpack/index.md similarity index 100% rename from doc/src/essentials/getting-started/webpack/index.md rename to doc/6/essentials/getting-started/webpack/index.md diff --git a/doc/src/essentials/getting-started/webpack/snippets/create.js b/doc/6/essentials/getting-started/webpack/snippets/create.js similarity index 100% rename from doc/src/essentials/getting-started/webpack/snippets/create.js rename to doc/6/essentials/getting-started/webpack/snippets/create.js diff --git a/doc/src/essentials/getting-started/webpack/snippets/create.test.yml b/doc/6/essentials/getting-started/webpack/snippets/create.test.yml similarity index 100% rename from doc/src/essentials/getting-started/webpack/snippets/create.test.yml rename to doc/6/essentials/getting-started/webpack/snippets/create.test.yml diff --git a/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.js b/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.js similarity index 100% rename from doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.js rename to doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.js diff --git a/doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml b/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml similarity index 100% rename from doc/src/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml rename to doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml diff --git a/doc/src/essentials/getting-started/webpack/snippets/subscribe.js b/doc/6/essentials/getting-started/webpack/snippets/subscribe.js similarity index 100% rename from doc/src/essentials/getting-started/webpack/snippets/subscribe.js rename to doc/6/essentials/getting-started/webpack/snippets/subscribe.js diff --git a/doc/src/essentials/getting-started/webpack/snippets/subscribe.test.yml b/doc/6/essentials/getting-started/webpack/snippets/subscribe.test.yml similarity index 100% rename from doc/src/essentials/getting-started/webpack/snippets/subscribe.test.yml rename to doc/6/essentials/getting-started/webpack/snippets/subscribe.test.yml diff --git a/doc/src/essentials/index.md b/doc/6/essentials/index.md similarity index 100% rename from doc/src/essentials/index.md rename to doc/6/essentials/index.md diff --git a/doc/src/essentials/offline-tools/index.md b/doc/6/essentials/offline-tools/index.md similarity index 100% rename from doc/src/essentials/offline-tools/index.md rename to doc/6/essentials/offline-tools/index.md diff --git a/doc/src/essentials/realtime-notifications/index.md b/doc/6/essentials/realtime-notifications/index.md similarity index 100% rename from doc/src/essentials/realtime-notifications/index.md rename to doc/6/essentials/realtime-notifications/index.md diff --git a/doc/src/index.md b/doc/6/index.md similarity index 100% rename from doc/src/index.md rename to doc/6/index.md diff --git a/doc/src/protocols/http/constructor/index.md b/doc/6/protocols/http/constructor/index.md similarity index 100% rename from doc/src/protocols/http/constructor/index.md rename to doc/6/protocols/http/constructor/index.md diff --git a/doc/src/protocols/http/constructor/snippets/constructor.js b/doc/6/protocols/http/constructor/snippets/constructor.js similarity index 100% rename from doc/src/protocols/http/constructor/snippets/constructor.js rename to doc/6/protocols/http/constructor/snippets/constructor.js diff --git a/doc/src/protocols/http/constructor/snippets/constructor.test.yml b/doc/6/protocols/http/constructor/snippets/constructor.test.yml similarity index 100% rename from doc/src/protocols/http/constructor/snippets/constructor.test.yml rename to doc/6/protocols/http/constructor/snippets/constructor.test.yml diff --git a/doc/src/protocols/http/index.md b/doc/6/protocols/http/index.md similarity index 100% rename from doc/src/protocols/http/index.md rename to doc/6/protocols/http/index.md diff --git a/doc/src/protocols/http/introduction/index.md b/doc/6/protocols/http/introduction/index.md similarity index 100% rename from doc/src/protocols/http/introduction/index.md rename to doc/6/protocols/http/introduction/index.md diff --git a/doc/src/protocols/index.md b/doc/6/protocols/index.md similarity index 100% rename from doc/src/protocols/index.md rename to doc/6/protocols/index.md diff --git a/doc/src/protocols/socketio/constructor/index.md b/doc/6/protocols/socketio/constructor/index.md similarity index 100% rename from doc/src/protocols/socketio/constructor/index.md rename to doc/6/protocols/socketio/constructor/index.md diff --git a/doc/src/protocols/socketio/constructor/snippets/constructor.js b/doc/6/protocols/socketio/constructor/snippets/constructor.js similarity index 100% rename from doc/src/protocols/socketio/constructor/snippets/constructor.js rename to doc/6/protocols/socketio/constructor/snippets/constructor.js diff --git a/doc/src/protocols/socketio/constructor/snippets/constructor.test.yml b/doc/6/protocols/socketio/constructor/snippets/constructor.test.yml similarity index 100% rename from doc/src/protocols/socketio/constructor/snippets/constructor.test.yml rename to doc/6/protocols/socketio/constructor/snippets/constructor.test.yml diff --git a/doc/src/protocols/socketio/index.md b/doc/6/protocols/socketio/index.md similarity index 100% rename from doc/src/protocols/socketio/index.md rename to doc/6/protocols/socketio/index.md diff --git a/doc/src/protocols/socketio/introduction/index.md b/doc/6/protocols/socketio/introduction/index.md similarity index 100% rename from doc/src/protocols/socketio/introduction/index.md rename to doc/6/protocols/socketio/introduction/index.md diff --git a/doc/src/protocols/websocket/constructor/index.md b/doc/6/protocols/websocket/constructor/index.md similarity index 100% rename from doc/src/protocols/websocket/constructor/index.md rename to doc/6/protocols/websocket/constructor/index.md diff --git a/doc/src/protocols/websocket/constructor/snippets/constructor.js b/doc/6/protocols/websocket/constructor/snippets/constructor.js similarity index 100% rename from doc/src/protocols/websocket/constructor/snippets/constructor.js rename to doc/6/protocols/websocket/constructor/snippets/constructor.js diff --git a/doc/src/protocols/websocket/constructor/snippets/constructor.test.yml b/doc/6/protocols/websocket/constructor/snippets/constructor.test.yml similarity index 100% rename from doc/src/protocols/websocket/constructor/snippets/constructor.test.yml rename to doc/6/protocols/websocket/constructor/snippets/constructor.test.yml diff --git a/doc/src/protocols/websocket/index.md b/doc/6/protocols/websocket/index.md similarity index 100% rename from doc/src/protocols/websocket/index.md rename to doc/6/protocols/websocket/index.md diff --git a/doc/src/protocols/websocket/introduction/index.md b/doc/6/protocols/websocket/introduction/index.md similarity index 100% rename from doc/src/protocols/websocket/introduction/index.md rename to doc/6/protocols/websocket/introduction/index.md From 999491df90235d254c8c5b48e13b2d4d6bf59ae1 Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Wed, 12 Jun 2019 18:15:34 +0200 Subject: [PATCH 09/26] [move] Received v5 doc from main repo --- doc/5/.keep | 0 .../collection-mapping/apply/index.md | 43 +++++++ .../apply/snippets/apply-1.js | 9 ++ .../collection-mapping/constructor/index.md | 42 ++++++ .../constructor/snippets/constructor-1.js | 10 ++ .../core-classes/collection-mapping/index.md | 6 + .../collection-mapping/refresh/index.md | 37 ++++++ .../refresh/snippets/refresh-1.js | 9 ++ .../collection-mapping/set-headers/index.md | 31 +++++ .../set-headers/snippets/set-headers-1.js | 1 + .../collection-mapping/set/index.md | 33 +++++ .../collection-mapping/set/snippets/set-1.js | 1 + .../collection/collection-mapping/index.md | 28 ++++ .../snippets/collection-mapping-1.js | 6 + .../collection/constructor/index.md | 42 ++++++ .../constructor/snippets/constructor-1.js | 1 + doc/5/core-classes/collection/count/index.md | 48 +++++++ .../collection/count/snippets/count-1.js | 14 ++ .../collection/count/snippets/count-2.js | 2 + .../collection/create-document/index.md | 58 +++++++++ .../snippets/create-document-1.js | 16 +++ doc/5/core-classes/collection/create/index.md | 69 ++++++++++ .../collection/create/snippets/create-1.js | 35 +++++ .../collection/create/snippets/create-2.js | 14 ++ .../collection/delete-document/index.md | 66 ++++++++++ .../snippets/delete-document-1.js | 29 +++++ .../snippets/delete-document-2.js | 2 + .../collection/delete-specifications/index.md | 46 +++++++ .../snippets/delete-specifications-1.js | 14 ++ .../snippets/delete-specifications-2.js | 4 + .../core-classes/collection/document/index.md | 29 +++++ .../document/snippets/document-1.js | 4 + .../collection/fetch-document/index.md | 38 ++++++ .../snippets/fetch-document-1.js | 14 ++ .../collection/get-mapping/index.md | 37 ++++++ .../get-mapping/snippets/get-mapping-1.js | 14 ++ .../collection/get-specifications/index.md | 50 ++++++++ .../snippets/get-specifications-1.js | 14 ++ .../snippets/get-specifications-2.js | 15 +++ doc/5/core-classes/collection/index.md | 6 + .../collection/mcreate-document/index.md | 54 ++++++++ .../snippets/mcreate-document-1.js | 21 +++ .../snippets/mcreate-document-2.js | 8 ++ .../mcreate-or-replace-document/index.md | 54 ++++++++ .../snippets/mcreate-or-replace-document-1.js | 21 +++ .../snippets/mcreate-or-replace-document-2.js | 8 ++ .../collection/mdelete-document/index.md | 45 +++++++ .../snippets/mdelete-document-1.js | 16 +++ .../snippets/mdelete-document-2.js | 2 + .../collection/mget-document/index.md | 50 ++++++++ .../mget-document/snippets/mget-document-1.js | 16 +++ .../mget-document/snippets/mget-document-2.js | 8 ++ .../collection/mreplace-document/index.md | 54 ++++++++ .../snippets/mreplace-document-1.js | 21 +++ .../snippets/mreplace-document-2.js | 8 ++ .../collection/mupdate-document/index.md | 54 ++++++++ .../snippets/mupdate-document-1.js | 21 +++ .../snippets/mupdate-document-2.js | 8 ++ .../collection/publish-message/index.md | 55 ++++++++ .../snippets/publish-message-1.js | 3 + .../collection/replace-document/index.md | 47 +++++++ .../snippets/replace-document-1.js | 14 ++ doc/5/core-classes/collection/room/index.md | 32 +++++ .../collection/room/snippets/room-1.js | 6 + .../collection/scroll-specifications/index.md | 43 +++++++ .../snippets/scroll-specifications-1.js | 22 ++++ .../snippets/scroll-specifications-2.js | 8 ++ doc/5/core-classes/collection/scroll/index.md | 50 ++++++++ .../collection/scroll/snippets/scroll-1.js | 18 +++ .../collection/search-specifications/index.md | 45 +++++++ .../snippets/search-specifications-1.js | 33 +++++ .../snippets/search-specifications-2.js | 9 ++ doc/5/core-classes/collection/search/index.md | 59 +++++++++ .../collection/search/snippets/search-1.js | 61 +++++++++ .../collection/set-headers/index.md | 31 +++++ .../set-headers/snippets/set-headers-1.js | 6 + .../collection/subscribe/index.md | 50 ++++++++ .../subscribe/snippets/subscribe-1.js | 10 ++ .../core-classes/collection/truncate/index.md | 63 +++++++++ .../truncate/snippets/truncate-1.js | 16 +++ .../truncate/snippets/truncate-2.js | 13 ++ .../collection/update-document/index.md | 49 +++++++ .../snippets/update-document-1.js | 14 ++ .../collection/update-specifications/index.md | 60 +++++++++ .../snippets/update-specifications-1.js | 25 ++++ .../snippets/update-specifications-2.js | 15 +++ .../validate-specifications/index.md | 38 ++++++ .../snippets/validate-specifications-1.js | 25 ++++ .../document/constructor/index.md | 46 +++++++ .../constructor/snippets/constructor-1.js | 15 +++ doc/5/core-classes/document/delete/index.md | 39 ++++++ .../document/delete/snippets/delete-1.js | 9 ++ doc/5/core-classes/document/exists/index.md | 37 ++++++ .../document/exists/snippets/exists-1.js | 4 + doc/5/core-classes/document/index.md | 6 + doc/5/core-classes/document/publish/index.md | 37 ++++++ .../document/publish/snippets/publish-1.js | 1 + doc/5/core-classes/document/refresh/index.md | 37 ++++++ .../document/refresh/snippets/refresh-1.js | 9 ++ doc/5/core-classes/document/save/index.md | 48 +++++++ .../document/save/snippets/save-1.js | 9 ++ .../document/set-content/index.md | 36 ++++++ .../set-content/snippets/set-content-1.js | 1 + .../document/set-headers/index.md | 31 +++++ .../set-headers/snippets/set-headers-1.js | 1 + .../core-classes/document/subscribe/index.md | 41 ++++++ .../subscribe/snippets/subscribe-1.js | 15 +++ doc/5/core-classes/index.md | 7 + .../core-classes/kuzzle/add-listener/index.md | 29 +++++ .../add-listener/snippets/add-listener-1.js | 4 + .../core-classes/kuzzle/check-token/index.md | 54 ++++++++ .../check-token/snippets/check-token-1.js | 10 ++ .../check-token/snippets/check-token-2.js | 5 + .../check-token/snippets/check-token-3.js | 5 + doc/5/core-classes/kuzzle/collection/index.md | 33 +++++ .../collection/snippets/collection-1.js | 7 + doc/5/core-classes/kuzzle/connect/index.md | 27 ++++ .../kuzzle/connect/snippets/connect-1.js | 1 + .../core-classes/kuzzle/constructor/index.md | 95 ++++++++++++++ .../constructor/snippets/constructor-1.js | 11 ++ .../core-classes/kuzzle/create-index/index.md | 47 +++++++ .../create-index/snippets/create-index-1.js | 13 ++ .../create-index/snippets/create-index-2.js | 5 + .../kuzzle/create-my-credentials/index.md | 39 ++++++ .../snippets/create-my-credentials-1.js | 11 ++ .../kuzzle/delete-my-credentials/index.md | 38 ++++++ .../snippets/delete-my-credentials-1.js | 11 ++ doc/5/core-classes/kuzzle/disconnect/index.md | 16 +++ .../disconnect/snippets/disconnect-1.js | 1 + .../core-classes/kuzzle/flush-queue/index.md | 20 +++ .../flush-queue/snippets/flush-queue-1.js | 1 + .../kuzzle/get-all-statistics/index.md | 66 ++++++++++ .../snippets/get-all-statistics-1.js | 15 +++ .../snippets/get-all-statistics-2.js | 16 +++ .../kuzzle/get-auto-refresh/index.md | 52 ++++++++ .../snippets/get-auto-refresh-1.js | 11 ++ .../kuzzle/get-jwt-token/index.md | 20 +++ .../get-jwt-token/snippets/get-jwt-token-1.js | 1 + .../kuzzle/get-my-credentials/index.md | 47 +++++++ .../snippets/get-my-credentials-1.js | 11 ++ .../snippets/get-my-credentials-2.js | 5 + .../kuzzle/get-my-rights/index.md | 58 +++++++++ .../get-my-rights/snippets/get-my-rights-1.js | 12 ++ .../get-my-rights/snippets/get-my-rights-2.js | 17 +++ .../kuzzle/get-server-info/index.md | 120 ++++++++++++++++++ .../snippets/get-server-info-1.js | 10 ++ .../snippets/get-server-info-2.js | 79 ++++++++++++ .../kuzzle/get-statistics/index.md | 59 +++++++++ .../snippets/get-statistics-1.js | 9 ++ .../snippets/get-statistics-2.js | 14 ++ .../snippets/get-statistics-3.js | 15 +++ .../snippets/get-statistics-4.js | 24 ++++ doc/5/core-classes/kuzzle/index.md | 7 + .../kuzzle/list-collections/index.md | 58 +++++++++ .../snippets/list-collections-1.js | 11 ++ .../snippets/list-collections-2.js | 11 ++ .../core-classes/kuzzle/list-indexes/index.md | 43 +++++++ .../list-indexes/snippets/list-indexes-1.js | 11 ++ .../list-indexes/snippets/list-indexes-2.js | 2 + doc/5/core-classes/kuzzle/login/index.md | 49 +++++++ .../kuzzle/login/snippets/login-1.js | 14 ++ doc/5/core-classes/kuzzle/logout/index.md | 41 ++++++ .../kuzzle/logout/snippets/logout-1.js | 10 ++ .../kuzzle/memory-storage/index.md | 10 ++ doc/5/core-classes/kuzzle/now/index.md | 43 +++++++ .../core-classes/kuzzle/now/snippets/now-1.js | 9 ++ .../core-classes/kuzzle/now/snippets/now-2.js | 2 + doc/5/core-classes/kuzzle/query/index.md | 82 ++++++++++++ .../kuzzle/query/snippets/query-1.js | 23 ++++ .../kuzzle/query/snippets/query-2.js | 9 ++ .../kuzzle/refresh-index/index.md | 58 +++++++++ .../refresh-index/snippets/refresh-index-1.js | 1 + .../kuzzle/remove-all-listeners/index.md | 28 ++++ .../snippets/remove-all-listeners-1.js | 5 + .../kuzzle/remove-listener/index.md | 29 +++++ .../snippets/remove-listener-1.js | 1 + .../core-classes/kuzzle/replay-queue/index.md | 20 +++ .../replay-queue/snippets/replay-queue-1.js | 1 + doc/5/core-classes/kuzzle/security/index.md | 10 ++ .../kuzzle/set-auto-refresh/index.md | 59 +++++++++ .../snippets/set-auto-refresh-1.js | 1 + .../kuzzle/set-default-index/index.md | 20 +++ .../snippets/set-default-index-1.js | 1 + .../core-classes/kuzzle/set-headers/index.md | 31 +++++ .../set-headers/snippets/set-headers-1.js | 1 + .../kuzzle/set-jwt-token/index.md | 42 ++++++ .../set-jwt-token/snippets/set-jwt-token-1.js | 9 ++ .../kuzzle/start-queuing/index.md | 20 +++ .../start-queuing/snippets/start-queuing-1.js | 1 + .../core-classes/kuzzle/stop-queuing/index.md | 20 +++ .../stop-queuing/snippets/stop-queuing-1.js | 1 + .../kuzzle/unset-jwt-token/index.md | 20 +++ .../snippets/unset-jwt-token-1.js | 1 + .../kuzzle/update-my-credentials/index.md | 39 ++++++ .../snippets/update-my-credentials-1.js | 11 ++ .../core-classes/kuzzle/update-self/index.md | 44 +++++++ .../update-self/snippets/update-self-1.js | 18 +++ .../kuzzle/validate-my-credentials/index.md | 39 ++++++ .../snippets/validate-my-credentials-1.js | 11 ++ doc/5/core-classes/kuzzle/who-am-i/index.md | 28 ++++ .../kuzzle/who-am-i/snippets/who-am-i-1.js | 10 ++ .../memory-storage/append/index.md | 53 ++++++++ .../append/snippets/append-1.js | 10 ++ .../append/snippets/append-2.js | 2 + .../memory-storage/bitcount/index.md | 48 +++++++ .../bitcount/snippets/bitcount-1.js | 10 ++ .../bitcount/snippets/bitcount-2.js | 2 + .../memory-storage/bitop/index.md | 54 ++++++++ .../memory-storage/bitop/snippets/bitop-1.js | 10 ++ .../memory-storage/bitop/snippets/bitop-2.js | 2 + .../memory-storage/bitpos/index.md | 49 +++++++ .../bitpos/snippets/bitpos-1.js | 10 ++ .../bitpos/snippets/bitpos-2.js | 2 + .../memory-storage/constructor/index.md | 24 ++++ .../constructor/snippets/constructor-1.js | 5 + .../memory-storage/dbsize/index.md | 45 +++++++ .../dbsize/snippets/dbsize-1.js | 10 ++ .../dbsize/snippets/dbsize-2.js | 2 + .../core-classes/memory-storage/decr/index.md | 52 ++++++++ .../memory-storage/decr/snippets/decr-1.js | 10 ++ .../memory-storage/decr/snippets/decr-2.js | 2 + .../memory-storage/decrby/index.md | 53 ++++++++ .../decrby/snippets/decrby-1.js | 10 ++ .../decrby/snippets/decrby-2.js | 2 + .../core-classes/memory-storage/del/index.md | 52 ++++++++ .../memory-storage/del/snippets/del-1.js | 10 ++ .../memory-storage/del/snippets/del-2.js | 2 + .../memory-storage/exists/index.md | 46 +++++++ .../exists/snippets/exists-1.js | 10 ++ .../exists/snippets/exists-2.js | 2 + .../memory-storage/expire/index.md | 53 ++++++++ .../expire/snippets/expire-1.js | 10 ++ .../expire/snippets/expire-2.js | 2 + .../memory-storage/expireat/index.md | 54 ++++++++ .../expireat/snippets/expireat-1.js | 10 ++ .../expireat/snippets/expireat-2.js | 2 + .../memory-storage/flushdb/index.md | 45 +++++++ .../flushdb/snippets/flushdb-1.js | 10 ++ .../memory-storage/geoadd/index.md | 53 ++++++++ .../geoadd/snippets/geoadd-1.js | 23 ++++ .../geoadd/snippets/geoadd-2.js | 2 + .../memory-storage/geodist/index.md | 50 ++++++++ .../geodist/snippets/geodist-1.js | 10 ++ .../geodist/snippets/geodist-2.js | 2 + .../memory-storage/geohash/index.md | 47 +++++++ .../geohash/snippets/geohash-1.js | 10 ++ .../geohash/snippets/geohash-2.js | 2 + .../memory-storage/geopos/index.md | 47 +++++++ .../geopos/snippets/geopos-1.js | 10 ++ .../geopos/snippets/geopos-2.js | 2 + .../memory-storage/georadius/index.md | 72 +++++++++++ .../georadius/snippets/georadius-1.js | 10 ++ .../georadius/snippets/georadius-2.js | 5 + .../georadius/snippets/georadius-3.js | 5 + .../georadius/snippets/georadius-4.js | 5 + .../memory-storage/georadiusbymember/index.md | 70 ++++++++++ .../snippets/georadiusbymember-1.js | 10 ++ .../snippets/georadiusbymember-2.js | 5 + .../snippets/georadiusbymember-3.js | 5 + .../snippets/georadiusbymember-4.js | 5 + .../core-classes/memory-storage/get/index.md | 46 +++++++ .../memory-storage/get/snippets/get-1.js | 10 ++ .../memory-storage/get/snippets/get-2.js | 2 + .../memory-storage/getbit/index.md | 47 +++++++ .../getbit/snippets/getbit-1.js | 10 ++ .../getbit/snippets/getbit-2.js | 2 + .../memory-storage/getrange/index.md | 48 +++++++ .../getrange/snippets/getrange-1.js | 10 ++ .../getrange/snippets/getrange-2.js | 2 + .../memory-storage/getset/index.md | 53 ++++++++ .../getset/snippets/getset-1.js | 10 ++ .../getset/snippets/getset-2.js | 2 + .../core-classes/memory-storage/hdel/index.md | 53 ++++++++ .../memory-storage/hdel/snippets/hdel-1.js | 10 ++ .../memory-storage/hdel/snippets/hdel-2.js | 2 + .../memory-storage/hexists/index.md | 47 +++++++ .../hexists/snippets/hexists-1.js | 10 ++ .../hexists/snippets/hexists-2.js | 2 + .../core-classes/memory-storage/hget/index.md | 47 +++++++ .../memory-storage/hget/snippets/hget-1.js | 10 ++ .../memory-storage/hget/snippets/hget-2.js | 2 + .../memory-storage/hgetall/index.md | 50 ++++++++ .../hgetall/snippets/hgetall-1.js | 10 ++ .../hgetall/snippets/hgetall-2.js | 6 + .../memory-storage/hincrby/index.md | 54 ++++++++ .../hincrby/snippets/hincrby-1.js | 10 ++ .../hincrby/snippets/hincrby-2.js | 2 + .../memory-storage/hincrbyfloat/index.md | 54 ++++++++ .../hincrbyfloat/snippets/hincrbyfloat-1.js | 10 ++ .../hincrbyfloat/snippets/hincrbyfloat-2.js | 2 + .../memory-storage/hkeys/index.md | 46 +++++++ .../memory-storage/hkeys/snippets/hkeys-1.js | 10 ++ .../memory-storage/hkeys/snippets/hkeys-2.js | 6 + .../core-classes/memory-storage/hlen/index.md | 46 +++++++ .../memory-storage/hlen/snippets/hlen-1.js | 10 ++ .../memory-storage/hlen/snippets/hlen-2.js | 2 + .../memory-storage/hmget/index.md | 47 +++++++ .../memory-storage/hmget/snippets/hmget-1.js | 10 ++ .../memory-storage/hmget/snippets/hmget-2.js | 6 + .../memory-storage/hmset/index.md | 47 +++++++ .../memory-storage/hmset/snippets/hmset-1.js | 16 +++ .../memory-storage/hscan/index.md | 55 ++++++++ .../memory-storage/hscan/snippets/hscan-1.js | 10 ++ .../memory-storage/hscan/snippets/hscan-2.js | 10 ++ .../core-classes/memory-storage/hset/index.md | 54 ++++++++ .../memory-storage/hset/snippets/hset-1.js | 10 ++ .../memory-storage/hset/snippets/hset-2.js | 2 + .../memory-storage/hsetnx/index.md | 54 ++++++++ .../hsetnx/snippets/hsetnx-1.js | 10 ++ .../hsetnx/snippets/hsetnx-2.js | 2 + .../memory-storage/hstrlen/index.md | 47 +++++++ .../hstrlen/snippets/hstrlen-1.js | 10 ++ .../hstrlen/snippets/hstrlen-2.js | 2 + .../memory-storage/hvals/index.md | 46 +++++++ .../memory-storage/hvals/snippets/hvals-1.js | 10 ++ .../memory-storage/hvals/snippets/hvals-2.js | 6 + .../core-classes/memory-storage/incr/index.md | 52 ++++++++ .../memory-storage/incr/snippets/incr-1.js | 10 ++ .../memory-storage/incr/snippets/incr-2.js | 2 + .../memory-storage/incrby/index.md | 53 ++++++++ .../incrby/snippets/incrby-1.js | 10 ++ .../incrby/snippets/incrby-2.js | 2 + .../memory-storage/incrbyfloat/index.md | 53 ++++++++ .../incrbyfloat/snippets/incrbyfloat-1.js | 10 ++ .../incrbyfloat/snippets/incrbyfloat-2.js | 2 + doc/5/core-classes/memory-storage/index.md | 6 + .../core-classes/memory-storage/keys/index.md | 46 +++++++ .../memory-storage/keys/snippets/keys-1.js | 10 ++ .../memory-storage/keys/snippets/keys-2.js | 6 + .../memory-storage/lindex/index.md | 47 +++++++ .../lindex/snippets/lindex-1.js | 10 ++ .../lindex/snippets/lindex-2.js | 2 + .../memory-storage/linsert/index.md | 55 ++++++++ .../linsert/snippets/linsert-1.js | 10 ++ .../linsert/snippets/linsert-2.js | 2 + .../core-classes/memory-storage/llen/index.md | 46 +++++++ .../memory-storage/llen/snippets/llen-1.js | 10 ++ .../memory-storage/llen/snippets/llen-2.js | 2 + .../core-classes/memory-storage/lpop/index.md | 52 ++++++++ .../memory-storage/lpop/snippets/lpop-1.js | 10 ++ .../memory-storage/lpop/snippets/lpop-2.js | 2 + .../memory-storage/lpush/index.md | 51 ++++++++ .../memory-storage/lpush/snippets/lpush-1.js | 10 ++ .../memory-storage/lpush/snippets/lpush-2.js | 2 + .../memory-storage/lpushx/index.md | 53 ++++++++ .../lpushx/snippets/lpushx-1.js | 10 ++ .../lpushx/snippets/lpushx-2.js | 2 + .../memory-storage/lrange/index.md | 48 +++++++ .../lrange/snippets/lrange-1.js | 10 ++ .../lrange/snippets/lrange-2.js | 5 + .../core-classes/memory-storage/lrem/index.md | 54 ++++++++ .../memory-storage/lrem/snippets/lrem-1.js | 10 ++ .../memory-storage/lrem/snippets/lrem-2.js | 2 + .../core-classes/memory-storage/lset/index.md | 48 +++++++ .../memory-storage/lset/snippets/lset-1.js | 10 ++ .../memory-storage/ltrim/index.md | 48 +++++++ .../memory-storage/ltrim/snippets/ltrim-1.js | 10 ++ .../core-classes/memory-storage/mget/index.md | 46 +++++++ .../memory-storage/mget/snippets/mget-1.js | 10 ++ .../memory-storage/mget/snippets/mget-2.js | 6 + .../core-classes/memory-storage/mset/index.md | 46 +++++++ .../memory-storage/mset/snippets/mset-1.js | 16 +++ .../memory-storage/msetnx/index.md | 52 ++++++++ .../msetnx/snippets/msetnx-1.js | 16 +++ .../msetnx/snippets/msetnx-2.js | 2 + .../memory-storage/object/index.md | 47 +++++++ .../object/snippets/object-1.js | 10 ++ .../object/snippets/object-2.js | 2 + .../memory-storage/persist/index.md | 50 ++++++++ .../persist/snippets/persist-1.js | 10 ++ .../persist/snippets/persist-2.js | 2 + .../memory-storage/pexpire/index.md | 53 ++++++++ .../pexpire/snippets/pexpire-1.js | 10 ++ .../pexpire/snippets/pexpire-2.js | 2 + .../memory-storage/pexpireat/index.md | 54 ++++++++ .../pexpireat/snippets/pexpireat-1.js | 10 ++ .../pexpireat/snippets/pexpireat-2.js | 2 + .../memory-storage/pfadd/index.md | 53 ++++++++ .../memory-storage/pfadd/snippets/pfadd-1.js | 10 ++ .../memory-storage/pfadd/snippets/pfadd-2.js | 2 + .../memory-storage/pfcount/index.md | 46 +++++++ .../pfcount/snippets/pfcount-1.js | 10 ++ .../pfcount/snippets/pfcount-2.js | 2 + .../memory-storage/pfmerge/index.md | 41 ++++++ .../pfmerge/snippets/pfmerge-1.js | 10 ++ .../core-classes/memory-storage/ping/index.md | 45 +++++++ .../memory-storage/ping/snippets/ping-1.js | 10 ++ .../memory-storage/ping/snippets/ping-2.js | 2 + .../memory-storage/psetex/index.md | 48 +++++++ .../psetex/snippets/psetex-1.js | 10 ++ .../core-classes/memory-storage/pttl/index.md | 46 +++++++ .../memory-storage/pttl/snippets/pttl-1.js | 10 ++ .../memory-storage/pttl/snippets/pttl-2.js | 2 + .../memory-storage/randomkey/index.md | 45 +++++++ .../randomkey/snippets/randomkey-1.js | 10 ++ .../randomkey/snippets/randomkey-2.js | 2 + .../memory-storage/rename/index.md | 47 +++++++ .../rename/snippets/rename-1.js | 10 ++ .../memory-storage/renamenx/index.md | 53 ++++++++ .../renamenx/snippets/renamenx-1.js | 10 ++ .../renamenx/snippets/renamenx-2.js | 2 + .../core-classes/memory-storage/rpop/index.md | 50 ++++++++ .../memory-storage/rpop/snippets/rpop-1.js | 10 ++ .../memory-storage/rpop/snippets/rpop-2.js | 2 + .../memory-storage/rpoplpush/index.md | 53 ++++++++ .../rpoplpush/snippets/rpoplpush-1.js | 10 ++ .../rpoplpush/snippets/rpoplpush-2.js | 2 + .../memory-storage/rpush/index.md | 53 ++++++++ .../memory-storage/rpush/snippets/rpush-1.js | 10 ++ .../memory-storage/rpush/snippets/rpush-2.js | 2 + .../memory-storage/rpushx/index.md | 53 ++++++++ .../rpushx/snippets/rpushx-1.js | 10 ++ .../rpushx/snippets/rpushx-2.js | 2 + .../core-classes/memory-storage/sadd/index.md | 53 ++++++++ .../memory-storage/sadd/snippets/sadd-1.js | 10 ++ .../memory-storage/sadd/snippets/sadd-2.js | 2 + .../core-classes/memory-storage/scan/index.md | 58 +++++++++ .../memory-storage/scan/snippets/scan-1.js | 10 ++ .../memory-storage/scan/snippets/scan-2.js | 9 ++ .../memory-storage/scard/index.md | 46 +++++++ .../memory-storage/scard/snippets/scard-1.js | 10 ++ .../memory-storage/scard/snippets/scard-2.js | 2 + .../memory-storage/sdiff/index.md | 53 ++++++++ .../memory-storage/sdiff/snippets/sdiff-1.js | 10 ++ .../memory-storage/sdiff/snippets/sdiff-2.js | 6 + .../memory-storage/sdiffstore/index.md | 56 ++++++++ .../sdiffstore/snippets/sdiffstore-1.js | 10 ++ .../sdiffstore/snippets/sdiffstore-2.js | 2 + .../core-classes/memory-storage/set/index.md | 51 ++++++++ .../memory-storage/set/snippets/set-1.js | 10 ++ .../memory-storage/setex/index.md | 48 +++++++ .../memory-storage/setex/snippets/setex-1.js | 10 ++ .../memory-storage/setnx/index.md | 53 ++++++++ .../memory-storage/setnx/snippets/setnx-1.js | 10 ++ .../memory-storage/setnx/snippets/setnx-2.js | 2 + .../memory-storage/sinter/index.md | 46 +++++++ .../sinter/snippets/sinter-1.js | 10 ++ .../sinter/snippets/sinter-2.js | 6 + .../memory-storage/sinterstore/index.md | 55 ++++++++ .../sinterstore/snippets/sinterstore-1.js | 10 ++ .../sinterstore/snippets/sinterstore-2.js | 2 + .../memory-storage/sismember/index.md | 47 +++++++ .../sismember/snippets/sismember-1.js | 10 ++ .../sismember/snippets/sismember-2.js | 2 + .../memory-storage/smembers/index.md | 52 ++++++++ .../smembers/snippets/smembers-1.js | 10 ++ .../smembers/snippets/smembers-2.js | 6 + .../memory-storage/smove/index.md | 54 ++++++++ .../memory-storage/smove/snippets/smove-1.js | 10 ++ .../memory-storage/smove/snippets/smove-2.js | 2 + .../core-classes/memory-storage/sort/index.md | 52 ++++++++ .../memory-storage/sort/snippets/sort-1.js | 10 ++ .../memory-storage/sort/snippets/sort-2.js | 6 + .../core-classes/memory-storage/spop/index.md | 53 ++++++++ .../memory-storage/spop/snippets/spop-1.js | 10 ++ .../memory-storage/spop/snippets/spop-2.js | 2 + .../memory-storage/srandmember/index.md | 48 +++++++ .../srandmember/snippets/srandmember-1.js | 10 ++ .../srandmember/snippets/srandmember-2.js | 6 + .../core-classes/memory-storage/srem/index.md | 53 ++++++++ .../memory-storage/srem/snippets/srem-1.js | 10 ++ .../memory-storage/srem/snippets/srem-2.js | 2 + .../memory-storage/sscan/index.md | 55 ++++++++ .../memory-storage/sscan/snippets/sscan-1.js | 10 ++ .../memory-storage/sscan/snippets/sscan-2.js | 9 ++ .../memory-storage/strlen/index.md | 46 +++++++ .../strlen/snippets/strlen-1.js | 10 ++ .../strlen/snippets/strlen-2.js | 2 + .../memory-storage/sunion/index.md | 46 +++++++ .../sunion/snippets/sunion-1.js | 10 ++ .../sunion/snippets/sunion-2.js | 6 + .../memory-storage/sunionstore/index.md | 49 +++++++ .../sunionstore/snippets/sunionstore-1.js | 10 ++ .../sunionstore/snippets/sunionstore-2.js | 2 + .../core-classes/memory-storage/time/index.md | 48 +++++++ .../memory-storage/time/snippets/time-1.js | 10 ++ .../memory-storage/time/snippets/time-2.js | 5 + .../memory-storage/touch/index.md | 52 ++++++++ .../memory-storage/touch/snippets/touch-1.js | 10 ++ .../memory-storage/touch/snippets/touch-2.js | 2 + .../core-classes/memory-storage/ttl/index.md | 46 +++++++ .../memory-storage/ttl/snippets/ttl-1.js | 10 ++ .../memory-storage/ttl/snippets/ttl-2.js | 2 + .../core-classes/memory-storage/type/index.md | 46 +++++++ .../memory-storage/type/snippets/type-1.js | 10 ++ .../memory-storage/type/snippets/type-2.js | 2 + .../core-classes/memory-storage/zadd/index.md | 61 +++++++++ .../memory-storage/zadd/snippets/zadd-1.js | 16 +++ .../memory-storage/zadd/snippets/zadd-2.js | 2 + .../memory-storage/zcard/index.md | 46 +++++++ .../memory-storage/zcard/snippets/zcard-1.js | 10 ++ .../memory-storage/zcard/snippets/zcard-2.js | 2 + .../memory-storage/zcount/index.md | 50 ++++++++ .../zcount/snippets/zcount-1.js | 10 ++ .../zcount/snippets/zcount-2.js | 2 + .../memory-storage/zincrby/index.md | 54 ++++++++ .../zincrby/snippets/zincrby-1.js | 10 ++ .../zincrby/snippets/zincrby-2.js | 2 + .../memory-storage/zinterstore/index.md | 51 ++++++++ .../zinterstore/snippets/zinterstore-1.js | 10 ++ .../zinterstore/snippets/zinterstore-2.js | 2 + .../memory-storage/zlexcount/index.md | 48 +++++++ .../zlexcount/snippets/zlexcount-1.js | 10 ++ .../zlexcount/snippets/zlexcount-2.js | 2 + .../memory-storage/zrange/index.md | 62 +++++++++ .../zrange/snippets/zrange-1.js | 10 ++ .../zrange/snippets/zrange-2.js | 6 + .../memory-storage/zrangebylex/index.md | 55 ++++++++ .../zrangebylex/snippets/zrangebylex-1.js | 10 ++ .../zrangebylex/snippets/zrangebylex-2.js | 6 + .../memory-storage/zrangebyscore/index.md | 59 +++++++++ .../zrangebyscore/snippets/zrangebyscore-1.js | 10 ++ .../zrangebyscore/snippets/zrangebyscore-2.js | 6 + .../memory-storage/zrank/index.md | 47 +++++++ .../memory-storage/zrank/snippets/zrank-1.js | 10 ++ .../memory-storage/zrank/snippets/zrank-2.js | 2 + .../core-classes/memory-storage/zrem/index.md | 53 ++++++++ .../memory-storage/zrem/snippets/zrem-1.js | 10 ++ .../memory-storage/zrem/snippets/zrem-2.js | 2 + .../memory-storage/zremrangebylex/index.md | 54 ++++++++ .../snippets/zremrangebylex-1.js | 10 ++ .../snippets/zremrangebylex-2.js | 2 + .../memory-storage/zremrangebyrank/index.md | 56 ++++++++ .../snippets/zremrangebyrank-1.js | 10 ++ .../snippets/zremrangebyrank-2.js | 2 + .../memory-storage/zremrangebyscore/index.md | 54 ++++++++ .../snippets/zremrangebyscore-1.js | 10 ++ .../snippets/zremrangebyscore-2.js | 2 + .../memory-storage/zrevrange/index.md | 61 +++++++++ .../zrevrange/snippets/zrevrange-1.js | 10 ++ .../zrevrange/snippets/zrevrange-2.js | 6 + .../memory-storage/zrevrangebylex/index.md | 55 ++++++++ .../snippets/zrevrangebylex-1.js | 10 ++ .../snippets/zrevrangebylex-2.js | 6 + .../memory-storage/zrevrangebyscore/index.md | 59 +++++++++ .../snippets/zrevrangebyscore-1.js | 10 ++ .../snippets/zrevrangebyscore-2.js | 6 + .../memory-storage/zrevrank/index.md | 47 +++++++ .../zrevrank/snippets/zrevrank-1.js | 10 ++ .../zrevrank/snippets/zrevrank-2.js | 2 + .../memory-storage/zscan/index.md | 55 ++++++++ .../memory-storage/zscan/snippets/zscan-1.js | 10 ++ .../memory-storage/zscan/snippets/zscan-2.js | 11 ++ .../memory-storage/zscore/index.md | 47 +++++++ .../zscore/snippets/zscore-1.js | 10 ++ .../zscore/snippets/zscore-2.js | 2 + .../memory-storage/zunionstore/index.md | 51 ++++++++ .../zunionstore/snippets/zunionstore-1.js | 10 ++ .../zunionstore/snippets/zunionstore-2.js | 2 + .../core-classes/profile/add-policy/index.md | 40 ++++++ .../add-policy/snippets/add-policy-1.js | 4 + .../core-classes/profile/constructor/index.md | 44 +++++++ .../constructor/snippets/constructor-1.js | 12 ++ doc/5/core-classes/profile/delete/index.md | 37 ++++++ .../profile/delete/snippets/delete-1.js | 12 ++ .../profile/get-policies/index.md | 44 +++++++ .../get-policies/snippets/get-policies-1.js | 3 + .../get-policies/snippets/get-policies-2.js | 20 +++ doc/5/core-classes/profile/index.md | 6 + doc/5/core-classes/profile/save/index.md | 47 +++++++ .../profile/save/snippets/save-1.js | 21 +++ .../core-classes/profile/set-content/index.md | 32 +++++ .../set-content/snippets/set-content-1.js | 9 ++ .../profile/set-policies/index.md | 40 ++++++ .../set-policies/snippets/set-policies-1.js | 4 + doc/5/core-classes/profile/update/index.md | 44 +++++++ .../profile/update/snippets/update-1.js | 17 +++ doc/5/core-classes/role/constructor/index.md | 44 +++++++ .../constructor/snippets/constructor-1.js | 15 +++ doc/5/core-classes/role/delete/index.md | 37 ++++++ .../role/delete/snippets/delete-1.js | 10 ++ doc/5/core-classes/role/index.md | 6 + doc/5/core-classes/role/save/index.md | 43 +++++++ .../core-classes/role/save/snippets/save-1.js | 12 ++ doc/5/core-classes/role/set-content/index.md | 32 +++++ .../set-content/snippets/set-content-1.js | 11 ++ doc/5/core-classes/role/update/index.md | 56 ++++++++ .../role/update/snippets/update-1.js | 21 +++ doc/5/core-classes/room/constructor/index.md | 55 ++++++++ .../constructor/snippets/constructor-1.js | 12 ++ doc/5/core-classes/room/count/index.md | 34 +++++ .../room/count/snippets/count-1.js | 9 ++ .../room/count/snippets/count-2.js | 2 + doc/5/core-classes/room/index.md | 6 + doc/5/core-classes/room/renew/index.md | 26 ++++ .../room/renew/snippets/renew-1.js | 8 ++ doc/5/core-classes/room/set-headers/index.md | 33 +++++ .../set-headers/snippets/set-headers-1.js | 1 + doc/5/core-classes/room/unsubscribe/index.md | 20 +++ .../unsubscribe/snippets/unsubscribe-1.js | 1 + .../search-result/constructor/index.md | 27 ++++ .../search-result/fetch-next/index.md | 36 ++++++ .../fetch-next/snippets/fetch-next-1.js | 12 ++ .../fetch-next/snippets/fetch-next-2.js | 22 ++++ doc/5/core-classes/search-result/index.md | 6 + .../security/constructor/index.md | 25 ++++ .../constructor/snippets/constructor-1.js | 5 + .../security/create-credentials/index.md | 49 +++++++ .../snippets/create-credentials-1.js | 12 ++ .../snippets/create-credentials-2.js | 5 + .../security/create-profile/index.md | 46 +++++++ .../snippets/create-profile-1.js | 30 +++++ .../security/create-restricted-user/index.md | 46 +++++++ .../snippets/create-restricted-user-1.js | 27 ++++ .../security/create-role/index.md | 45 +++++++ .../create-role/snippets/create-role-1.js | 29 +++++ .../security/create-user/index.md | 54 ++++++++ .../create-user/snippets/create-user-1.js | 37 ++++++ .../security/delete-credentials/index.md | 47 +++++++ .../snippets/delete-credentials-1.js | 12 ++ .../snippets/delete-credentials-2.js | 4 + .../security/delete-profile/index.md | 56 ++++++++ .../snippets/delete-profile-1.js | 14 ++ .../snippets/delete-profile-2.js | 2 + .../security/delete-role/index.md | 56 ++++++++ .../delete-role/snippets/delete-role-1.js | 14 ++ .../delete-role/snippets/delete-role-2.js | 2 + .../security/delete-user/index.md | 56 ++++++++ .../delete-user/snippets/delete-user-1.js | 14 ++ .../delete-user/snippets/delete-user-2.js | 2 + .../security/fetch-profile/index.md | 38 ++++++ .../fetch-profile/snippets/fetch-profile-1.js | 14 ++ .../core-classes/security/fetch-role/index.md | 38 ++++++ .../fetch-role/snippets/fetch-role-1.js | 14 ++ .../core-classes/security/fetch-user/index.md | 38 ++++++ .../fetch-user/snippets/fetch-user-1.js | 14 ++ .../get-all-credential-fields/index.md | 45 +++++++ .../snippets/get-all-credential-fields-1.js | 12 ++ .../snippets/get-all-credential-fields-2.js | 7 + .../security/get-credentials-fields/index.md | 44 +++++++ .../snippets/get-credentials-fields-1.js | 12 ++ .../snippets/get-credentials-fields-2.js | 5 + .../security/get-credentials/index.md | 48 +++++++ .../snippets/get-credentials-1.js | 12 ++ .../snippets/get-credentials-2.js | 5 + .../security/get-user-rights/index.md | 59 +++++++++ .../snippets/get-user-rights-1.js | 14 ++ .../snippets/get-user-rights-2.js | 17 +++ .../security/has-credentials/index.md | 39 ++++++ .../snippets/has-credentials-1.js | 12 ++ doc/5/core-classes/security/index.md | 6 + .../security/is-action-allowed/index.md | 42 ++++++ .../snippets/is-action-allowed-1.js | 6 + doc/5/core-classes/security/profile/index.md | 29 +++++ .../security/profile/snippets/profile-1.js | 8 ++ .../security/replace-user/index.md | 46 +++++++ .../replace-user/snippets/replace-user-1.js | 13 ++ doc/5/core-classes/security/role/index.md | 29 +++++ .../security/role/snippets/role-1.js | 11 ++ .../security/scroll-profiles/index.md | 38 ++++++ .../snippets/scroll-profiles-1.js | 6 + .../security/scroll-users/index.md | 38 ++++++ .../scroll-users/snippets/scroll-users-1.js | 6 + .../security/search-profiles/index.md | 62 +++++++++ .../snippets/search-profiles-1.js | 36 ++++++ .../snippets/search-profiles-2.js | 9 ++ .../security/search-roles/index.md | 59 +++++++++ .../search-roles/snippets/search-roles-1.js | 34 +++++ .../search-roles/snippets/search-roles-2.js | 7 + .../security/search-users/index.md | 58 +++++++++ .../search-users/snippets/search-users-1.js | 52 ++++++++ .../search-users/snippets/search-users-2.js | 9 ++ .../security/update-credentials/index.md | 49 +++++++ .../snippets/update-credentials-1.js | 12 ++ .../snippets/update-credentials-2.js | 5 + .../security/update-profile/index.md | 46 +++++++ .../snippets/update-profile-1.js | 25 ++++ .../security/update-role/index.md | 46 +++++++ .../update-role/snippets/update-role-1.js | 24 ++++ .../security/update-user/index.md | 46 +++++++ .../update-user/snippets/update-user-1.js | 20 +++ doc/5/core-classes/security/user/index.md | 29 +++++ .../security/user/snippets/user-1.js | 13 ++ .../security/validate-credentials/index.md | 48 +++++++ .../snippets/validate-credentials-1.js | 12 ++ .../snippets/validate-credentials-2.js | 2 + doc/5/core-classes/user/add-profile/index.md | 40 ++++++ .../add-profile/snippets/add-profile-1.js | 7 + doc/5/core-classes/user/constructor/index.md | 42 ++++++ .../constructor/snippets/constructor-1.js | 17 +++ doc/5/core-classes/user/create/index.md | 43 +++++++ .../user/create/snippets/create-1.js | 12 ++ doc/5/core-classes/user/delete/index.md | 37 ++++++ .../user/delete/snippets/delete-1.js | 12 ++ .../core-classes/user/get-profileids/index.md | 20 +++ .../snippets/get-profileids-1.js | 3 + doc/5/core-classes/user/get-profiles/index.md | 37 ++++++ .../get-profiles/snippets/get-profiles-1.js | 12 ++ doc/5/core-classes/user/index.md | 6 + doc/5/core-classes/user/replace/index.md | 43 +++++++ .../user/replace/snippets/replace-1.js | 12 ++ .../user/save-restricted/index.md | 41 ++++++ .../snippets/save-restricted-1.js | 12 ++ doc/5/core-classes/user/save/index.md | 43 +++++++ .../core-classes/user/save/snippets/save-1.js | 12 ++ doc/5/core-classes/user/set-content/index.md | 32 +++++ .../set-content/snippets/set-content-1.js | 6 + .../user/set-credentials/index.md | 32 +++++ .../snippets/set-credentials-1.js | 5 + doc/5/core-classes/user/set-profiles/index.md | 39 ++++++ .../set-profiles/snippets/set-profiles-1.js | 7 + doc/5/core-classes/user/update/index.md | 44 +++++++ .../user/update/snippets/update-1.js | 16 +++ doc/5/essentials/error-handling/index.md | 16 +++ .../snippets/handling-errors-1.js | 19 +++ doc/5/essentials/events/index.md | 29 +++++ doc/5/essentials/index.md | 7 + doc/5/essentials/offline-tools/index.md | 96 ++++++++++++++ .../realtime-notifications/index.md | 96 ++++++++++++++ .../snippets/notifications-1.js | 21 +++ .../snippets/notifications-2.js | 17 +++ .../snippets/notifications-3.js | 46 +++++++ .../snippets/notifications-4.js | 19 +++ .../snippets/notifications-5.js | 17 +++ doc/5/index.md | 7 + 715 files changed, 16679 insertions(+) create mode 100644 doc/5/.keep create mode 100644 doc/5/core-classes/collection-mapping/apply/index.md create mode 100644 doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js create mode 100644 doc/5/core-classes/collection-mapping/constructor/index.md create mode 100644 doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/collection-mapping/index.md create mode 100644 doc/5/core-classes/collection-mapping/refresh/index.md create mode 100644 doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js create mode 100644 doc/5/core-classes/collection-mapping/set-headers/index.md create mode 100644 doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js create mode 100644 doc/5/core-classes/collection-mapping/set/index.md create mode 100644 doc/5/core-classes/collection-mapping/set/snippets/set-1.js create mode 100644 doc/5/core-classes/collection/collection-mapping/index.md create mode 100644 doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js create mode 100644 doc/5/core-classes/collection/constructor/index.md create mode 100644 doc/5/core-classes/collection/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/collection/count/index.md create mode 100644 doc/5/core-classes/collection/count/snippets/count-1.js create mode 100644 doc/5/core-classes/collection/count/snippets/count-2.js create mode 100644 doc/5/core-classes/collection/create-document/index.md create mode 100644 doc/5/core-classes/collection/create-document/snippets/create-document-1.js create mode 100644 doc/5/core-classes/collection/create/index.md create mode 100644 doc/5/core-classes/collection/create/snippets/create-1.js create mode 100644 doc/5/core-classes/collection/create/snippets/create-2.js create mode 100644 doc/5/core-classes/collection/delete-document/index.md create mode 100644 doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js create mode 100644 doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js create mode 100644 doc/5/core-classes/collection/delete-specifications/index.md create mode 100644 doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js create mode 100644 doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js create mode 100644 doc/5/core-classes/collection/document/index.md create mode 100644 doc/5/core-classes/collection/document/snippets/document-1.js create mode 100644 doc/5/core-classes/collection/fetch-document/index.md create mode 100644 doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js create mode 100644 doc/5/core-classes/collection/get-mapping/index.md create mode 100644 doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js create mode 100644 doc/5/core-classes/collection/get-specifications/index.md create mode 100644 doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js create mode 100644 doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js create mode 100644 doc/5/core-classes/collection/index.md create mode 100644 doc/5/core-classes/collection/mcreate-document/index.md create mode 100644 doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js create mode 100644 doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js create mode 100644 doc/5/core-classes/collection/mcreate-or-replace-document/index.md create mode 100644 doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js create mode 100644 doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js create mode 100644 doc/5/core-classes/collection/mdelete-document/index.md create mode 100644 doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js create mode 100644 doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js create mode 100644 doc/5/core-classes/collection/mget-document/index.md create mode 100644 doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js create mode 100644 doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js create mode 100644 doc/5/core-classes/collection/mreplace-document/index.md create mode 100644 doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js create mode 100644 doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js create mode 100644 doc/5/core-classes/collection/mupdate-document/index.md create mode 100644 doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js create mode 100644 doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js create mode 100644 doc/5/core-classes/collection/publish-message/index.md create mode 100644 doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js create mode 100644 doc/5/core-classes/collection/replace-document/index.md create mode 100644 doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js create mode 100644 doc/5/core-classes/collection/room/index.md create mode 100644 doc/5/core-classes/collection/room/snippets/room-1.js create mode 100644 doc/5/core-classes/collection/scroll-specifications/index.md create mode 100644 doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js create mode 100644 doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js create mode 100644 doc/5/core-classes/collection/scroll/index.md create mode 100644 doc/5/core-classes/collection/scroll/snippets/scroll-1.js create mode 100644 doc/5/core-classes/collection/search-specifications/index.md create mode 100644 doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js create mode 100644 doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js create mode 100644 doc/5/core-classes/collection/search/index.md create mode 100644 doc/5/core-classes/collection/search/snippets/search-1.js create mode 100644 doc/5/core-classes/collection/set-headers/index.md create mode 100644 doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js create mode 100644 doc/5/core-classes/collection/subscribe/index.md create mode 100644 doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js create mode 100644 doc/5/core-classes/collection/truncate/index.md create mode 100644 doc/5/core-classes/collection/truncate/snippets/truncate-1.js create mode 100644 doc/5/core-classes/collection/truncate/snippets/truncate-2.js create mode 100644 doc/5/core-classes/collection/update-document/index.md create mode 100644 doc/5/core-classes/collection/update-document/snippets/update-document-1.js create mode 100644 doc/5/core-classes/collection/update-specifications/index.md create mode 100644 doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js create mode 100644 doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js create mode 100644 doc/5/core-classes/collection/validate-specifications/index.md create mode 100644 doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js create mode 100644 doc/5/core-classes/document/constructor/index.md create mode 100644 doc/5/core-classes/document/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/document/delete/index.md create mode 100644 doc/5/core-classes/document/delete/snippets/delete-1.js create mode 100644 doc/5/core-classes/document/exists/index.md create mode 100644 doc/5/core-classes/document/exists/snippets/exists-1.js create mode 100644 doc/5/core-classes/document/index.md create mode 100644 doc/5/core-classes/document/publish/index.md create mode 100644 doc/5/core-classes/document/publish/snippets/publish-1.js create mode 100644 doc/5/core-classes/document/refresh/index.md create mode 100644 doc/5/core-classes/document/refresh/snippets/refresh-1.js create mode 100644 doc/5/core-classes/document/save/index.md create mode 100644 doc/5/core-classes/document/save/snippets/save-1.js create mode 100644 doc/5/core-classes/document/set-content/index.md create mode 100644 doc/5/core-classes/document/set-content/snippets/set-content-1.js create mode 100644 doc/5/core-classes/document/set-headers/index.md create mode 100644 doc/5/core-classes/document/set-headers/snippets/set-headers-1.js create mode 100644 doc/5/core-classes/document/subscribe/index.md create mode 100644 doc/5/core-classes/document/subscribe/snippets/subscribe-1.js create mode 100644 doc/5/core-classes/index.md create mode 100644 doc/5/core-classes/kuzzle/add-listener/index.md create mode 100644 doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js create mode 100644 doc/5/core-classes/kuzzle/check-token/index.md create mode 100644 doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js create mode 100644 doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js create mode 100644 doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js create mode 100644 doc/5/core-classes/kuzzle/collection/index.md create mode 100644 doc/5/core-classes/kuzzle/collection/snippets/collection-1.js create mode 100644 doc/5/core-classes/kuzzle/connect/index.md create mode 100644 doc/5/core-classes/kuzzle/connect/snippets/connect-1.js create mode 100644 doc/5/core-classes/kuzzle/constructor/index.md create mode 100644 doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/kuzzle/create-index/index.md create mode 100644 doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js create mode 100644 doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js create mode 100644 doc/5/core-classes/kuzzle/create-my-credentials/index.md create mode 100644 doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js create mode 100644 doc/5/core-classes/kuzzle/delete-my-credentials/index.md create mode 100644 doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js create mode 100644 doc/5/core-classes/kuzzle/disconnect/index.md create mode 100644 doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js create mode 100644 doc/5/core-classes/kuzzle/flush-queue/index.md create mode 100644 doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js create mode 100644 doc/5/core-classes/kuzzle/get-all-statistics/index.md create mode 100644 doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js create mode 100644 doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js create mode 100644 doc/5/core-classes/kuzzle/get-auto-refresh/index.md create mode 100644 doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js create mode 100644 doc/5/core-classes/kuzzle/get-jwt-token/index.md create mode 100644 doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js create mode 100644 doc/5/core-classes/kuzzle/get-my-credentials/index.md create mode 100644 doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js create mode 100644 doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js create mode 100644 doc/5/core-classes/kuzzle/get-my-rights/index.md create mode 100644 doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js create mode 100644 doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js create mode 100644 doc/5/core-classes/kuzzle/get-server-info/index.md create mode 100644 doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js create mode 100644 doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js create mode 100644 doc/5/core-classes/kuzzle/get-statistics/index.md create mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js create mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js create mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js create mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js create mode 100644 doc/5/core-classes/kuzzle/index.md create mode 100644 doc/5/core-classes/kuzzle/list-collections/index.md create mode 100644 doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js create mode 100644 doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js create mode 100644 doc/5/core-classes/kuzzle/list-indexes/index.md create mode 100644 doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js create mode 100644 doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js create mode 100644 doc/5/core-classes/kuzzle/login/index.md create mode 100644 doc/5/core-classes/kuzzle/login/snippets/login-1.js create mode 100644 doc/5/core-classes/kuzzle/logout/index.md create mode 100644 doc/5/core-classes/kuzzle/logout/snippets/logout-1.js create mode 100644 doc/5/core-classes/kuzzle/memory-storage/index.md create mode 100644 doc/5/core-classes/kuzzle/now/index.md create mode 100644 doc/5/core-classes/kuzzle/now/snippets/now-1.js create mode 100644 doc/5/core-classes/kuzzle/now/snippets/now-2.js create mode 100644 doc/5/core-classes/kuzzle/query/index.md create mode 100644 doc/5/core-classes/kuzzle/query/snippets/query-1.js create mode 100644 doc/5/core-classes/kuzzle/query/snippets/query-2.js create mode 100644 doc/5/core-classes/kuzzle/refresh-index/index.md create mode 100644 doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js create mode 100644 doc/5/core-classes/kuzzle/remove-all-listeners/index.md create mode 100644 doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js create mode 100644 doc/5/core-classes/kuzzle/remove-listener/index.md create mode 100644 doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js create mode 100644 doc/5/core-classes/kuzzle/replay-queue/index.md create mode 100644 doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js create mode 100644 doc/5/core-classes/kuzzle/security/index.md create mode 100644 doc/5/core-classes/kuzzle/set-auto-refresh/index.md create mode 100644 doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js create mode 100644 doc/5/core-classes/kuzzle/set-default-index/index.md create mode 100644 doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js create mode 100644 doc/5/core-classes/kuzzle/set-headers/index.md create mode 100644 doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js create mode 100644 doc/5/core-classes/kuzzle/set-jwt-token/index.md create mode 100644 doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js create mode 100644 doc/5/core-classes/kuzzle/start-queuing/index.md create mode 100644 doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js create mode 100644 doc/5/core-classes/kuzzle/stop-queuing/index.md create mode 100644 doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js create mode 100644 doc/5/core-classes/kuzzle/unset-jwt-token/index.md create mode 100644 doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js create mode 100644 doc/5/core-classes/kuzzle/update-my-credentials/index.md create mode 100644 doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js create mode 100644 doc/5/core-classes/kuzzle/update-self/index.md create mode 100644 doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js create mode 100644 doc/5/core-classes/kuzzle/validate-my-credentials/index.md create mode 100644 doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js create mode 100644 doc/5/core-classes/kuzzle/who-am-i/index.md create mode 100644 doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js create mode 100644 doc/5/core-classes/memory-storage/append/index.md create mode 100644 doc/5/core-classes/memory-storage/append/snippets/append-1.js create mode 100644 doc/5/core-classes/memory-storage/append/snippets/append-2.js create mode 100644 doc/5/core-classes/memory-storage/bitcount/index.md create mode 100644 doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js create mode 100644 doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js create mode 100644 doc/5/core-classes/memory-storage/bitop/index.md create mode 100644 doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js create mode 100644 doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js create mode 100644 doc/5/core-classes/memory-storage/bitpos/index.md create mode 100644 doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js create mode 100644 doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js create mode 100644 doc/5/core-classes/memory-storage/constructor/index.md create mode 100644 doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/memory-storage/dbsize/index.md create mode 100644 doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js create mode 100644 doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js create mode 100644 doc/5/core-classes/memory-storage/decr/index.md create mode 100644 doc/5/core-classes/memory-storage/decr/snippets/decr-1.js create mode 100644 doc/5/core-classes/memory-storage/decr/snippets/decr-2.js create mode 100644 doc/5/core-classes/memory-storage/decrby/index.md create mode 100644 doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js create mode 100644 doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js create mode 100644 doc/5/core-classes/memory-storage/del/index.md create mode 100644 doc/5/core-classes/memory-storage/del/snippets/del-1.js create mode 100644 doc/5/core-classes/memory-storage/del/snippets/del-2.js create mode 100644 doc/5/core-classes/memory-storage/exists/index.md create mode 100644 doc/5/core-classes/memory-storage/exists/snippets/exists-1.js create mode 100644 doc/5/core-classes/memory-storage/exists/snippets/exists-2.js create mode 100644 doc/5/core-classes/memory-storage/expire/index.md create mode 100644 doc/5/core-classes/memory-storage/expire/snippets/expire-1.js create mode 100644 doc/5/core-classes/memory-storage/expire/snippets/expire-2.js create mode 100644 doc/5/core-classes/memory-storage/expireat/index.md create mode 100644 doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js create mode 100644 doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js create mode 100644 doc/5/core-classes/memory-storage/flushdb/index.md create mode 100644 doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js create mode 100644 doc/5/core-classes/memory-storage/geoadd/index.md create mode 100644 doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js create mode 100644 doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js create mode 100644 doc/5/core-classes/memory-storage/geodist/index.md create mode 100644 doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js create mode 100644 doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js create mode 100644 doc/5/core-classes/memory-storage/geohash/index.md create mode 100644 doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js create mode 100644 doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js create mode 100644 doc/5/core-classes/memory-storage/geopos/index.md create mode 100644 doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js create mode 100644 doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js create mode 100644 doc/5/core-classes/memory-storage/georadius/index.md create mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js create mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js create mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js create mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js create mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/index.md create mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js create mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js create mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js create mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js create mode 100644 doc/5/core-classes/memory-storage/get/index.md create mode 100644 doc/5/core-classes/memory-storage/get/snippets/get-1.js create mode 100644 doc/5/core-classes/memory-storage/get/snippets/get-2.js create mode 100644 doc/5/core-classes/memory-storage/getbit/index.md create mode 100644 doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js create mode 100644 doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js create mode 100644 doc/5/core-classes/memory-storage/getrange/index.md create mode 100644 doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js create mode 100644 doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js create mode 100644 doc/5/core-classes/memory-storage/getset/index.md create mode 100644 doc/5/core-classes/memory-storage/getset/snippets/getset-1.js create mode 100644 doc/5/core-classes/memory-storage/getset/snippets/getset-2.js create mode 100644 doc/5/core-classes/memory-storage/hdel/index.md create mode 100644 doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js create mode 100644 doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js create mode 100644 doc/5/core-classes/memory-storage/hexists/index.md create mode 100644 doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js create mode 100644 doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js create mode 100644 doc/5/core-classes/memory-storage/hget/index.md create mode 100644 doc/5/core-classes/memory-storage/hget/snippets/hget-1.js create mode 100644 doc/5/core-classes/memory-storage/hget/snippets/hget-2.js create mode 100644 doc/5/core-classes/memory-storage/hgetall/index.md create mode 100644 doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js create mode 100644 doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js create mode 100644 doc/5/core-classes/memory-storage/hincrby/index.md create mode 100644 doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js create mode 100644 doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js create mode 100644 doc/5/core-classes/memory-storage/hincrbyfloat/index.md create mode 100644 doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js create mode 100644 doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js create mode 100644 doc/5/core-classes/memory-storage/hkeys/index.md create mode 100644 doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js create mode 100644 doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js create mode 100644 doc/5/core-classes/memory-storage/hlen/index.md create mode 100644 doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js create mode 100644 doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js create mode 100644 doc/5/core-classes/memory-storage/hmget/index.md create mode 100644 doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js create mode 100644 doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js create mode 100644 doc/5/core-classes/memory-storage/hmset/index.md create mode 100644 doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js create mode 100644 doc/5/core-classes/memory-storage/hscan/index.md create mode 100644 doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js create mode 100644 doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js create mode 100644 doc/5/core-classes/memory-storage/hset/index.md create mode 100644 doc/5/core-classes/memory-storage/hset/snippets/hset-1.js create mode 100644 doc/5/core-classes/memory-storage/hset/snippets/hset-2.js create mode 100644 doc/5/core-classes/memory-storage/hsetnx/index.md create mode 100644 doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js create mode 100644 doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js create mode 100644 doc/5/core-classes/memory-storage/hstrlen/index.md create mode 100644 doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js create mode 100644 doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js create mode 100644 doc/5/core-classes/memory-storage/hvals/index.md create mode 100644 doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js create mode 100644 doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js create mode 100644 doc/5/core-classes/memory-storage/incr/index.md create mode 100644 doc/5/core-classes/memory-storage/incr/snippets/incr-1.js create mode 100644 doc/5/core-classes/memory-storage/incr/snippets/incr-2.js create mode 100644 doc/5/core-classes/memory-storage/incrby/index.md create mode 100644 doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js create mode 100644 doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js create mode 100644 doc/5/core-classes/memory-storage/incrbyfloat/index.md create mode 100644 doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js create mode 100644 doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js create mode 100644 doc/5/core-classes/memory-storage/index.md create mode 100644 doc/5/core-classes/memory-storage/keys/index.md create mode 100644 doc/5/core-classes/memory-storage/keys/snippets/keys-1.js create mode 100644 doc/5/core-classes/memory-storage/keys/snippets/keys-2.js create mode 100644 doc/5/core-classes/memory-storage/lindex/index.md create mode 100644 doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js create mode 100644 doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js create mode 100644 doc/5/core-classes/memory-storage/linsert/index.md create mode 100644 doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js create mode 100644 doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js create mode 100644 doc/5/core-classes/memory-storage/llen/index.md create mode 100644 doc/5/core-classes/memory-storage/llen/snippets/llen-1.js create mode 100644 doc/5/core-classes/memory-storage/llen/snippets/llen-2.js create mode 100644 doc/5/core-classes/memory-storage/lpop/index.md create mode 100644 doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js create mode 100644 doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js create mode 100644 doc/5/core-classes/memory-storage/lpush/index.md create mode 100644 doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js create mode 100644 doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js create mode 100644 doc/5/core-classes/memory-storage/lpushx/index.md create mode 100644 doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js create mode 100644 doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js create mode 100644 doc/5/core-classes/memory-storage/lrange/index.md create mode 100644 doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js create mode 100644 doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js create mode 100644 doc/5/core-classes/memory-storage/lrem/index.md create mode 100644 doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js create mode 100644 doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js create mode 100644 doc/5/core-classes/memory-storage/lset/index.md create mode 100644 doc/5/core-classes/memory-storage/lset/snippets/lset-1.js create mode 100644 doc/5/core-classes/memory-storage/ltrim/index.md create mode 100644 doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js create mode 100644 doc/5/core-classes/memory-storage/mget/index.md create mode 100644 doc/5/core-classes/memory-storage/mget/snippets/mget-1.js create mode 100644 doc/5/core-classes/memory-storage/mget/snippets/mget-2.js create mode 100644 doc/5/core-classes/memory-storage/mset/index.md create mode 100644 doc/5/core-classes/memory-storage/mset/snippets/mset-1.js create mode 100644 doc/5/core-classes/memory-storage/msetnx/index.md create mode 100644 doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js create mode 100644 doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js create mode 100644 doc/5/core-classes/memory-storage/object/index.md create mode 100644 doc/5/core-classes/memory-storage/object/snippets/object-1.js create mode 100644 doc/5/core-classes/memory-storage/object/snippets/object-2.js create mode 100644 doc/5/core-classes/memory-storage/persist/index.md create mode 100644 doc/5/core-classes/memory-storage/persist/snippets/persist-1.js create mode 100644 doc/5/core-classes/memory-storage/persist/snippets/persist-2.js create mode 100644 doc/5/core-classes/memory-storage/pexpire/index.md create mode 100644 doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js create mode 100644 doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js create mode 100644 doc/5/core-classes/memory-storage/pexpireat/index.md create mode 100644 doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js create mode 100644 doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js create mode 100644 doc/5/core-classes/memory-storage/pfadd/index.md create mode 100644 doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js create mode 100644 doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js create mode 100644 doc/5/core-classes/memory-storage/pfcount/index.md create mode 100644 doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js create mode 100644 doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js create mode 100644 doc/5/core-classes/memory-storage/pfmerge/index.md create mode 100644 doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js create mode 100644 doc/5/core-classes/memory-storage/ping/index.md create mode 100644 doc/5/core-classes/memory-storage/ping/snippets/ping-1.js create mode 100644 doc/5/core-classes/memory-storage/ping/snippets/ping-2.js create mode 100644 doc/5/core-classes/memory-storage/psetex/index.md create mode 100644 doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js create mode 100644 doc/5/core-classes/memory-storage/pttl/index.md create mode 100644 doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js create mode 100644 doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js create mode 100644 doc/5/core-classes/memory-storage/randomkey/index.md create mode 100644 doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js create mode 100644 doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js create mode 100644 doc/5/core-classes/memory-storage/rename/index.md create mode 100644 doc/5/core-classes/memory-storage/rename/snippets/rename-1.js create mode 100644 doc/5/core-classes/memory-storage/renamenx/index.md create mode 100644 doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js create mode 100644 doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js create mode 100644 doc/5/core-classes/memory-storage/rpop/index.md create mode 100644 doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js create mode 100644 doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js create mode 100644 doc/5/core-classes/memory-storage/rpoplpush/index.md create mode 100644 doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js create mode 100644 doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js create mode 100644 doc/5/core-classes/memory-storage/rpush/index.md create mode 100644 doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js create mode 100644 doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js create mode 100644 doc/5/core-classes/memory-storage/rpushx/index.md create mode 100644 doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js create mode 100644 doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js create mode 100644 doc/5/core-classes/memory-storage/sadd/index.md create mode 100644 doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js create mode 100644 doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js create mode 100644 doc/5/core-classes/memory-storage/scan/index.md create mode 100644 doc/5/core-classes/memory-storage/scan/snippets/scan-1.js create mode 100644 doc/5/core-classes/memory-storage/scan/snippets/scan-2.js create mode 100644 doc/5/core-classes/memory-storage/scard/index.md create mode 100644 doc/5/core-classes/memory-storage/scard/snippets/scard-1.js create mode 100644 doc/5/core-classes/memory-storage/scard/snippets/scard-2.js create mode 100644 doc/5/core-classes/memory-storage/sdiff/index.md create mode 100644 doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js create mode 100644 doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js create mode 100644 doc/5/core-classes/memory-storage/sdiffstore/index.md create mode 100644 doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js create mode 100644 doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js create mode 100644 doc/5/core-classes/memory-storage/set/index.md create mode 100644 doc/5/core-classes/memory-storage/set/snippets/set-1.js create mode 100644 doc/5/core-classes/memory-storage/setex/index.md create mode 100644 doc/5/core-classes/memory-storage/setex/snippets/setex-1.js create mode 100644 doc/5/core-classes/memory-storage/setnx/index.md create mode 100644 doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js create mode 100644 doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js create mode 100644 doc/5/core-classes/memory-storage/sinter/index.md create mode 100644 doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js create mode 100644 doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js create mode 100644 doc/5/core-classes/memory-storage/sinterstore/index.md create mode 100644 doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js create mode 100644 doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js create mode 100644 doc/5/core-classes/memory-storage/sismember/index.md create mode 100644 doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js create mode 100644 doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js create mode 100644 doc/5/core-classes/memory-storage/smembers/index.md create mode 100644 doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js create mode 100644 doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js create mode 100644 doc/5/core-classes/memory-storage/smove/index.md create mode 100644 doc/5/core-classes/memory-storage/smove/snippets/smove-1.js create mode 100644 doc/5/core-classes/memory-storage/smove/snippets/smove-2.js create mode 100644 doc/5/core-classes/memory-storage/sort/index.md create mode 100644 doc/5/core-classes/memory-storage/sort/snippets/sort-1.js create mode 100644 doc/5/core-classes/memory-storage/sort/snippets/sort-2.js create mode 100644 doc/5/core-classes/memory-storage/spop/index.md create mode 100644 doc/5/core-classes/memory-storage/spop/snippets/spop-1.js create mode 100644 doc/5/core-classes/memory-storage/spop/snippets/spop-2.js create mode 100644 doc/5/core-classes/memory-storage/srandmember/index.md create mode 100644 doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js create mode 100644 doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js create mode 100644 doc/5/core-classes/memory-storage/srem/index.md create mode 100644 doc/5/core-classes/memory-storage/srem/snippets/srem-1.js create mode 100644 doc/5/core-classes/memory-storage/srem/snippets/srem-2.js create mode 100644 doc/5/core-classes/memory-storage/sscan/index.md create mode 100644 doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js create mode 100644 doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js create mode 100644 doc/5/core-classes/memory-storage/strlen/index.md create mode 100644 doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js create mode 100644 doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js create mode 100644 doc/5/core-classes/memory-storage/sunion/index.md create mode 100644 doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js create mode 100644 doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js create mode 100644 doc/5/core-classes/memory-storage/sunionstore/index.md create mode 100644 doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js create mode 100644 doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js create mode 100644 doc/5/core-classes/memory-storage/time/index.md create mode 100644 doc/5/core-classes/memory-storage/time/snippets/time-1.js create mode 100644 doc/5/core-classes/memory-storage/time/snippets/time-2.js create mode 100644 doc/5/core-classes/memory-storage/touch/index.md create mode 100644 doc/5/core-classes/memory-storage/touch/snippets/touch-1.js create mode 100644 doc/5/core-classes/memory-storage/touch/snippets/touch-2.js create mode 100644 doc/5/core-classes/memory-storage/ttl/index.md create mode 100644 doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js create mode 100644 doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js create mode 100644 doc/5/core-classes/memory-storage/type/index.md create mode 100644 doc/5/core-classes/memory-storage/type/snippets/type-1.js create mode 100644 doc/5/core-classes/memory-storage/type/snippets/type-2.js create mode 100644 doc/5/core-classes/memory-storage/zadd/index.md create mode 100644 doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js create mode 100644 doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js create mode 100644 doc/5/core-classes/memory-storage/zcard/index.md create mode 100644 doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js create mode 100644 doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js create mode 100644 doc/5/core-classes/memory-storage/zcount/index.md create mode 100644 doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js create mode 100644 doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js create mode 100644 doc/5/core-classes/memory-storage/zincrby/index.md create mode 100644 doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js create mode 100644 doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js create mode 100644 doc/5/core-classes/memory-storage/zinterstore/index.md create mode 100644 doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js create mode 100644 doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js create mode 100644 doc/5/core-classes/memory-storage/zlexcount/index.md create mode 100644 doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js create mode 100644 doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js create mode 100644 doc/5/core-classes/memory-storage/zrange/index.md create mode 100644 doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js create mode 100644 doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js create mode 100644 doc/5/core-classes/memory-storage/zrangebylex/index.md create mode 100644 doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js create mode 100644 doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js create mode 100644 doc/5/core-classes/memory-storage/zrangebyscore/index.md create mode 100644 doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js create mode 100644 doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js create mode 100644 doc/5/core-classes/memory-storage/zrank/index.md create mode 100644 doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js create mode 100644 doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js create mode 100644 doc/5/core-classes/memory-storage/zrem/index.md create mode 100644 doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js create mode 100644 doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js create mode 100644 doc/5/core-classes/memory-storage/zremrangebylex/index.md create mode 100644 doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js create mode 100644 doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js create mode 100644 doc/5/core-classes/memory-storage/zremrangebyrank/index.md create mode 100644 doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js create mode 100644 doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js create mode 100644 doc/5/core-classes/memory-storage/zremrangebyscore/index.md create mode 100644 doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js create mode 100644 doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js create mode 100644 doc/5/core-classes/memory-storage/zrevrange/index.md create mode 100644 doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js create mode 100644 doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js create mode 100644 doc/5/core-classes/memory-storage/zrevrangebylex/index.md create mode 100644 doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js create mode 100644 doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js create mode 100644 doc/5/core-classes/memory-storage/zrevrangebyscore/index.md create mode 100644 doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js create mode 100644 doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js create mode 100644 doc/5/core-classes/memory-storage/zrevrank/index.md create mode 100644 doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js create mode 100644 doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js create mode 100644 doc/5/core-classes/memory-storage/zscan/index.md create mode 100644 doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js create mode 100644 doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js create mode 100644 doc/5/core-classes/memory-storage/zscore/index.md create mode 100644 doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js create mode 100644 doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js create mode 100644 doc/5/core-classes/memory-storage/zunionstore/index.md create mode 100644 doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js create mode 100644 doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js create mode 100644 doc/5/core-classes/profile/add-policy/index.md create mode 100644 doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js create mode 100644 doc/5/core-classes/profile/constructor/index.md create mode 100644 doc/5/core-classes/profile/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/profile/delete/index.md create mode 100644 doc/5/core-classes/profile/delete/snippets/delete-1.js create mode 100644 doc/5/core-classes/profile/get-policies/index.md create mode 100644 doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js create mode 100644 doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js create mode 100644 doc/5/core-classes/profile/index.md create mode 100644 doc/5/core-classes/profile/save/index.md create mode 100644 doc/5/core-classes/profile/save/snippets/save-1.js create mode 100644 doc/5/core-classes/profile/set-content/index.md create mode 100644 doc/5/core-classes/profile/set-content/snippets/set-content-1.js create mode 100644 doc/5/core-classes/profile/set-policies/index.md create mode 100644 doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js create mode 100644 doc/5/core-classes/profile/update/index.md create mode 100644 doc/5/core-classes/profile/update/snippets/update-1.js create mode 100644 doc/5/core-classes/role/constructor/index.md create mode 100644 doc/5/core-classes/role/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/role/delete/index.md create mode 100644 doc/5/core-classes/role/delete/snippets/delete-1.js create mode 100644 doc/5/core-classes/role/index.md create mode 100644 doc/5/core-classes/role/save/index.md create mode 100644 doc/5/core-classes/role/save/snippets/save-1.js create mode 100644 doc/5/core-classes/role/set-content/index.md create mode 100644 doc/5/core-classes/role/set-content/snippets/set-content-1.js create mode 100644 doc/5/core-classes/role/update/index.md create mode 100644 doc/5/core-classes/role/update/snippets/update-1.js create mode 100644 doc/5/core-classes/room/constructor/index.md create mode 100644 doc/5/core-classes/room/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/room/count/index.md create mode 100644 doc/5/core-classes/room/count/snippets/count-1.js create mode 100644 doc/5/core-classes/room/count/snippets/count-2.js create mode 100644 doc/5/core-classes/room/index.md create mode 100644 doc/5/core-classes/room/renew/index.md create mode 100644 doc/5/core-classes/room/renew/snippets/renew-1.js create mode 100644 doc/5/core-classes/room/set-headers/index.md create mode 100644 doc/5/core-classes/room/set-headers/snippets/set-headers-1.js create mode 100644 doc/5/core-classes/room/unsubscribe/index.md create mode 100644 doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js create mode 100644 doc/5/core-classes/search-result/constructor/index.md create mode 100644 doc/5/core-classes/search-result/fetch-next/index.md create mode 100644 doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js create mode 100644 doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js create mode 100644 doc/5/core-classes/search-result/index.md create mode 100644 doc/5/core-classes/security/constructor/index.md create mode 100644 doc/5/core-classes/security/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/security/create-credentials/index.md create mode 100644 doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js create mode 100644 doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js create mode 100644 doc/5/core-classes/security/create-profile/index.md create mode 100644 doc/5/core-classes/security/create-profile/snippets/create-profile-1.js create mode 100644 doc/5/core-classes/security/create-restricted-user/index.md create mode 100644 doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js create mode 100644 doc/5/core-classes/security/create-role/index.md create mode 100644 doc/5/core-classes/security/create-role/snippets/create-role-1.js create mode 100644 doc/5/core-classes/security/create-user/index.md create mode 100644 doc/5/core-classes/security/create-user/snippets/create-user-1.js create mode 100644 doc/5/core-classes/security/delete-credentials/index.md create mode 100644 doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js create mode 100644 doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js create mode 100644 doc/5/core-classes/security/delete-profile/index.md create mode 100644 doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js create mode 100644 doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js create mode 100644 doc/5/core-classes/security/delete-role/index.md create mode 100644 doc/5/core-classes/security/delete-role/snippets/delete-role-1.js create mode 100644 doc/5/core-classes/security/delete-role/snippets/delete-role-2.js create mode 100644 doc/5/core-classes/security/delete-user/index.md create mode 100644 doc/5/core-classes/security/delete-user/snippets/delete-user-1.js create mode 100644 doc/5/core-classes/security/delete-user/snippets/delete-user-2.js create mode 100644 doc/5/core-classes/security/fetch-profile/index.md create mode 100644 doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js create mode 100644 doc/5/core-classes/security/fetch-role/index.md create mode 100644 doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js create mode 100644 doc/5/core-classes/security/fetch-user/index.md create mode 100644 doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js create mode 100644 doc/5/core-classes/security/get-all-credential-fields/index.md create mode 100644 doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js create mode 100644 doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js create mode 100644 doc/5/core-classes/security/get-credentials-fields/index.md create mode 100644 doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js create mode 100644 doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js create mode 100644 doc/5/core-classes/security/get-credentials/index.md create mode 100644 doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js create mode 100644 doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js create mode 100644 doc/5/core-classes/security/get-user-rights/index.md create mode 100644 doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js create mode 100644 doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js create mode 100644 doc/5/core-classes/security/has-credentials/index.md create mode 100644 doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js create mode 100644 doc/5/core-classes/security/index.md create mode 100644 doc/5/core-classes/security/is-action-allowed/index.md create mode 100644 doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js create mode 100644 doc/5/core-classes/security/profile/index.md create mode 100644 doc/5/core-classes/security/profile/snippets/profile-1.js create mode 100644 doc/5/core-classes/security/replace-user/index.md create mode 100644 doc/5/core-classes/security/replace-user/snippets/replace-user-1.js create mode 100644 doc/5/core-classes/security/role/index.md create mode 100644 doc/5/core-classes/security/role/snippets/role-1.js create mode 100644 doc/5/core-classes/security/scroll-profiles/index.md create mode 100644 doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js create mode 100644 doc/5/core-classes/security/scroll-users/index.md create mode 100644 doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js create mode 100644 doc/5/core-classes/security/search-profiles/index.md create mode 100644 doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js create mode 100644 doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js create mode 100644 doc/5/core-classes/security/search-roles/index.md create mode 100644 doc/5/core-classes/security/search-roles/snippets/search-roles-1.js create mode 100644 doc/5/core-classes/security/search-roles/snippets/search-roles-2.js create mode 100644 doc/5/core-classes/security/search-users/index.md create mode 100644 doc/5/core-classes/security/search-users/snippets/search-users-1.js create mode 100644 doc/5/core-classes/security/search-users/snippets/search-users-2.js create mode 100644 doc/5/core-classes/security/update-credentials/index.md create mode 100644 doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js create mode 100644 doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js create mode 100644 doc/5/core-classes/security/update-profile/index.md create mode 100644 doc/5/core-classes/security/update-profile/snippets/update-profile-1.js create mode 100644 doc/5/core-classes/security/update-role/index.md create mode 100644 doc/5/core-classes/security/update-role/snippets/update-role-1.js create mode 100644 doc/5/core-classes/security/update-user/index.md create mode 100644 doc/5/core-classes/security/update-user/snippets/update-user-1.js create mode 100644 doc/5/core-classes/security/user/index.md create mode 100644 doc/5/core-classes/security/user/snippets/user-1.js create mode 100644 doc/5/core-classes/security/validate-credentials/index.md create mode 100644 doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js create mode 100644 doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js create mode 100644 doc/5/core-classes/user/add-profile/index.md create mode 100644 doc/5/core-classes/user/add-profile/snippets/add-profile-1.js create mode 100644 doc/5/core-classes/user/constructor/index.md create mode 100644 doc/5/core-classes/user/constructor/snippets/constructor-1.js create mode 100644 doc/5/core-classes/user/create/index.md create mode 100644 doc/5/core-classes/user/create/snippets/create-1.js create mode 100644 doc/5/core-classes/user/delete/index.md create mode 100644 doc/5/core-classes/user/delete/snippets/delete-1.js create mode 100644 doc/5/core-classes/user/get-profileids/index.md create mode 100644 doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js create mode 100644 doc/5/core-classes/user/get-profiles/index.md create mode 100644 doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js create mode 100644 doc/5/core-classes/user/index.md create mode 100644 doc/5/core-classes/user/replace/index.md create mode 100644 doc/5/core-classes/user/replace/snippets/replace-1.js create mode 100644 doc/5/core-classes/user/save-restricted/index.md create mode 100644 doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js create mode 100644 doc/5/core-classes/user/save/index.md create mode 100644 doc/5/core-classes/user/save/snippets/save-1.js create mode 100644 doc/5/core-classes/user/set-content/index.md create mode 100644 doc/5/core-classes/user/set-content/snippets/set-content-1.js create mode 100644 doc/5/core-classes/user/set-credentials/index.md create mode 100644 doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js create mode 100644 doc/5/core-classes/user/set-profiles/index.md create mode 100644 doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js create mode 100644 doc/5/core-classes/user/update/index.md create mode 100644 doc/5/core-classes/user/update/snippets/update-1.js create mode 100644 doc/5/essentials/error-handling/index.md create mode 100644 doc/5/essentials/error-handling/snippets/handling-errors-1.js create mode 100644 doc/5/essentials/events/index.md create mode 100644 doc/5/essentials/index.md create mode 100644 doc/5/essentials/offline-tools/index.md create mode 100644 doc/5/essentials/realtime-notifications/index.md create mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-1.js create mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-2.js create mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-3.js create mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-4.js create mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-5.js create mode 100644 doc/5/index.md diff --git a/doc/5/.keep b/doc/5/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/doc/5/core-classes/collection-mapping/apply/index.md b/doc/5/core-classes/collection-mapping/apply/index.md new file mode 100644 index 000000000..27b08c2f3 --- /dev/null +++ b/doc/5/core-classes/collection-mapping/apply/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: apply +description: CollectionMapping:apply +--- + +# apply + +Applies the new mapping to the collection. + +--- + +## apply([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns this `CollectionMapping` object to allow chaining. + +--- + +## Callback Response + +Returns the updated `CollectionMapping` object. + +## Usage + +<<< ./snippets/apply-1.js diff --git a/doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js b/doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js new file mode 100644 index 000000000..985b8ffa3 --- /dev/null +++ b/doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +dataMapping.apply(function (error, result) { + // called once the mapping action has been completed +}); + +// Using promises (NodeJS) +dataMapping.applyPromise().then(function (error, result) { + // resolved once the mapping action has been completed +}); diff --git a/doc/5/core-classes/collection-mapping/constructor/index.md b/doc/5/core-classes/collection-mapping/constructor/index.md new file mode 100644 index 000000000..611fd4ecb --- /dev/null +++ b/doc/5/core-classes/collection-mapping/constructor/index.md @@ -0,0 +1,42 @@ +--- +code: false +type: page +title: constructor +description: CollectionMapping:constructor +order: 1 +--- + +# CollectionMapping + +When creating a new collection in the persistent data storage layer, Kuzzle uses a default mapping. +This means that, by default, you won't be able to exploit the full capabilities of our persistent data storage layer (currently handled by [ElasticSearch](https://www.elastic.co/products/elasticsearch)), and your searches may suffer from below-average performance, depending on the amount of data you stored in a collection and the complexity of your database. + +The CollectionMapping object allows you to get the current mapping in a collection and to modify it if necessary. + +
+Once a field mapping has been set, it cannot be removed without reconstructing the collection. +
+ +--- + +## CollectionMapping(Collection, [mapping]) + +| Arguments | Type | Description | +| ------------ | ----------------------------------- | --------------------------------- | +| `Collection` | [Collection](/sdk/js/5/core-classes/collection/) | An instantiated Collection object | +| `mapping` | JSON Object | Optional mapping | + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ------------- | ----------- | --------------------------------------------- | ------- | +| `headers` | JSON Object | Common headers for all sent documents. | get/set | +| `mapping` | object | Easy-to-understand list of mappings per field | get/set | + +**Note:** the `headers` property is inherited from the provided [Collection](/sdk/js/5/core-classes/collection/) object and can be overrided + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js b/doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..a9c44fdee --- /dev/null +++ b/doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js @@ -0,0 +1,10 @@ +/* + Constructors are not exposed in the JS/Node SDK. + CollectionMapping objects are returned by the method + Collection.getMapping + + You may also use the Collection.collectionMapping() method: + */ +var mapping = kuzzle.collection('collection', 'index').collectionMapping(); + +mapping = kuzzle.collection('collection', 'index').collectionMapping(mapping); diff --git a/doc/5/core-classes/collection-mapping/index.md b/doc/5/core-classes/collection-mapping/index.md new file mode 100644 index 000000000..f26a7c1a0 --- /dev/null +++ b/doc/5/core-classes/collection-mapping/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: CollectionMapping +description: CollectionMapping documentation +--- diff --git a/doc/5/core-classes/collection-mapping/refresh/index.md b/doc/5/core-classes/collection-mapping/refresh/index.md new file mode 100644 index 000000000..4de73245a --- /dev/null +++ b/doc/5/core-classes/collection-mapping/refresh/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: refresh +description: CollectionMapping:refresh +--- + +# refresh + +Instantiates a new CollectionMapping object with an up-to-date content. + +--- + +## refresh([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the updated `CollectionMapping` object. + +## Usage + +<<< ./snippets/refresh-1.js diff --git a/doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js b/doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js new file mode 100644 index 000000000..c3bb95ade --- /dev/null +++ b/doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS & Web Browser) +dataMapping.refresh(function (error, result) { + // called once the mapping has been retrieved from Kuzzle +}); + +// Using promises (NodeJS) +dataMapping.refreshPromise().then(result => { + // resolved once the mapping has been retrieved from Kuzzle +}); diff --git a/doc/5/core-classes/collection-mapping/set-headers/index.md b/doc/5/core-classes/collection-mapping/set-headers/index.md new file mode 100644 index 000000000..e01fc3540 --- /dev/null +++ b/doc/5/core-classes/collection-mapping/set-headers/index.md @@ -0,0 +1,31 @@ +--- +code: false +type: page +title: setHeaders +description: CollectionMapping:setHeaders +--- + +# setHeaders + +This is a helper function returning itself, allowing to easily chain calls. + +--- + +## setHeaders(content, [replace]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------------------------------------------------------- | +| `content` | JSON Object | New content | +| `replace` | boolean | true: replace the current content with the provided data, false: merge it | + +**Note:** by default, the `replace` argument is set to `false` + +--- + +## Return value + +Returns this `CollectionMapping` object to allow chaining. + +## Usage + +<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js new file mode 100644 index 000000000..4784cc0f5 --- /dev/null +++ b/doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js @@ -0,0 +1 @@ +dataMapping.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/collection-mapping/set/index.md b/doc/5/core-classes/collection-mapping/set/index.md new file mode 100644 index 000000000..cb26bf82a --- /dev/null +++ b/doc/5/core-classes/collection-mapping/set/index.md @@ -0,0 +1,33 @@ +--- +code: false +type: page +title: set +description: CollectionMapping:set +--- + +# set + +Adds or updates a field mapping. + +
+Changes made by this function won't be applied until you call the apply method +
+ +--- + +## set(field, mapping) + +| Arguments | Type | Description | +| --------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `field` | string | Name of the field from which the mapping is to be added or updated | +| `mapping` | JSON Object | Mapping for this field, following the [Elasticsearch Mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/mapping.html) | + +--- + +## Return Value + +Returns this `CollectionMapping` object to allow chaining. + +## Usage + +<<< ./snippets/set-1.js diff --git a/doc/5/core-classes/collection-mapping/set/snippets/set-1.js b/doc/5/core-classes/collection-mapping/set/snippets/set-1.js new file mode 100644 index 000000000..05e06902a --- /dev/null +++ b/doc/5/core-classes/collection-mapping/set/snippets/set-1.js @@ -0,0 +1 @@ +dataMapping.set('field', {type: 'string', index: 'analyzed', null_value: ''}); diff --git a/doc/5/core-classes/collection/collection-mapping/index.md b/doc/5/core-classes/collection/collection-mapping/index.md new file mode 100644 index 000000000..b67ef427e --- /dev/null +++ b/doc/5/core-classes/collection/collection-mapping/index.md @@ -0,0 +1,28 @@ +--- +code: false +type: page +title: collectionMapping +description: Collection:collectionMapping +--- + +# collectionMapping + +Creates a new [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object, using its constructor. + +--- + +## collectionMapping([mapping]) + +| Arguments | Type | Description | +| --------- | ----------- | ---------------- | +| `mapping` | JSON Object | Optional mapping | + +--- + +## Return Value + +Returns the newly created [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object. + +## Usage + +<<< ./snippets/collection-mapping-1.js diff --git a/doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js b/doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js new file mode 100644 index 000000000..0486b4d62 --- /dev/null +++ b/doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js @@ -0,0 +1,6 @@ +let dataMapping = kuzzle + .collection('collection', 'index') + .collectionMapping({someField: {type: 'string', index: 'analyzed'}}) + .apply(function (error, result) { + // called once the mapping action has been completed + }); diff --git a/doc/5/core-classes/collection/constructor/index.md b/doc/5/core-classes/collection/constructor/index.md new file mode 100644 index 000000000..ee06952a1 --- /dev/null +++ b/doc/5/core-classes/collection/constructor/index.md @@ -0,0 +1,42 @@ +--- +code: false +type: page +title: constructor +description: Collection:constructor +order: 1 +--- + +# Collection + +In Kuzzle, you manipulate documents and subscriptions, both related to collections. + +A collection is a set of data managed by Kuzzle. It acts like a data table for persistent documents, or like a room for pub/sub messages. + +--- + +## Collection(kuzzle, collection, index) + +| Arguments | Type | Description | +| ------------ | ------ | ------------------------------------------------------ | +| `kuzzle` | object | Kuzzle object | +| `collection` | string | The name of the collection you want to manipulate | +| `index` | string | Name of the index containing the collection | + +**Note:** We recommend you instantiate a Collection object by calling [Kuzzle.collection](/sdk/js/5/core-classes/kuzzle/collection) rather than using the constructor directly + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ------------- | ------ | -------------------------------------------------------- | ------- | +| `collection` | string | The name of the collection handled by this instance | get | +| `index` | object | Name of the index containing the collection | get | +| `headers` | object | Headers for all sent documents. | get/set | +| `kuzzle` | object | linked Kuzzle instance | get | + +**Note:** the `headers` property is inherited from the main `Kuzzle` object and can be overrided + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/collection/constructor/snippets/constructor-1.js b/doc/5/core-classes/collection/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..2bb9fc323 --- /dev/null +++ b/doc/5/core-classes/collection/constructor/snippets/constructor-1.js @@ -0,0 +1 @@ +let dataCollection = new Collection(kuzzle, "my-collection", "my-index") diff --git a/doc/5/core-classes/collection/count/index.md b/doc/5/core-classes/collection/count/index.md new file mode 100644 index 000000000..81b6c18d0 --- /dev/null +++ b/doc/5/core-classes/collection/count/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: count +description: Collection:count +--- + +# count + +Returns the number of documents matching the provided set of filters. + +
+There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first. +
+ +--- + +## count(filters, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | +| `filters` | JSON Object | Filters in [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl.html) format | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a count for the number of document matches as an `integer`. + +## Usage + +<<< ./snippets/count-1.js + +> Callback response: + +```json +12 +``` diff --git a/doc/5/core-classes/collection/count/snippets/count-1.js b/doc/5/core-classes/collection/count/snippets/count-1.js new file mode 100644 index 000000000..799d5a523 --- /dev/null +++ b/doc/5/core-classes/collection/count/snippets/count-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .count({}, function (err, res) { + // ... + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .countPromise({}) + .then(res => { + // ... + }); diff --git a/doc/5/core-classes/collection/count/snippets/count-2.js b/doc/5/core-classes/collection/count/snippets/count-2.js new file mode 100644 index 000000000..a300bc6b4 --- /dev/null +++ b/doc/5/core-classes/collection/count/snippets/count-2.js @@ -0,0 +1,2 @@ +on +12 diff --git a/doc/5/core-classes/collection/create-document/index.md b/doc/5/core-classes/collection/create-document/index.md new file mode 100644 index 000000000..c095a75c9 --- /dev/null +++ b/doc/5/core-classes/collection/create-document/index.md @@ -0,0 +1,58 @@ +--- +code: false +type: page +title: createDocument +description: Collection:createDocument +--- + +# createDocument + +Create a new document in Kuzzle and instantiate a [Document](/sdk/js/5/core-classes/document/) object. + +--- + +## createDocument(Document, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------- | +| `Document` | object | [Document](/sdk/js/5/core-classes/document/) object | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## createDocument([id], content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------- | +| `id` | string | Optional document identifier | +| `content` | JSON object | Content of the document to create | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | +| `ifExist` | string | If the same document already exists: resolves to an `error`. Replaces the existing document if set to `replace` | `false` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a [Document](/sdk/js/5/core-classes/document/) object containing the newly created document. + +## Usage + +<<< ./snippets/create-document-1.js diff --git a/doc/5/core-classes/collection/create-document/snippets/create-document-1.js b/doc/5/core-classes/collection/create-document/snippets/create-document-1.js new file mode 100644 index 000000000..a7ed362e7 --- /dev/null +++ b/doc/5/core-classes/collection/create-document/snippets/create-document-1.js @@ -0,0 +1,16 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .createDocument('foobar', {title: 'foo', content: 'bar'}, {ifExist: 'replace'}, function (err, res) { + // callback called once the create action has been completed + // => the result is a Document object + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .createDocumentPromise('foobar', {title: 'foo', content: 'bar'}, {ifExist: 'replace'}) + .then(res => { + // promise resolved once the create action has been completed + // => the result is a Document object + }); diff --git a/doc/5/core-classes/collection/create/index.md b/doc/5/core-classes/collection/create/index.md new file mode 100644 index 000000000..31540b342 --- /dev/null +++ b/doc/5/core-classes/collection/create/index.md @@ -0,0 +1,69 @@ +--- +code: false +type: page +title: create +description: Collection:create +--- + +# create + +Creates a new [collection](/core/1/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided `index`. + + + +You can also provide an optional data mapping that allow you to exploit the full capabilities of our +persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/mapping.html)). + +This method will only update the mapping if the collection already exists. + +--- + +## create([mapping], [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------- | +| `mapping` | JSON Object | Optional data mapping | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Ralue + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. + +## Usage + +<<< ./snippets/create-1.js + +> Callback response: + +```json +{ + "status": 200, + "error": null, + "requestId": "", + "controller": "collection", + "action": "create", + "collection": "", + "index": "index", + "volatile": null, + "result": { + "acknowledged": true + } +} +``` diff --git a/doc/5/core-classes/collection/create/snippets/create-1.js b/doc/5/core-classes/collection/create/snippets/create-1.js new file mode 100644 index 000000000..bf012c39c --- /dev/null +++ b/doc/5/core-classes/collection/create/snippets/create-1.js @@ -0,0 +1,35 @@ +// Optional: a mapping can be provided and will be +// applied when the collection is created +const mapping = { + properties: { + field1: { + type: '' + }, + field2: { + type: '' + } + } +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .create(mapping, function (error, result) { + // callback called once the create operation has completed + // => the result is a JSON object containing the raw Kuzzle response: + // { + // acknowledged: true + // } + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .createPromise(mapping) + .then(result => { + // promise resolved once the create operation has completed + // => the result is a JSON object containing the raw Kuzzle response: + // { + // acknowledged: true + // } + }); diff --git a/doc/5/core-classes/collection/create/snippets/create-2.js b/doc/5/core-classes/collection/create/snippets/create-2.js new file mode 100644 index 000000000..8d12b6f8a --- /dev/null +++ b/doc/5/core-classes/collection/create/snippets/create-2.js @@ -0,0 +1,14 @@ +on +{ + "status": 200, + "error": null, + "requestId": "", + "controller": "collection", + "action": "create", + "collection": "", + "index": "index", + "volatile": null, + "result": { + "acknowledged": true + } +} diff --git a/doc/5/core-classes/collection/delete-document/index.md b/doc/5/core-classes/collection/delete-document/index.md new file mode 100644 index 000000000..e394843be --- /dev/null +++ b/doc/5/core-classes/collection/delete-document/index.md @@ -0,0 +1,66 @@ +--- +code: false +type: page +title: deleteDocument +description: Collection:deleteDocument +--- + +# deleteDocument + +Delete a stored document, or all stored documents matching a search filter. + +
+There is a small delay between the time a document is deleted and it being reflected in the search layer (usually a couple of seconds). That means that a document that was just deleted may still be returned by this function at first. +
+ +--- + +## deleteDocument(documentId, [options], [callback]) + +| Arguments | Type | Description | +| ------------ | ----------- | -------------------------- | +| `documentId` | string | Unique document identifier | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## deleteDocument(filters, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | +| `filters` | JSON object | Filters in [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl.html) format | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns an `array` containing the ids of the deleted documents. + +## Usage + +<<< ./snippets/delete-document-1.js + +> Callback response: + +```json +["AVCoeBkimsySTKTfa8AX"] +``` diff --git a/doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js b/doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js new file mode 100644 index 000000000..0bbffc1c5 --- /dev/null +++ b/doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js @@ -0,0 +1,29 @@ +// Deleting one document using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .deleteDocument('document unique ID', function (err, res) { + // callback called once the delete action has been completed + }); + +// Deleting one document using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .deleteDocumentPromise('document unique ID') + .then(res => { + // promises resolved once the delete action has been completed + }); + +// Deleting multiple documents using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .deleteDocument({filter: {equals: {title: 'foo'}}}, function (err, res) { + // callback called once the delete with query has been completed + }); + +// Deleting multiple documents using promises (NodeJS) + kuzzle + .collection('collection', 'index') + .deleteDocumentPromise({filter: {equals: {title: 'foo'}}}) + .then(res => { + // promise resolved once the delete by query has been completed + }); diff --git a/doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js b/doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js new file mode 100644 index 000000000..fa8c9067b --- /dev/null +++ b/doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js @@ -0,0 +1,2 @@ +on +[ "AVCoeBkimsySTKTfa8AX" ] diff --git a/doc/5/core-classes/collection/delete-specifications/index.md b/doc/5/core-classes/collection/delete-specifications/index.md new file mode 100644 index 000000000..c002c49e2 --- /dev/null +++ b/doc/5/core-classes/collection/delete-specifications/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: deleteSpecifications +description: Collection:deleteSpecifications +--- + +# deleteSpecifications + +Delete specifications linked to the collection object. + +--- + +## deleteSpecifications([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer indexation to return (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +## Usage + +<<< ./snippets/delete-specifications-1.js + +> Callback response: + +```json +{ + "acknowledged": true +} +``` diff --git a/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js b/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js new file mode 100644 index 000000000..f9634f346 --- /dev/null +++ b/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js @@ -0,0 +1,14 @@ +// Deleting specifications using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .deleteSpecifications(function (err, res) { + // callback called once the delete action has been completed + }); + +// Deleting specifications using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .deleteSpecificationsPromise() + .then(res => { + // promises resolved once the delete action has been completed + }); diff --git a/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js b/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js new file mode 100644 index 000000000..02d519956 --- /dev/null +++ b/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js @@ -0,0 +1,4 @@ +on +{ + "acknowledged": true +} diff --git a/doc/5/core-classes/collection/document/index.md b/doc/5/core-classes/collection/document/index.md new file mode 100644 index 000000000..542d6c44c --- /dev/null +++ b/doc/5/core-classes/collection/document/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: document +description: Collection:document +--- + +# document + +Creates a new [Document](/sdk/js/5/core-classes/document/) object, using its constructor. + +--- + +## document([id], [content]) + +| Arguments | Type | Description | +| --------- | ----------- | --------------------------- | +| `id` | string | Optional document unique ID | +| `content` | JSON object | Optional document content | + +--- + +## Return Value + +Returns the newly created [Document](/sdk/js/5/core-classes/document) object. + +## Usage + +<<< ./snippets/document-1.js diff --git a/doc/5/core-classes/collection/document/snippets/document-1.js b/doc/5/core-classes/collection/document/snippets/document-1.js new file mode 100644 index 000000000..49c67048a --- /dev/null +++ b/doc/5/core-classes/collection/document/snippets/document-1.js @@ -0,0 +1,4 @@ +let document = kuzzle + .collection('collection', 'index') + .document('id', {some: 'content'}) + .save(); diff --git a/doc/5/core-classes/collection/fetch-document/index.md b/doc/5/core-classes/collection/fetch-document/index.md new file mode 100644 index 000000000..c63060213 --- /dev/null +++ b/doc/5/core-classes/collection/fetch-document/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: fetchDocument +description: Collection:fetchDocument +--- + +# fetchDocument + +Retrieves a single stored document using its unique document ID, and returns it as a [Document](/sdk/js/5/core-classes/document/) object. + +--- + +## fetchDocument(documentId, [options], callback) + +| Arguments | Type | Description | +| ------------ | ----------- | ------------------------------ | +| `documentId` | string | Unique document identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a [Document](/sdk/js/5/core-classes/document/) object. + +## Usage + +<<< ./snippets/fetch-document-1.js diff --git a/doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js b/doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js new file mode 100644 index 000000000..d82379b82 --- /dev/null +++ b/doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .fetchDocument('documentId', function (error, result) { + // result is a Document object + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .fetchDocumentPromise('documentId') + .then(result => { + // result is a Document object + }); diff --git a/doc/5/core-classes/collection/get-mapping/index.md b/doc/5/core-classes/collection/get-mapping/index.md new file mode 100644 index 000000000..dacc65cc5 --- /dev/null +++ b/doc/5/core-classes/collection/get-mapping/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: getMapping +description: Collection:getMapping +--- + +# getMapping + +Retrieves the current mapping of this collection as a [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object. + +--- + +## getMapping([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object. + +## Usage + +<<< ./snippets/get-mapping-1.js diff --git a/doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js b/doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js new file mode 100644 index 000000000..f75d8bf5a --- /dev/null +++ b/doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .getMapping(function (error, result) { + // result is a CollectionMapping object + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .getMappingPromise() + .then(result => { + // result is a CollectionMapping object + }); diff --git a/doc/5/core-classes/collection/get-specifications/index.md b/doc/5/core-classes/collection/get-specifications/index.md new file mode 100644 index 000000000..c69581602 --- /dev/null +++ b/doc/5/core-classes/collection/get-specifications/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: getSpecifications +description: Collection:getSpecifications +--- + +# getSpecifications + +Retrieves the specifications linked to the collection object. + +--- + +## getSpecifications([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +## Usage + +<<< ./snippets/get-specifications-1.js + +> Callback response + +```json +{ + "validation": { + "strict": "true", + "fields": { + "foo": { + "mandatory": "true", + "type": "string", + "defaultValue": "bar" + } + } + }, + "index": "index", + "collection": "collection" +} +``` diff --git a/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js b/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js new file mode 100644 index 000000000..13e45d89b --- /dev/null +++ b/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .getSpecifications(function (error, specifications) { + // specifications is a JSON object + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .getSpecificationsPromise() + .then(specifications => { + // specifications is a JSON object + }); diff --git a/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js b/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js new file mode 100644 index 000000000..9cc82d578 --- /dev/null +++ b/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js @@ -0,0 +1,15 @@ +on +{ + "validation": { + "strict": "true", + "fields": { + "foo": { + "mandatory": "true", + "type": "string", + "defaultValue": "bar" + } + } + }, + "index": "index", + "collection": "collection" +} diff --git a/doc/5/core-classes/collection/index.md b/doc/5/core-classes/collection/index.md new file mode 100644 index 000000000..e8a690f15 --- /dev/null +++ b/doc/5/core-classes/collection/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: Collection +description: Collection documentation +--- diff --git a/doc/5/core-classes/collection/mcreate-document/index.md b/doc/5/core-classes/collection/mcreate-document/index.md new file mode 100644 index 000000000..5a1a539d9 --- /dev/null +++ b/doc/5/core-classes/collection/mcreate-document/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: mcreateDocument +description: Collection:mcreateDocument +--- + +# mCreateDocument + +Create the input [Documents](/sdk/js/5/core-classes/document/). + +--- + +## mCreateDocument(documents, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | -------------------------------------------------- | +| `documents` | Document[] | Array of [Document](/sdk/js/5/core-classes/document/) to create | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. +Can return a 206 partial error in cases where some documents could not be created. + +## Usage + +<<< ./snippets/mcreate-document-1.js + +> Callback response: + +```json +{ + "hits": [{ "first": "document" }, { "second": "document" }], + "total": 2 +} +``` diff --git a/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js b/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js new file mode 100644 index 000000000..e8391da56 --- /dev/null +++ b/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js @@ -0,0 +1,21 @@ +var + Document = require('./src/Document'), + firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), + secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .mCreateDocument([firstDocument, secondDocument], function (error, result) { + // callback called once the mCreate operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .mCreateDocumentPromise([firstDocument, secondDocument]) + .then(result => { + // promise resolved once the mCreate operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js b/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js new file mode 100644 index 000000000..6fe98f89d --- /dev/null +++ b/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js @@ -0,0 +1,8 @@ +on +{ + "hits": [ + {"first": "document"}, + {"second": "document"} + ], + "total": 2 +} diff --git a/doc/5/core-classes/collection/mcreate-or-replace-document/index.md b/doc/5/core-classes/collection/mcreate-or-replace-document/index.md new file mode 100644 index 000000000..4b23e9960 --- /dev/null +++ b/doc/5/core-classes/collection/mcreate-or-replace-document/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: mcreateOrReplaceDocument +description: Collection:mcreateOrReplaceDocument +--- + +# mCreateOrReplaceDocument + +Create or replace the input [Documents](/sdk/js/5/core-classes/document/). + +--- + +## mCreateOrReplaceDocument(documents, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | ------------------------------------------------------------- | +| `documents` | Document[] | Array of [Document](/sdk/js/5/core-classes/document/) to create or replace | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. +Can return a 206 partial error in cases where some documents could not be created or replaced. + +## Usage + +<<< ./snippets/mcreate-or-replace-document-1.js + +> Callback response: + +```json +{ + "hits": [{ "first": "document" }, { "second": "document" }], + "total": 2 +} +``` diff --git a/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js b/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js new file mode 100644 index 000000000..2a5d09fc1 --- /dev/null +++ b/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js @@ -0,0 +1,21 @@ +var + Document = require('./src/Document'), + firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), + secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .mCreateOrReplaceDocument([firstDocument, secondDocument], function (error, result) { + // callback called once the mCreateOrReplace operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .mCreateOrReplaceDocumentPromise([firstDocument, secondDocument]) + .then(result => { + // promise resolved once the mCreateOrReplace operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js b/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js new file mode 100644 index 000000000..6fe98f89d --- /dev/null +++ b/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js @@ -0,0 +1,8 @@ +on +{ + "hits": [ + {"first": "document"}, + {"second": "document"} + ], + "total": 2 +} diff --git a/doc/5/core-classes/collection/mdelete-document/index.md b/doc/5/core-classes/collection/mdelete-document/index.md new file mode 100644 index 000000000..0700851c9 --- /dev/null +++ b/doc/5/core-classes/collection/mdelete-document/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: mdeleteDocument +description: Collection:mdeleteDocument +--- + +# mDeleteDocument + +Delete multiple [Documents](/sdk/js/5/core-classes/document/) according to the input IDs. + +--- + +## mDeleteDocument(documentIds, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | ----------------------------------- | +| `documentIds` | String[] | Array of IDs of documents to delete | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. +Can return a 206 partial error in cases where some documents could not be deleted. + +## Usage + +<<< ./snippets/mdelete-document-1.js + +> Callback response: + +```json +["doc1", "doc2"] +``` diff --git a/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js b/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js new file mode 100644 index 000000000..78f4c6666 --- /dev/null +++ b/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js @@ -0,0 +1,16 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .mDeleteDocument(['doc1', 'doc2'], function (error, result) { + // callback called once the mDelete operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .mDeleteDocument() + .then(result => { + // promise resolved once the mDelete operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js b/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js new file mode 100644 index 000000000..ffd192655 --- /dev/null +++ b/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js @@ -0,0 +1,2 @@ +on +["doc1", "doc2"] diff --git a/doc/5/core-classes/collection/mget-document/index.md b/doc/5/core-classes/collection/mget-document/index.md new file mode 100644 index 000000000..57baa2a9d --- /dev/null +++ b/doc/5/core-classes/collection/mget-document/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: mgetDocument +description: Collection:mgetDocument +--- + +# mGetDocument + +Get multiple [Documents](/sdk/js/5/core-classes/document/) according to the input document IDs. + +--- + +## mGetDocument(documentIds, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------- | +| `documentIds` | String[] | Array of IDs of documents to retrieve | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. + +## Usage + +<<< ./snippets/mget-document-1.js + +> Callback response: + +```json +{ + "hits": [ + { "_id": "doc1", "first": "document" }, + { "_id": "doc2", "second": "document" } + ], + "total": 2 +} +``` diff --git a/doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js b/doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js new file mode 100644 index 000000000..9e1aa5e2a --- /dev/null +++ b/doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js @@ -0,0 +1,16 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .mGetDocument(['doc1', 'doc2'], function (error, result) { + // callback called once the mGet operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .mGetDocument() + .then(result => { + // promise resolved once the mGet operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js b/doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js new file mode 100644 index 000000000..c06286b24 --- /dev/null +++ b/doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js @@ -0,0 +1,8 @@ +on +{ + "hits": [ + {"_id": "doc1", "first": "document"}, + {"_id": "doc2", "second": "document"} + ], + "total": 2 +} diff --git a/doc/5/core-classes/collection/mreplace-document/index.md b/doc/5/core-classes/collection/mreplace-document/index.md new file mode 100644 index 000000000..ed5cb19fe --- /dev/null +++ b/doc/5/core-classes/collection/mreplace-document/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: mreplaceDocument +description: Collection:mreplaceDocument +--- + +# mReplaceDocument + +Replace the provided [Documents](/sdk/js/5/core-classes/document/). + +--- + +## mReplaceDocument(documents, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | --------------------------------------------------- | +| `documents` | Document[] | Array of [Document](/sdk/js/5/core-classes/document/) to replace | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. +Can return a 206 partial error in cases where documents could not be replaced. + +## Usage + +<<< ./snippets/mreplace-document-1.js + +> Callback response: + +```json +{ + "hits": [{ "first": "document" }, { "second": "document" }], + "total": 2 +} +``` diff --git a/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js b/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js new file mode 100644 index 000000000..39f54a680 --- /dev/null +++ b/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js @@ -0,0 +1,21 @@ +var + Document = require('./src/Document'), + firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), + secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .mReplaceDocument([firstDocument, secondDocument], function (error, result) { + // callback called once the mReplace operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .mReplaceDocument([firstDocument, secondDocument]) + .then(result => { + // promise resolved once the mReplace operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js b/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js new file mode 100644 index 000000000..6fe98f89d --- /dev/null +++ b/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js @@ -0,0 +1,8 @@ +on +{ + "hits": [ + {"first": "document"}, + {"second": "document"} + ], + "total": 2 +} diff --git a/doc/5/core-classes/collection/mupdate-document/index.md b/doc/5/core-classes/collection/mupdate-document/index.md new file mode 100644 index 000000000..f34f7c7f5 --- /dev/null +++ b/doc/5/core-classes/collection/mupdate-document/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: mupdateDocument +description: Collection:mupdateDocument +--- + +# mUpdateDocument + +Update the provided [Documents](/sdk/js/5/core-classes/document/). + +--- + +## mUpdateDocument(documents, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | --------------------------------------------------- | +| `documents` | Document[] | Array of [Documents](/sdk/js/5/core-classes/document/) to update | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. +Can return a 206 partial error in cases where documents could not be updated. + +## Usage + +<<< ./snippets/mupdate-document-1.js + +> Callback response: + +```json +{ + "hits": [{ "first": "document" }, { "second": "document" }], + "total": 2 +} +``` diff --git a/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js b/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js new file mode 100644 index 000000000..741c750a6 --- /dev/null +++ b/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js @@ -0,0 +1,21 @@ +var + Document = require('./src/Document'), + firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), + secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .mUpdateDocument([firstDocument, secondDocument], function (error, result) { + // callback called once the mUpdate operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .mUpdateDocument([firstDocument, secondDocument]) + .then(result => { + // promise resolved once the mUpdate operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js b/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js new file mode 100644 index 000000000..6fe98f89d --- /dev/null +++ b/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js @@ -0,0 +1,8 @@ +on +{ + "hits": [ + {"first": "document"}, + {"second": "document"} + ], + "total": 2 +} diff --git a/doc/5/core-classes/collection/publish-message/index.md b/doc/5/core-classes/collection/publish-message/index.md new file mode 100644 index 000000000..d490b23a7 --- /dev/null +++ b/doc/5/core-classes/collection/publish-message/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: publishMessage +description: Collection:publishMessage +--- + +# publishMessage + +Publish a real-time message. + +--- + +## publishMessage(Document, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------- | +| `Document` | object | [Document](/sdk/js/5/core-classes/document/) object | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## publishMessage(content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------- | +| `content` | JSON Object | Content of the document to publish | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | ------------------------------------------------------------- | ------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a raw Kuzzle response in JSON format. + +## Usage + +<<< ./snippets/publish-message-1.js diff --git a/doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js b/doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js new file mode 100644 index 000000000..d85010c11 --- /dev/null +++ b/doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js @@ -0,0 +1,3 @@ +kuzzle + .collection('collection', 'index') + .publishMessage({foo: 'bar', baz: 'qux'}); diff --git a/doc/5/core-classes/collection/replace-document/index.md b/doc/5/core-classes/collection/replace-document/index.md new file mode 100644 index 000000000..18547e5d0 --- /dev/null +++ b/doc/5/core-classes/collection/replace-document/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: replaceDocument +description: Collection:replaceDocument +--- + +# replaceDocument + +Replace an existing document and return the updated version as a [Document](/sdk/js/5/core-classes/document/) object. + +--- + +## replaceDocument(documentId, content, [options], [callback]) + +| Arguments | Type | Description | +| ------------ | ----------- | --------------------------------- | +| `documentId` | string | Unique document identifier | +| `content` | JSON Object | Content of the document to create | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns an updated [Document](/sdk/js/5/core-classes/document/) object. + +## Usage + +<<< ./snippets/replace-document-1.js diff --git a/doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js b/doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js new file mode 100644 index 000000000..886ddad72 --- /dev/null +++ b/doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .replaceDocument('documentId', {title: 'foo', content: 'bar'}, function (error, result) { + // result is a Document object + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .replaceDocumentPromise('documentId', {title: 'foo', content: 'bar'}) + .then(result => { + // result is a Document object + }); diff --git a/doc/5/core-classes/collection/room/index.md b/doc/5/core-classes/collection/room/index.md new file mode 100644 index 000000000..892651950 --- /dev/null +++ b/doc/5/core-classes/collection/room/index.md @@ -0,0 +1,32 @@ +--- +code: false +type: page +title: room +description: Collection:room +--- + +# room + +Creates a new [Room](/sdk/js/5/core-classes/room/) object, using its constructor. + +--- + +## room([options]) + +| Arguments | Type | Description | +| --------- | ------ | -------------------------- | +| `options` | object | Subscription configuration | + +## Options + +Provided options are passed directly to the [Room](/sdk/js/5/core-classes/room/) object constructor. + +--- + +## Return Value + +Returns the newly created [Room](/sdk/js/5/core-classes/room/) object. + +## Usage + +<<< ./snippets/room-1.js diff --git a/doc/5/core-classes/collection/room/snippets/room-1.js b/doc/5/core-classes/collection/room/snippets/room-1.js new file mode 100644 index 000000000..09dc3ff36 --- /dev/null +++ b/doc/5/core-classes/collection/room/snippets/room-1.js @@ -0,0 +1,6 @@ +let room = kuzzle + .collection('collection', 'index') + .room() + .renew({in: {field: ['some', 'new', 'filter']}}, function (err, res) { + // handle notifications + }); diff --git a/doc/5/core-classes/collection/scroll-specifications/index.md b/doc/5/core-classes/collection/scroll-specifications/index.md new file mode 100644 index 000000000..0a8209cb4 --- /dev/null +++ b/doc/5/core-classes/collection/scroll-specifications/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: scrollSpecifications +description: Collection:scrollSpecifications +--- + +# scrollSpecifications + +Returns a JSON object containing the next page of the scroll session, and the `scrollId` to be used in the next `scroll` action. +A scroll session is always initiated by a `searchSpecification` action with the `scroll` argument. + +--- + +## scrollSpecifications(scrollId, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------- | +| `scrollId` | string | The "scrollId" provided with the last scrollSpecifications response or from the initial searchSpecifications request | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `scroll` | string | Re-initializes the scroll session timeout to its value. If not defined, the scroll timeout is defaulted to a Kuzzle configuration | `undefined` | + +## Usage + +<<< ./snippets/scroll-specifications-1.js + +> Callback response + +```json +{ + "hits": [{ "first": "specification" }, { "second": "specification" }], + "total": 2 +} +``` diff --git a/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js b/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js new file mode 100644 index 000000000..7e766208a --- /dev/null +++ b/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js @@ -0,0 +1,22 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .scrollSpecifications(scrollId, {scroll: '1m'}, function (err, res) { + res.hits.forEach(function (specification) { + console.log(specification); + }); + + res.total // Total specifications count + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .scrollSpecificationsPromise(scrollId, {scroll: '1m'}) + .then(res => { + res.hits.forEach(specification => { + console.log(specification); + }); + + res.total // Total specifications count + }); diff --git a/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js b/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js new file mode 100644 index 000000000..4a4171ac0 --- /dev/null +++ b/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js @@ -0,0 +1,8 @@ +on +{ + "hits": [ + {"first": "specification"}, + {"second": "specification"} + ], + "total": 2 +} diff --git a/doc/5/core-classes/collection/scroll/index.md b/doc/5/core-classes/collection/scroll/index.md new file mode 100644 index 000000000..18d5b092d --- /dev/null +++ b/doc/5/core-classes/collection/scroll/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: scroll +description: Collection:scroll +--- + +# scroll + +Returns a [SearchResult](/sdk/js/5/core-classes/search-result/) object containing the next page of the scroll session, and the `scrollId` to be used in the next `scroll` action. +A scroll session is always initiated by a `search` action and including the `scroll` argument; more information below. + +
+There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first. +
+ +
+ To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search/). +
+ +--- + +## scroll(scrollId, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | +| `scrollId` | string | The "scrollId" provided with the last scroll response or from the initial search request if it is the first scroll call | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `scroll` | string | Re-initializes the scroll session timeout to its value. If not defined, the scroll timeout is defaulted to a Kuzzle configuration | `undefined` | + +--- + +## Callback Response + +Returns an instantiated [SearchResult](/sdk/js/5/core-classes/search-result) object. + +--- + +## Usage + +<<< ./snippets/scroll-1.js diff --git a/doc/5/core-classes/collection/scroll/snippets/scroll-1.js b/doc/5/core-classes/collection/scroll/snippets/scroll-1.js new file mode 100644 index 000000000..b3c99b51f --- /dev/null +++ b/doc/5/core-classes/collection/scroll/snippets/scroll-1.js @@ -0,0 +1,18 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .scroll(scrollId, {scroll: '1m'}, function (err, searchResult) { + searchResult.getDocuments().forEach(function (document) { + console.log(document.toString()); + }); + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .scrollPromise(scrollId, {scroll: '1m'}) + .then(searchResult => { + searchResult.getDocuments().forEach(document => { + console.log(document.toString()); + }); + }); diff --git a/doc/5/core-classes/collection/search-specifications/index.md b/doc/5/core-classes/collection/search-specifications/index.md new file mode 100644 index 000000000..4d52f516a --- /dev/null +++ b/doc/5/core-classes/collection/search-specifications/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: searchSpecifications +description: Collection:searchSpecifications +--- + +# searchSpecifications + +Retrieves every specifications across indexes/collections according to the given filters. + +--- + +## searchSpecifications(filters, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `filters` | JSON object | Search request body, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-body.html) format.
If given an empty object, matches all specifications across index/collections | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `from` | number | Provide the starting offset of the request (used to paginate results) | `0` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | +| `size` | number | Provide the maximum number of results of the request (used to paginate results) | `10` | + +## Usage + +<<< ./snippets/search-specifications-1.js + +> Callback response + +```json +{ + "hits": [{ "first": "specification" }, { "second": "specification" }], + "total": 2, + "scrollId": "foobar" +} +``` diff --git a/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js b/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js new file mode 100644 index 000000000..2f52e225a --- /dev/null +++ b/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js @@ -0,0 +1,33 @@ +const + filters = { + match_all: { + boost: 1 + } + }, + options= { + from: 0, + size: 20 + }; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .searchSpecifications(filters, options, function (err, res) { + res.hits.forEach(function (specification) { + console.log(specification); + }); + + res.total // Total specifications count + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .searchSpecificationsPromise(filters, options) + .then(res => { + res.hits.forEach(specification => { + console.log(specification); + }); + + res.total // Total specifications count + }); diff --git a/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js b/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js new file mode 100644 index 000000000..181748ef2 --- /dev/null +++ b/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js @@ -0,0 +1,9 @@ +on +{ + "hits": [ + {"first": "specification"}, + {"second": "specification"} + ], + "total": 2, + "scrollId": "foobar" +} diff --git a/doc/5/core-classes/collection/search/index.md b/doc/5/core-classes/collection/search/index.md new file mode 100644 index 000000000..609954730 --- /dev/null +++ b/doc/5/core-classes/collection/search/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: search +description: Collection:search +--- + +# search + +Executes a search on the collection. + +
+There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first. +
+ +## Processing large data sets + +When processing a large number of documents (i.e. more than 1000), using `search` is not always the best option. + +Pagination of results can be done by using the from and size but the cost becomes prohibitive when deep pagination is reached. In fact, Elasticsearch, Kuzzle's embedded database, limits results to 10,000 records by default. + +Instead, the recommended way to process a large number of documents is to use [`Collection.scroll`](/sdk/js/5/core-classes/collection/scroll/) or, easier, [`SearchResult.fetchNext`](/sdk/js/5/core-classes/search-result/fetch-next). + +See [`SearchResult.fetchNext`](/sdk/js/5/core-classes/search-result/fetch-next/#how-to-process-every-document-of-a-collection) for an example of how to process every document of a collection. + +--- + +## search(body, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `body` | JSON object | Search request body, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-body.html) format.
If given an empty object, matches all documents in the collection | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `from` | number | Provide the starting offset of the request (used to paginate results) | `0` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | +| `size` | number | Provide the maximum number of results of the request (used to paginate results) | `10` | + +
+ To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search/). +
+ +--- + +## Callback Response + +Returns an instance of [SearchResult](/sdk/js/5/core-classes/search-result). + +## Usage + +<<< ./snippets/search-1.js diff --git a/doc/5/core-classes/collection/search/snippets/search-1.js b/doc/5/core-classes/collection/search/snippets/search-1.js new file mode 100644 index 000000000..7f99a05f8 --- /dev/null +++ b/doc/5/core-classes/collection/search/snippets/search-1.js @@ -0,0 +1,61 @@ +const + body = { + query: { + bool: { + must: [ + { + terms: {status: ['idle', 'wantToHire', 'toHire', 'riding']} + }, + { + term: {type: 'cab'} + }, + { + geo_distance: { + distance: '10km', + pos: {lat: '48.8566140', lon: '2.352222'} + } + } + ] + } + }, + sort: [ + 'status', + { + _geo_distance : { + pos: {lat: '48.8566140', lon: '2.352222'}, + order : "asc" + } + }, + {date: "desc"} + ], + aggregations: { + aggs_name: { + terms: { + field: "field_name" + } + } + } + }, + options = { + from: 0, + size: 20 + }; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .search(body, options, function (err, searchResult) { + searchResult.getDocuments().forEach(function(document) { + console.log(document.toString()); + }); + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .searchPromise(body, options) + .then(searchResult => { + searchResult.getDocuments().forEach(document => { + console.log(document.toString()); + }); + }); diff --git a/doc/5/core-classes/collection/set-headers/index.md b/doc/5/core-classes/collection/set-headers/index.md new file mode 100644 index 000000000..a515777c0 --- /dev/null +++ b/doc/5/core-classes/collection/set-headers/index.md @@ -0,0 +1,31 @@ +--- +code: false +type: page +title: setHeaders +description: Collection:setHeaders +--- + +# setHeaders + +This is a helper function returning itself, allowing to easily set headers while chaining calls. + +--- + +## setHeaders(content, [replace]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------------------------------------------------------- | +| `content` | JSON Object | New content | +| `replace` | boolean | true: replace the current content with the provided data, false: merge it | + +**Note:** by default, the `replace` argument is set to `false` + +--- + +## Return value + +Returns the `Collection` object to allow chaining. + +## Usage + +<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js new file mode 100644 index 000000000..73417e559 --- /dev/null +++ b/doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js @@ -0,0 +1,6 @@ +kuzzle + .collection('collection', 'index') + .setHeaders({ + someContent: 'someValue', + volatile: { someVolatileData: ['with', 'some', 'values']} + }, true); diff --git a/doc/5/core-classes/collection/subscribe/index.md b/doc/5/core-classes/collection/subscribe/index.md new file mode 100644 index 000000000..a6ca04c71 --- /dev/null +++ b/doc/5/core-classes/collection/subscribe/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: subscribe +description: Collection:subscribe +--- + +# subscribe + +Subscribes to this collection with a set of filters. + +The provided callback will be called everytime a [notification](/sdk/js/5/essentials/realtime-notifications) is received from Kuzzle. + +--- + +## subscribe(filters, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------------------------------------- | +| `filters` | JSON Object | [Koncorde Filters](/core/1/koncorde) | +| `options` | object | (Optional) Subscription configuration. Passed to the Room constructor. | +| `callback` | function | Callback to call every time a notification is received on this subscription | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `scope` | string | Filter document notifications depending on their scope status. You may receive entering documents (scope: `in`), leaving documents (scope: `out`), all documents changes (scope: `all`) or filter these notifications completely (scope: `none`). This filter does not affect pub/sub messages or user events. | `all` | +| `state` | string | Filter document notifications depending on the state of the modifying request. You may receive real-time notifications when a document is about to be changed (state: `pending`), or be notified when the change has been fully written in the database (state: `done`), or both (state: `all`). This filter does not affect pub/sub messages or user events. | `done` | +| `subscribeToSelf` | boolean | (Don't) subscribe to notifications fired as a consequence of our own queries | `true` | +| `users` | string | Filter notifications fired upon a user entering the room (user: `in`), leaving the room (user: `out`), or both (user: `all`). Setting this variable to `none` prevents receiving these notifications | `none` | + +The `options` object is directly passed to the Room constructor. +See the [Room object](/sdk/js/5/core-classes/room/) documentation for more information about these options and notifications. + +--- + +## Return Value + +Returns an object exposing the following method: + `onDone(callback)` + +The `callback` argument is called when the subscription ends, either successfully or with an error. + +## Usage + +<<< ./snippets/subscribe-1.js diff --git a/doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js b/doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js new file mode 100644 index 000000000..4260d9623 --- /dev/null +++ b/doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js @@ -0,0 +1,10 @@ +kuzzle + .collection('collection', 'index') + .subscribe({equals: {title: 'foo'}}, function (error, result) { + // called each time a new notification on this filter is received + // check the Room/Notifications section of this documentation + // to get notification examples + }) + .onDone(function (err, roomObject) { + // Handles the subscription result. Can be chained. + }); diff --git a/doc/5/core-classes/collection/truncate/index.md b/doc/5/core-classes/collection/truncate/index.md new file mode 100644 index 000000000..e36c24832 --- /dev/null +++ b/doc/5/core-classes/collection/truncate/index.md @@ -0,0 +1,63 @@ +--- +code: false +type: page +title: truncate +description: Collection:truncate +--- + +# truncate + +Truncate the collection, removing all stored documents but keeping all associated mappings. + +This method is a lot faster than removing all documents using multiple delete requests. + +--- + +## truncate([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. + +## Usage + +<<< ./snippets/truncate-1.js + +> Callback response: + +```json +{ + "status": 200, + "error": null, + "requestId": "8fdc0efb-6fc7-427d-a3a1-fd8cf5eabc20", + "controller": "admin", + "action": "truncateCollection", + "collection": "name of the truncated collection", + "index": "name of the index containing the truncated collection", + "volatile": {}, + "state": "done", + "result": { "acknowledged": true } +} +``` diff --git a/doc/5/core-classes/collection/truncate/snippets/truncate-1.js b/doc/5/core-classes/collection/truncate/snippets/truncate-1.js new file mode 100644 index 000000000..dd29f22ca --- /dev/null +++ b/doc/5/core-classes/collection/truncate/snippets/truncate-1.js @@ -0,0 +1,16 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .truncate(function (error, result) { + // callback called once the truncate operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); + +// Using promises (NodeJS only) +kuzzle + .collection('collection', 'index') + .truncatePromise() + .then(result => { + // promise resolved once the truncate operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/collection/truncate/snippets/truncate-2.js b/doc/5/core-classes/collection/truncate/snippets/truncate-2.js new file mode 100644 index 000000000..467755810 --- /dev/null +++ b/doc/5/core-classes/collection/truncate/snippets/truncate-2.js @@ -0,0 +1,13 @@ +on +{ + "status": 200, + "error": null, + "requestId": "8fdc0efb-6fc7-427d-a3a1-fd8cf5eabc20", + "controller": "admin", + "action": "truncateCollection", + "collection": "name of the truncated collection", + "index": "name of the index containing the truncated collection", + "volatile": {}, + "state": "done", + "result": { "acknowledged": true } +} diff --git a/doc/5/core-classes/collection/update-document/index.md b/doc/5/core-classes/collection/update-document/index.md new file mode 100644 index 000000000..8892252d8 --- /dev/null +++ b/doc/5/core-classes/collection/update-document/index.md @@ -0,0 +1,49 @@ +--- +code: false +type: page +title: updateDocument +description: Collection:updateDocument +--- + +# updateDocument + +Update parts of a document, by replacing some fields or adding new ones. +Note that you cannot remove fields this way: missing fields will simply be left unchanged. + +--- + +## updateDocument(documentId, content, [options], [callback]) + +| Arguments | Type | Description | +| ------------ | ----------- | --------------------------------- | +| `documentId` | string | Unique document identifier | +| `content` | JSON object | Content of the document to create | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | +| `retryOnConflict` | int | Number of retries to attempt before rejecting this update because of a cluster sync conflict | `0` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +--- + +## Callback Response + +Returns an up-to-date [Document](/sdk/js/5/core-classes/document/) object. + +## Usage + +<<< ./snippets/update-document-1.js diff --git a/doc/5/core-classes/collection/update-document/snippets/update-document-1.js b/doc/5/core-classes/collection/update-document/snippets/update-document-1.js new file mode 100644 index 000000000..2bd52470f --- /dev/null +++ b/doc/5/core-classes/collection/update-document/snippets/update-document-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .updateDocument('documentId', {title: 'foo', content: 'bar'}, function (error, result) { + // result is a Document object + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .updateDocumentPromise('documentId', {title: 'foo', content: 'bar'}) + .then(result => { + // result is a Document object + }); diff --git a/doc/5/core-classes/collection/update-specifications/index.md b/doc/5/core-classes/collection/update-specifications/index.md new file mode 100644 index 000000000..354ccc70b --- /dev/null +++ b/doc/5/core-classes/collection/update-specifications/index.md @@ -0,0 +1,60 @@ +--- +code: false +type: page +title: updateSpecifications +description: Collection:updateSpecifications +--- + +# updateSpecifications + +Update parts of a specification, by replacing some fields or adding new ones. +Note that you cannot remove fields this way: missing fields will simply be left unchanged. + +--- + +## updateSpecifications(content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------- | +| `content` | JSON object | Content of the specification to update | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | +| `retryOnConflict` | int | Number of retries to attempt before rejecting this update because of a cluster sync conflict | `0` | + +--- + +## Return Value + +Returns the `Collection` object to allow chaining. + +## Usage + +<<< ./snippets/update-specifications-1.js + +> Callback response + +```json +{ + "index": { + "collection": { + "strict": "true", + "fields": { + "foo": { + "mandatory": "true", + "type": "string", + "defaultValue": "bar" + } + } + } + } +} +``` diff --git a/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js b/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js new file mode 100644 index 000000000..ea849af77 --- /dev/null +++ b/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js @@ -0,0 +1,25 @@ +var specifications = { + strict: 'true', + fields: { + foo: { + mandatory: true, + type: 'string', + defaultValue: 'bar' + } + } +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .updateSpecifications(specifications, function (err, res) { + // result is a JSON object + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .updateSpecificationsPromise(specifications) + .then(res => { + // result is a JSON object + }); diff --git a/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js b/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js new file mode 100644 index 000000000..97b002288 --- /dev/null +++ b/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js @@ -0,0 +1,15 @@ +on +{ + "index": { + "collection": { + "strict":"true", + "fields": { + "foo": { + "mandatory": "true", + "type": "string", + "defaultValue": "bar" + } + } + } + } +} diff --git a/doc/5/core-classes/collection/validate-specifications/index.md b/doc/5/core-classes/collection/validate-specifications/index.md new file mode 100644 index 000000000..d85c48fcf --- /dev/null +++ b/doc/5/core-classes/collection/validate-specifications/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: validateSpecifications +description: Collection:validateSpecifications +--- + +# validateSpecifications + +Validate a specification. + +--- + +## validateSpecifications(content, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------- | +| `content` | JSON object | Content of the specification to validate | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a boolean indicating whether or not the input specifications is valid or not. + +## Usage + +<<< ./snippets/validate-specifications-1.js diff --git a/doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js b/doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js new file mode 100644 index 000000000..a29110176 --- /dev/null +++ b/doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js @@ -0,0 +1,25 @@ +var specifications = { + strict: 'true', + fields: { + foo: { + mandatory: true, + type: 'string', + defaultValue: 'bar' + } + } +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .collection('collection', 'index') + .validateSpecifications(specifications, function (err, isValid) { + // isValid is a boolean + }); + +// Using promises (NodeJS) +kuzzle + .collection('collection', 'index') + .validateSpecificationsPromise(specifications) + .then(isValid => { + // isValid is a boolean + }); diff --git a/doc/5/core-classes/document/constructor/index.md b/doc/5/core-classes/document/constructor/index.md new file mode 100644 index 000000000..cb8b7b66b --- /dev/null +++ b/doc/5/core-classes/document/constructor/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: constructor +description: Document:constructor +order: 1 +--- + +# Document + +Kuzzle handles two types of documents: realtime messages and stored documents. Document is the object representation of one of these document types. + +--- + +## Document(Collection, [documentId], [content]) + +| Arguments | Type | Description | +| ------------ | ----------- | --------------------------------------------------- | +| `Collection` | object | An instantiated Collection object | +| `content` | JSON Object | Initializes this document with the provided content | +| `documentId` | string | ID of an existing document. | + +**Note:** this constructor won't make any call to Kuzzle. When providing only a document ID, the `refresh` method should be called to retrieve the corresponding document content. + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ------------- | ----------- | ----------------------------------------------- | ------- | +| `collection` | string | The collection associated to this document | get | +| `content` | JSON Object | The content of the document | get/set | +| `headers` | JSON Object | Common headers for all sent documents. | get/set | +| `id` | string | Unique document identifier | get/set | +| `meta` | JSON Object | Document metadata | get | +| `version` | integer | Current document version | get | + +**Notes:** + +- setting a new value to the `content` property is equivalent to calling `setContent(data, false)` +- setting a new value to the `id` property will force this value for this document +- the `headers` property is inherited from the provided `Collection` object and can be overrided + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/document/constructor/snippets/constructor-1.js b/doc/5/core-classes/document/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..18248e986 --- /dev/null +++ b/doc/5/core-classes/document/constructor/snippets/constructor-1.js @@ -0,0 +1,15 @@ +/* + Constructors are not exposed in the JS/Node SDK. + Document objects are returned by various Collection methods. + + You may also use the Collection.document() method: + */ +var document = kuzzle.collection('collection', 'index').document('id'); + +document = kuzzle + .collection('collection', 'index') + .document({content: 'some content'}); + +document = kuzzle + .collection('collection', 'index') + .document('id', {content: 'some content'}); diff --git a/doc/5/core-classes/document/delete/index.md b/doc/5/core-classes/document/delete/index.md new file mode 100644 index 000000000..db330b06d --- /dev/null +++ b/doc/5/core-classes/document/delete/index.md @@ -0,0 +1,39 @@ +--- +code: false +type: page +title: delete +description: Document:delete +--- + +# delete + +Deletes this document in Kuzzle. + +--- + +## delete([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Callback Response + +Returns a string containing the ID of the deleted document. + +## Usage + +<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/document/delete/snippets/delete-1.js b/doc/5/core-classes/document/delete/snippets/delete-1.js new file mode 100644 index 000000000..6236c9c6f --- /dev/null +++ b/doc/5/core-classes/document/delete/snippets/delete-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +document.delete(function (error, result) { + // called once the delete action has been completed +}); + +// Using promises (NodeJS) +document.deletePromise().then(result => { + // called once the delete action has been completed +}); diff --git a/doc/5/core-classes/document/exists/index.md b/doc/5/core-classes/document/exists/index.md new file mode 100644 index 000000000..3eba069fc --- /dev/null +++ b/doc/5/core-classes/document/exists/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: exists +description: Document:exists +--- + +# exists + +Checks if the document exists in Kuzzle. + +--- + +## exists([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Return a boolean indicating whether or not the document exists in Kuzzle. + +## Usage + +<<< ./snippets/exists-1.js diff --git a/doc/5/core-classes/document/exists/snippets/exists-1.js b/doc/5/core-classes/document/exists/snippets/exists-1.js new file mode 100644 index 000000000..4023ef1fc --- /dev/null +++ b/doc/5/core-classes/document/exists/snippets/exists-1.js @@ -0,0 +1,4 @@ +// Using callbacks (NodeJS or Web Browser) +document.exists(function (error, exists) { + // called once the exists check has been completed +}); diff --git a/doc/5/core-classes/document/index.md b/doc/5/core-classes/document/index.md new file mode 100644 index 000000000..83afce740 --- /dev/null +++ b/doc/5/core-classes/document/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: Document +description: Document documentation +--- diff --git a/doc/5/core-classes/document/publish/index.md b/doc/5/core-classes/document/publish/index.md new file mode 100644 index 000000000..0b8683c19 --- /dev/null +++ b/doc/5/core-classes/document/publish/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: publish +description: Document:publish +--- + +# publish + +Publishes the content of this document as a real-time message. + +--- + +## publish([options]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | ------------------------------------------------------------- | ------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns this `Document` object to allow chaining. + +## Usage + +<<< ./snippets/publish-1.js diff --git a/doc/5/core-classes/document/publish/snippets/publish-1.js b/doc/5/core-classes/document/publish/snippets/publish-1.js new file mode 100644 index 000000000..984a19847 --- /dev/null +++ b/doc/5/core-classes/document/publish/snippets/publish-1.js @@ -0,0 +1 @@ +document.publish(); diff --git a/doc/5/core-classes/document/refresh/index.md b/doc/5/core-classes/document/refresh/index.md new file mode 100644 index 000000000..946629af3 --- /dev/null +++ b/doc/5/core-classes/document/refresh/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: refresh +description: Document:refresh +--- + +# refresh + +Creates a new `Document` object with the last version of this document stored in Kuzzle. + +--- + +## refresh([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Return a new `Document` object containing the last document version. + +## Usage + +<<< ./snippets/refresh-1.js diff --git a/doc/5/core-classes/document/refresh/snippets/refresh-1.js b/doc/5/core-classes/document/refresh/snippets/refresh-1.js new file mode 100644 index 000000000..719626798 --- /dev/null +++ b/doc/5/core-classes/document/refresh/snippets/refresh-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +document.refresh(function (error, result) { + // called once the refresh action has been completed +}); + +// Using promises (NodeJS) +document.refreshPromise().then(result => { + // called once the refresh action has been completed +}); diff --git a/doc/5/core-classes/document/save/index.md b/doc/5/core-classes/document/save/index.md new file mode 100644 index 000000000..07da6e4be --- /dev/null +++ b/doc/5/core-classes/document/save/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: save +description: Document:save +--- + +# save + +Saves this document into Kuzzle. + +If this is a new document, this function will create it in Kuzzle and the `id` property will be made available. +Otherwise, this method will replace the latest version of the document in Kuzzle with the content of this current object. + +--- + +## save([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns this `Document` object to allow chaining. + +--- + +## Callback Response + +Return this `Document` object once the document has been saved. + +## Usage + +<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/document/save/snippets/save-1.js b/doc/5/core-classes/document/save/snippets/save-1.js new file mode 100644 index 000000000..d16b8379e --- /dev/null +++ b/doc/5/core-classes/document/save/snippets/save-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +document.save(function (error, result) { + // called once the save action has been completed +}); + +// Using promises (NodeJS) +document.savePromise().then(result => { + // called once the save action has been completed +}); diff --git a/doc/5/core-classes/document/set-content/index.md b/doc/5/core-classes/document/set-content/index.md new file mode 100644 index 000000000..a0dfd6396 --- /dev/null +++ b/doc/5/core-classes/document/set-content/index.md @@ -0,0 +1,36 @@ +--- +code: false +type: page +title: setContent +description: Document:setContent +--- + +# setContent + +Replaces the current content with new data. +This is a helper function returning a reference to itself so that you can easily chain calls. + +
+Changes made by this function won't be applied until the save method is called +
+ +--- + +## setContent(data, [replace]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------------------------------------------------------- | +| `data` | JSON Object | New content | +| `replace` | boolean | true: replace the current content with the provided data, false: merge it | + +**Note:** by default, the `replace` argument is set to `false` + +--- + +## Return Value + +Returns this `Document` object to allow chaining. + +## Usage + +<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/document/set-content/snippets/set-content-1.js b/doc/5/core-classes/document/set-content/snippets/set-content-1.js new file mode 100644 index 000000000..94179832c --- /dev/null +++ b/doc/5/core-classes/document/set-content/snippets/set-content-1.js @@ -0,0 +1 @@ +document.setContent({newContent: 'someValue'}, true); diff --git a/doc/5/core-classes/document/set-headers/index.md b/doc/5/core-classes/document/set-headers/index.md new file mode 100644 index 000000000..11907035e --- /dev/null +++ b/doc/5/core-classes/document/set-headers/index.md @@ -0,0 +1,31 @@ +--- +code: false +type: page +title: setHeaders +description: Document:setHeaders +--- + +# setHeaders + +This is a helper function returning itself, allowing to easily chain calls. + +--- + +## setHeaders(content, [replace]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------------------------------------------------------- | +| `content` | JSON Object | New content | +| `replace` | boolean | true: replace the current content with the provided data, false: merge it | + +**Note:** by default, the `replace` argument is set to `false` + +--- + +## Return value + +Returns this `Document` object to allow chaining. + +## Usage + +<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/document/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/document/set-headers/snippets/set-headers-1.js new file mode 100644 index 000000000..42f05bc62 --- /dev/null +++ b/doc/5/core-classes/document/set-headers/snippets/set-headers-1.js @@ -0,0 +1 @@ +document.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/document/subscribe/index.md b/doc/5/core-classes/document/subscribe/index.md new file mode 100644 index 000000000..93b07d030 --- /dev/null +++ b/doc/5/core-classes/document/subscribe/index.md @@ -0,0 +1,41 @@ +--- +code: false +type: page +title: subscribe +description: Document:subscribe +--- + +# subscribe + +Listens to changes occuring in this document. +Throws an error if this document has not yet been created in Kuzzle. + +The provided callback will be called everytime a [notification](/sdk/js/5/essentials/realtime-notifications) is received from Kuzzle. + +--- + +## subscribe([options], callback) + +| Arguments | Type | Description | +| ---------- | -------- | ---------------------------------------------------------------------------------- | +| `options` | object | Subscription configuration | +| `callback` | function | Callback that will be called each time a change has been detected on this document | + +--- + +## Options + +Options are directly passed to the [Room](/sdk/js/5/core-classes/room/) object constructor. + +--- + +## Return Value + +Returns an object exposing the following method: + `onDone(callback)` + +The `callback` argument is called when the subscription ends, either successfully or with an error. + +## Usage + +<<< ./snippets/subscribe-1.js diff --git a/doc/5/core-classes/document/subscribe/snippets/subscribe-1.js b/doc/5/core-classes/document/subscribe/snippets/subscribe-1.js new file mode 100644 index 000000000..a412af97c --- /dev/null +++ b/doc/5/core-classes/document/subscribe/snippets/subscribe-1.js @@ -0,0 +1,15 @@ +document + .subscribe(function (error, notification) { + // called each time a change occurs on this document + }) + .onDone(function (error, roomObject) { + // Handles the subscription result + }); + +document + .subscribe({subscribeToSelf: true, volatile: { myId: 'someId'}}, function (error, notification) { + // called each time a change occurs on this document + }) + .onDone(function (error, roomObject) { + // Handles the subscription result + }); diff --git a/doc/5/core-classes/index.md b/doc/5/core-classes/index.md new file mode 100644 index 000000000..736c461bc --- /dev/null +++ b/doc/5/core-classes/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 100 +title: Core Classes +description: Javascript SDK v5.x core classes +--- diff --git a/doc/5/core-classes/kuzzle/add-listener/index.md b/doc/5/core-classes/kuzzle/add-listener/index.md new file mode 100644 index 000000000..e85a6b101 --- /dev/null +++ b/doc/5/core-classes/kuzzle/add-listener/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: addListener +description: Kuzzle:addListener +--- + +# addListener + +Adds a listener to an event. When an event is fired, listeners are called in the order that they are added. + +--- + +## addListener(event, listener) + +| Arguments | Type | Description | +| ---------- | -------- | -------------------------------------------------------------------------------- | +| `event` | string | One of the event described in the `Event Handling` section of this documentation | +| `listener` | function | The function to call each time one of the registered event is fired | + +--- + +## Return Value + +Returns the `Kuzzle` object to allow chaining. + +## Usage + +<<< ./snippets/add-listener-1.js diff --git a/doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js b/doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js new file mode 100644 index 000000000..78860fa65 --- /dev/null +++ b/doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js @@ -0,0 +1,4 @@ + var callback = function () { + // Actions to perform when receiving a 'connected' global event + }; + kuzzle.addListener('connected', callback); diff --git a/doc/5/core-classes/kuzzle/check-token/index.md b/doc/5/core-classes/kuzzle/check-token/index.md new file mode 100644 index 000000000..bfc6698ea --- /dev/null +++ b/doc/5/core-classes/kuzzle/check-token/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: checkToken +description: Kuzzle:checkToken +--- + +# checkToken + +> Callback response if the token is valid: + +```json +{ + "expiresAt": 1454588077399, + "valid": true +} +``` + +> Callback response if the token is invalid: + +```json +{ + "valid": false, + "state": "" +} +``` + +Checks the validity of a JSON Web Token. + +
+This method is non-queuable, meaning that during offline mode, it will be discarded and the callback return an error. +
+ +--- + +## checkToken(token, callback) + +| Arguments | Type | Description | +| ---------- | -------- | ------------------------------ | +| `token` | string | The token to check | +| `callback` | function | Callback handling the response | + +**Note:** this method sends an unauthenticated API call to Kuzzle, meaning it ignores the JWT Token property, even if it has been set. + +--- + +## Callback Response + +Returns a JSON object with a `valid` boolean property. +If the token is valid, an `expiresAt` property is set with the expiration timestamp. If not, a `state` property is set explaining why the token is invalid. + +## Usage + +<<< ./snippets/check-token-1.js diff --git a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js new file mode 100644 index 000000000..6be6881e1 --- /dev/null +++ b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.checkToken(token, function (err, res) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle.checkTokenPromise(token) + .then(res => { + // ... + }); diff --git a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js new file mode 100644 index 000000000..4b1fde6f2 --- /dev/null +++ b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js @@ -0,0 +1,5 @@ +on +{ + "expiresAt": 1454588077399, + "valid": true +} diff --git a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js new file mode 100644 index 000000000..6ee92f464 --- /dev/null +++ b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js @@ -0,0 +1,5 @@ +on +{ + "valid": false, + "state": "" +} diff --git a/doc/5/core-classes/kuzzle/collection/index.md b/doc/5/core-classes/kuzzle/collection/index.md new file mode 100644 index 000000000..ae8febbf0 --- /dev/null +++ b/doc/5/core-classes/kuzzle/collection/index.md @@ -0,0 +1,33 @@ +--- +code: false +type: page +title: collection +description: Kuzzle:collection +--- + +# collection + +Instantiates a new [Collection](/sdk/js/5/core-classes/collection) object. + +--- + +## collection(collection, [index]) + +| Arguments | Type | Description | +| ------------ | ------ | ------------------------------------------------------ | +| `collection` | string | The name of the collection you want to manipulate | +| `index` | string | The name of the index containing the collection | + +If no `index` is provided, the factory will take the default index set in the main Kuzzle SDK instance. If no default index has been set, an error is thrown. + +The `index` argument takes precedence over the default index. + +--- + +## Return Value + +Returns a [Collection](/sdk/js/5/core-classes/collection) object. + +## Usage + +<<< ./snippets/collection-1.js diff --git a/doc/5/core-classes/kuzzle/collection/snippets/collection-1.js b/doc/5/core-classes/kuzzle/collection/snippets/collection-1.js new file mode 100644 index 000000000..f1a0285cf --- /dev/null +++ b/doc/5/core-classes/kuzzle/collection/snippets/collection-1.js @@ -0,0 +1,7 @@ +var collection = kuzzle.collection('collection', 'index'); + +// or using a default index: +var + kuzzle = new Kuzzle('localhost', {defaultIndex: 'index'}); + +collection = kuzzle.collection('collection'); diff --git a/doc/5/core-classes/kuzzle/connect/index.md b/doc/5/core-classes/kuzzle/connect/index.md new file mode 100644 index 000000000..53925694a --- /dev/null +++ b/doc/5/core-classes/kuzzle/connect/index.md @@ -0,0 +1,27 @@ +--- +code: false +type: page +title: connect +description: Kuzzle:connect +--- + +# connect + +Connects to Kuzzle using the `host` parameter provided in the constructor. +Has no effect if `connect` is set to `auto`, unless `disconnect` has been called first. + +--- + +## Return value + +Returns the `Kuzzle` object to allow chaining. + +--- + +## Callback Response + +If a callback has been provided to the `Kuzzle` constructor, it will be called with the `Kuzzle` instance once connected to Kuzzle + +## Usage + +<<< ./snippets/connect-1.js diff --git a/doc/5/core-classes/kuzzle/connect/snippets/connect-1.js b/doc/5/core-classes/kuzzle/connect/snippets/connect-1.js new file mode 100644 index 000000000..599a215cd --- /dev/null +++ b/doc/5/core-classes/kuzzle/connect/snippets/connect-1.js @@ -0,0 +1 @@ +kuzzle.connect(); diff --git a/doc/5/core-classes/kuzzle/constructor/index.md b/doc/5/core-classes/kuzzle/constructor/index.md new file mode 100644 index 000000000..a99a5d2b2 --- /dev/null +++ b/doc/5/core-classes/kuzzle/constructor/index.md @@ -0,0 +1,95 @@ +--- +code: false +type: page +title: Kuzzle +description: Entry point and main class for the entire SDK +order: 100 +--- + +# Constructor + +This is the main entry point to communicate with Kuzzle. Every other object inherits properties from the `Kuzzle` object. + +--- + +## Kuzzle(host, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------- | +| `host` | string | The server name (or the IP address) of a Kuzzle server installation | +| `options` | JSON object | Optional Kuzzle connection configuration | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ------------------- | ----------- | ------------------------------------------------------------------ | -------- | +| `autoQueue` | boolean | Automatically queue all requests during offline mode | `false` | +| `autoReconnect` | boolean | Automatically reconnect after a connection loss | `true` | +| `autoReplay` | boolean | Automatically replay queued requests on a `reconnected` event | `false` | +| `autoResubscribe` | boolean | Automatically renew all subscriptions on a `reconnected` event | `true` | +| `connect` | string | Manually or automatically connect to the Kuzzle instance | `auto` | +| `defaultIndex` | string | Set the default index to use | | +| `headers` | JSON object | Common headers for all sent documents | | +| `volatile` | JSON object | Common volatile data, will be sent to all future requests | | +| `offlineMode` | string | Offline mode configuration | `manual` | +| `port` | integer | Kuzzle network port | 7512 | +| `queueTTL` | integer | Time a queued request is kept during offline mode, in milliseconds | `120000` | +| `queueMaxSize` | integer | Number of maximum requests kept during offline mode | `500` | +| `replayInterval` | integer | Delay between each replayed requests, in milliseconds | `10` | +| `reconnectionDelay` | integer | number of milliseconds between reconnection attempts | `1000` | +| `sslConnection` | boolean | Switch Kuzzle connection to SSL mode | `false` | + +**Notes:** + +- the `offlineMode` option only accepts the `manual` and `auto` values + +--- + +## Properties + +| Property name | Type | Description | Writable? | +| -------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | :-------: | +| `autoQueue` | boolean | Automatically queue all requests during offline mode | Yes | +| `autoReconnect` | boolean | Automatically reconnect after a connection loss | No | +| `autoReplay` | boolean | Automatically replay queued requests on a `reconnected` event | Yes | +| `autoResubscribe` | boolean | Automatically renew all subscriptions on a `reconnected` event | No | +| `defaultIndex` | string | Kuzzle's default index to use | Yes | +| `headers` | JSON object | Common headers for all sent documents. | Yes | +| `host` | string | Target Kuzzle host name/address | No | +| `jwtToken` | string | Token used in requests for authentication. | Yes | +| `offlineQueue` | JSON object | Contains the queued requests during offline mode | No | +| `offlineQueueLoader` | function | Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue | Yes | +| `port` | integer | Kuzzle network port | No | +| `queueFilter` | function | Called during offline mode. Takes a request object as arguments and returns a boolean, indicating if a request can be queued | Yes | +| `queueMaxSize` | integer | Number of maximum requests kept during offline mode | Yes | +| `queueTTL` | integer | Time a queued request is kept during offline mode, in milliseconds | Yes | +| `replayInterval` | integer | Delay between each replayed requests | Yes | +| `reconnectionDelay` | integer | Number of milliseconds between reconnection attempts | No | +| `sslConnection` | boolean | Connect to Kuzzle using SSL | No | +| `volatile` | JSON object | Common volatile data, will be sent to all future requests | Yes | + +**Notes:** + +- if `connect` is set to `manual`, the `connect` method will have to be called manually +- the kuzzle instance will automatically queue all requests, and play them automatically once a first connection is established, regardless of the `connect` or offline mode option values. +- multiple methods allow passing specific `volatile` data. These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones. +- the `queueFilter` property is a function taking a JSON object as an argument. This object is the request sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format +- if `queueTTL` is set to `0`, requests are kept indefinitely +- The offline buffer acts like a first-in first-out (FIFO) queue, meaning that if the `queueMaxSize` limit is reached, older requests are discarded to make room for new requests +- if `queueMaxSize` is set to `0`, an unlimited number of requests is kept until the buffer is flushed +- the `offlineQueueLoader` must be set with a function, taking no argument, and returning an array of objects containing a `query` member with a Kuzzle query to be replayed, and an optional `cb` member with the corresponding callback to invoke with the query result +- updates to `host`, `port`, `autoReconnect`, `reconnectionDelay` and `sslConnection` properties will only take effect on next `connect` call + +--- + +## Callback response + +If the connection succeeds, resolves to the `Kuzzle` object itself. +If the `connect` option is set to `manual`, the callback will be called after the `connect` method is resolved. + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js b/doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..3662b82eb --- /dev/null +++ b/doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js @@ -0,0 +1,11 @@ +var kuzzle = new Kuzzle('localhost', { + defaultIndex: 'some index', + autoReconnect: true, + headers: {someheader: "value"}, + port: 7512 +}); + +// A callback is also available and will be invoked once connected to the Kuzzle instance: +kuzzle = new Kuzzle('localhost', function (err, res) { + // ... +}); diff --git a/doc/5/core-classes/kuzzle/create-index/index.md b/doc/5/core-classes/kuzzle/create-index/index.md new file mode 100644 index 000000000..025c48f4b --- /dev/null +++ b/doc/5/core-classes/kuzzle/create-index/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: createIndex +description: Kuzzle:createIndex +--- + +# createIndex + +Create a new empty index, with no associated mapping. + +--- + +## createIndex([index], [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------------------------------------------------------------- | +| `index` | string | Optional index to query. If no set, defaults to [Kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties) | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the index creation status. + +## Usage + +<<< ./snippets/create-index-1.js + +> Callback response: + +```json +{ + "acknowledged": true, + "shards_acknowledged": true +} +``` diff --git a/doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js b/doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js new file mode 100644 index 000000000..1d719b3b1 --- /dev/null +++ b/doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js @@ -0,0 +1,13 @@ +// Using callbacks (node.js or browser) +kuzzle.createIndex('myIndex', function (err, res) { + // callback called once the create operation has completed + // => the result is a JSON object containing the raw Kuzzle response +}); + +// Using promises (node.js) +kuzzle + .createIndexPromise('myIndex') + .then(res => { + // promise resolved once the create operation has completed + // => the result is a JSON object containing the raw Kuzzle response + }); diff --git a/doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js b/doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js new file mode 100644 index 000000000..35daced6f --- /dev/null +++ b/doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js @@ -0,0 +1,5 @@ +on +{ + "acknowledged": true, + "shards_acknowledged": true +} diff --git a/doc/5/core-classes/kuzzle/create-my-credentials/index.md b/doc/5/core-classes/kuzzle/create-my-credentials/index.md new file mode 100644 index 000000000..47880f5dc --- /dev/null +++ b/doc/5/core-classes/kuzzle/create-my-credentials/index.md @@ -0,0 +1,39 @@ +--- +code: false +type: page +title: createMyCredentials +description: Kuzzle:createMyCredentials +--- + +# createMyCredentials + +Create the current user's credentials for the specified strategy. The credentials required will depend on the authentication plugin and strategy. + +--- + +## createMyCredentials(strategy, credentials, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------- | +| `strategy` | string | Strategy you want to create credentials for | +| `credentials` | JSON object | The credentials | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the created credentials. + +## Usage + +<<< ./snippets/create-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js b/doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js new file mode 100644 index 000000000..926313a6e --- /dev/null +++ b/doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js @@ -0,0 +1,11 @@ +// Using callbacks (node.js or browser) +kuzzle.createMyCredentials('local', {'username': 'foo'}, function (err, res) { + console.log(res); // {username: 'bar', kuid: ''} +}); + +// Using promises (node.js) +kuzzle + .createMyCredentials('local', {'username': 'foo'}) + .then(res => { + console.log(res); // {username: 'foo', kuid: ''} + }); diff --git a/doc/5/core-classes/kuzzle/delete-my-credentials/index.md b/doc/5/core-classes/kuzzle/delete-my-credentials/index.md new file mode 100644 index 000000000..500d333e9 --- /dev/null +++ b/doc/5/core-classes/kuzzle/delete-my-credentials/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: deleteMyCredentials +description: Kuzzle:deleteMyCredentials +--- + +# deleteMyCredentials + +Delete the current user's credentials for the specified `strategy`. + +--- + +## deleteMyCredentials(strategy, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------- | +| `strategy` | string | Strategy you want to delete credentials from | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the query status. + +## Usage + +<<< ./snippets/delete-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js b/doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js new file mode 100644 index 000000000..2903370c8 --- /dev/null +++ b/doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js @@ -0,0 +1,11 @@ +// Using callbacks (node.js or browser) +kuzzle.deleteMyCredentials('local', function (err, res) { + console.log(res); // {acknowledged: true} +}); + +// Using promises (node.js) +kuzzle + .deleteMyCredentials('local') + .then(res => { + console.log(res); // {acknowledged: true} + }); diff --git a/doc/5/core-classes/kuzzle/disconnect/index.md b/doc/5/core-classes/kuzzle/disconnect/index.md new file mode 100644 index 000000000..57a6f0842 --- /dev/null +++ b/doc/5/core-classes/kuzzle/disconnect/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: disconnect +description: Kuzzle:disconnect +--- + +# disconnect + +Closes the current connection, and frees all allocated resources. +Contrary to the `offline` state (when the network connection is unexpectedly lost), `disconnect()` invalidates the instance, which cannot be used until [connect()](/sdk/js/5/core-classes/kuzzle/connect) is explicitly called. +This action does not trigger a `disconnected` event since this event is triggered when an unexpected disconnection occur. + +## Usage + +<<< ./snippets/disconnect-1.js diff --git a/doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js b/doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js new file mode 100644 index 000000000..e7a7f4d6e --- /dev/null +++ b/doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js @@ -0,0 +1 @@ +kuzzle.disconnect(); diff --git a/doc/5/core-classes/kuzzle/flush-queue/index.md b/doc/5/core-classes/kuzzle/flush-queue/index.md new file mode 100644 index 000000000..8409cb448 --- /dev/null +++ b/doc/5/core-classes/kuzzle/flush-queue/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: flushQueue +description: Kuzzle:flushQueue +--- + +# flushQueue + +Empties the offline queue without replaying it. + +--- + +## Return Value + +Returns the `Kuzzle` SDK instance to allow chaining. + +## Usage + +<<< ./snippets/flush-queue-1.js diff --git a/doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js b/doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js new file mode 100644 index 000000000..8dc566cd5 --- /dev/null +++ b/doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js @@ -0,0 +1 @@ +kuzzle.flushQueue(); diff --git a/doc/5/core-classes/kuzzle/get-all-statistics/index.md b/doc/5/core-classes/kuzzle/get-all-statistics/index.md new file mode 100644 index 000000000..d4419693d --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-all-statistics/index.md @@ -0,0 +1,66 @@ +--- +code: false +type: page +title: getAllStatistics +description: Kuzzle:getAllStatistics +--- + +# getAllStatistics + +> Callback response example: + +```json +[ + { + "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "mqtt": 37, "socketio": 17 }, + "failedRequests": { "socketio": 1 }, + "timestamp": "1453110641308" + }, + { + "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "socketio": 34 }, + "failedRequests": { "socketio": 3 }, + "timestamp": "1453110642308" + }, + { + "connections": {}, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "socketio": 40 }, + "failedRequests": {}, + "timestamp": "1453110643308" + } +] +``` + +Kuzzle monitors active connections, and ongoing/completed/failed requests. +This method returns all available statistics from Kuzzle. + +--- + +## getAllStatistics([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +### Callback Response + +Returns an array of JSON objects that each contain a statistics frame. + +## Usage + +<<< ./snippets/get-all-statistics-1.js diff --git a/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js b/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js new file mode 100644 index 000000000..058f42f39 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js @@ -0,0 +1,15 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.getAllStatistics(function (err, stats) { + stats.forEach(function (frame) { + // loop through all returned frames + }); +}); + +// Using promises (NodeJS only) +kuzzle + .getAllStatisticsPromise() + .then(stats => { + stats.forEach(function (frame) { + // loop through all returned frames + }); + }); diff --git a/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js b/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js new file mode 100644 index 000000000..cdc4bb943 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js @@ -0,0 +1,16 @@ +on +[{ "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "mqtt": 37, "socketio": 17 }, + "failedRequests": { "socketio": 1 }, + "timestamp": "1453110641308" }, + { "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "socketio": 34 }, + "failedRequests": { "socketio": 3 }, + "timestamp": "1453110642308" }, + { "connections": {}, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "socketio": 40 }, + "failedRequests": {}, + "timestamp": "1453110643308" }] diff --git a/doc/5/core-classes/kuzzle/get-auto-refresh/index.md b/doc/5/core-classes/kuzzle/get-auto-refresh/index.md new file mode 100644 index 000000000..602f3dc51 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-auto-refresh/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: getAutoRefresh +description: Kuzzle:getAutoRefresh +--- + +# getAutoRefresh + +The `autoRefresh` flag, when set to true, will make Kuzzle perform a +[`refresh`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html) request +immediately after each write request, causing documents to be immediately visible in a search. + +The `getAutoRefresh` function returns the current `autoRefresh` status for the given index. + +
+

+ A refresh operation comes with some performance costs. +

+

+ While forcing the autoRefresh can be convenient on a development or test environmnent, we recommend that you avoid + using it in production or at least carefully monitor its implications before using it. +

+
+ +--- + +#### getAutoRefresh([index], [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------------------------------------------------------------- | +| `index` | string | Optional index to query. If no set, defaults to [Kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties) | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a boolean with the index `autoRefresh` status. + +## Usage + +<<< ./snippets/get-auto-refresh-1.js diff --git a/doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js b/doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js new file mode 100644 index 000000000..6e5e6e536 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js @@ -0,0 +1,11 @@ +// Using callbacks (node.js or browser) +kuzzle.getAutoRefresh('myIndex', function (err, autoRefresh) { + console.log(autoRefresh); // true|false +}); + +// Using promises (node.js) +kuzzle + .getAutoRefreshPromise('myIndex') + .then(autoRefresh => { + console.log(autoRefresh); // true|false + }); diff --git a/doc/5/core-classes/kuzzle/get-jwt-token/index.md b/doc/5/core-classes/kuzzle/get-jwt-token/index.md new file mode 100644 index 000000000..3bb975114 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-jwt-token/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: getJwtToken +description: Kuzzle:getJwtToken +--- + +# getJwtToken + +Get internal jwtToken used to request kuzzle. + +--- + +## Return Value + +Returns the stored JWT as a string value. + +## Usage + +<<< ./snippets/get-jwt-token-1.js diff --git a/doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js b/doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js new file mode 100644 index 000000000..1d2553c5e --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js @@ -0,0 +1 @@ +var jwtToken = kuzzle.getJwtToken(); diff --git a/doc/5/core-classes/kuzzle/get-my-credentials/index.md b/doc/5/core-classes/kuzzle/get-my-credentials/index.md new file mode 100644 index 000000000..87cf1c5bf --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-my-credentials/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: getMyCredentials +description: Kuzzle:getMyCredentials +--- + +# getMyCredentials + +Get [credential information](/core/1/guides/essentials/user-authentication/#user-credentials) for the current user. + +--- + +## getMyCredentials(strategy, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `strategy` | string | Strategy you want to get credentials from | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the credentials for the provided authentication strategy. + +## Usage + +<<< ./snippets/get-my-credentials-1.js + +> Callback response + +```json +{ + "username": "foo", + "kuid": "" +} +``` diff --git a/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js b/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js new file mode 100644 index 000000000..09411170f --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js @@ -0,0 +1,11 @@ +// Using callbacks (node.js or browser) +kuzzle.getMyCredentials('local', function (error, credentials) { + +}); + +// Using promises (node.js) +kuzzle + .getMyCredentialsPromise('local') + .then(credentials => { + + }); diff --git a/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js b/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js new file mode 100644 index 000000000..f12a9c355 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js @@ -0,0 +1,5 @@ +on +{ + "username": "foo", + "kuid": "" +} diff --git a/doc/5/core-classes/kuzzle/get-my-rights/index.md b/doc/5/core-classes/kuzzle/get-my-rights/index.md new file mode 100644 index 000000000..59eb74a4e --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-my-rights/index.md @@ -0,0 +1,58 @@ +--- +code: false +type: page +title: getMyRights +description: Kuzzle:getMyRights +--- + +# getMyRights + +Gets the rights for the current user. + +--- + +## getMyRights([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of rights. + +## Usage + +<<< ./snippets/get-my-rights-1.js + +> Callback response + +```json +[ + { + "controller": "my-controller", + "action": "my-action", + "index": "*", + "collection": "*", + "value": "allowed" + }, + { + "controller": "another-controller", + "action": "*", + "index": "my-index", + "collection": "*", + "value": "conditional" + } +] +``` diff --git a/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js b/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js new file mode 100644 index 000000000..cc193102e --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .getMyRights(function(error, rights) { + // result is an array of objects + }); + +// Using promises (NodeJS) +kuzzle + .getMyRightsPromise() + .then(rights => { + // result is an array of objects + }); diff --git a/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js b/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js new file mode 100644 index 000000000..8615b7d40 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js @@ -0,0 +1,17 @@ +on +[ + { + "controller": "my-controller", + "action": "my-action", + "index": "*", + "collection": "*", + "value": "allowed" + }, + { + "controller": "another-controller", + "action": "*", + "index": "my-index", + "collection": "*", + "value": "conditional" + } +] diff --git a/doc/5/core-classes/kuzzle/get-server-info/index.md b/doc/5/core-classes/kuzzle/get-server-info/index.md new file mode 100644 index 000000000..0763ecaca --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-server-info/index.md @@ -0,0 +1,120 @@ +--- +code: false +type: page +title: getServerInfo +description: Kuzzle:getServerInfo +--- + +# getServerInfo + +> Callback response example: + +```json +{ + "kuzzle": { + "api": { + "routes": { + "controller1": { + "action1": { + "controller": "controller1", + "action": "action1", + "http": { + "verb": "GET", + "url": "/action1/url" + } + }, + "action2": { + "controller": "controller1", + "action": "action2", + "http": { + "verb": "POST", + "url": "/action2/url" + } + }, + { + "...": "..." + } + }, + "pluginName/controller": { + "action": { + "controller": "pluginName/controller", + "action": "action", + "http": { + "verb": "GET", + "url": "/action/url" + } + }, + { + "...": " ..." + } + }, + { + "...": "..." + } + }, + "version": "" + }, + "memoryUsed": 12345, + "nodeVersion": "v6.9.5", + "plugins": {}, + "system": { + "cpus": [ + { + "cpu1": "informations" + }, + { + "...": "..." + } + ], + "memory": { + "free": 123456, + "total": 1234567 + } + }, + "uptime": "", + "version": "" + }, + "services": { + "internalCache": { + "kuzzle memory cache": "informations", + "...": "..." + }, + "memoryStorage": { + "API memory storage": "informations", + "...": "..." + }, + { + "...": "..." + } + } +} +``` + +Retrieves information about Kuzzle plugins and active services. + +--- + +## getServerInfo([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a JSON object containing server information. + +## Usage + +<<< ./snippets/get-server-info-1.js diff --git a/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js b/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js new file mode 100644 index 000000000..4318d5d2c --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.getServerInfo(function (err, stats) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle.getServerInfoPromise() + .then(infos => { + // ... + }); diff --git a/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js b/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js new file mode 100644 index 000000000..2ce1e6d2c --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js @@ -0,0 +1,79 @@ +on +{ + "kuzzle": { + "api": { + "routes": { + "controller1": { + "action1": { + "controller": "controller1", + "action": "action1", + "http": { + "verb": "GET", + "url": "/action1/url" + } + }, + "action2": { + "controller": "controller1", + "action": "action2", + "http": { + "verb": "POST", + "url": "/action2/url" + } + }, + { + "...": "..." + } + }, + "pluginName/controller": { + "action": { + "controller": "pluginName/controller", + "action": "action", + "http": { + "verb": "GET", + "url": "/action/url" + } + }, + { + "...": " ..." + } + }, + { + "...": "..." + } + }, + "version": "" + }, + "memoryUsed": 12345, + "nodeVersion": "v6.9.5", + "plugins": {}, + "system": { + "cpus": [ + { + "cpu1": "informations" + }, + { + "...": "..." + } + ], + "memory": { + "free": 123456, + "total": 1234567 + } + }, + "uptime": "", + "version": "" + }, + "services": { + "internalCache": { + "kuzzle memory cache": "informations", + "...": "..." + }, + "memoryStorage": { + "API memory storage": "informations", + "...": "..." + }, + { + "...": "..." + } + } +} diff --git a/doc/5/core-classes/kuzzle/get-statistics/index.md b/doc/5/core-classes/kuzzle/get-statistics/index.md new file mode 100644 index 000000000..6c153beef --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-statistics/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: getStatistics +description: Kuzzle:getStatistics +--- + +# getStatistics + +> Without argument, retrieves the last statistic frame in an array: +> When providing a timestamp, retrieves all frames recorded after that timestamp: +> Kuzzle server monitors active connections, and ongoing/completed/failed requests. +> This method returns either the last statistics frame, or a set of frames starting from a provided timestamp. + +--- + +## getStatistics([timestamp], [options], callback) + +| Arguments | Type | Description | +| ----------- | ----------- | ---------------------------------------------------------------- | +| `timestamp` | Epoch time | Optional starting time from which the frames are to be retrieved | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +**Note:** Kuzzle statistics are cleaned up regularly. If the timestamp is set too far in the past, then this method will return all available statistics. + +--- + +### Callback Response + +Returns an `array` containing one or more statistics frame (as JSON objects). + +## Usage + +<<< ./snippets/get-statistics-1.js + +<<< ./snippets/get-statistics-2.js + +> Callback response: + +```json +[ + { + "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "mqtt": 37, "socketio": 17 }, + "failedRequests": { "socketio": 1 }, + "timestamp": "1453110641308" + } +] +``` diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js new file mode 100644 index 000000000..5704ddfa5 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.getStatistics(function (err, statistics) { +}); + +// Using promises (NodeJS only) +kuzzle + .getStatisticsPromise() + .then(statistics => { + }); diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js new file mode 100644 index 000000000..d21210ee6 --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js @@ -0,0 +1,14 @@ +// Date can be either in ISO format or a timestamp (utc, in milliseconds) +var ts = Date.parse('2015-10-26T12:19:10.213Z'); + +// Using callbacks (NodeJS or Web Browser) +kuzzle.getStatistics(ts, function (error, statistics) { + +}); + +// Using promises (NodeJS only) +kuzzle + .getStatisticsPromise(ts) + .then(statistics => { + + }); diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js new file mode 100644 index 000000000..f5444693e --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js @@ -0,0 +1,15 @@ + +// Date can be either in ISO format or a timestamp (utc, in milliseconds) +var ts = Date.parse('2015-10-26T12:19:10.213Z'); + +// Using callbacks (NodeJS or Web Browser) +kuzzle.getStatistics(ts, function (error, statistics) { + +}); + +// Using promises (NodeJS only) +kuzzle + .getStatisticsPromise(ts) + .then(statistics => { + + }); diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js new file mode 100644 index 000000000..1a0a6480c --- /dev/null +++ b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js @@ -0,0 +1,24 @@ +on +[ + { + "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "mqtt": 37, "socketio": 17 }, + "failedRequests": { "socketio": 1 }, + "timestamp": "1453110641308" + }, + { + "connections": { "socketio": 1 }, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "socketio": 34 }, + "failedRequests": { "socketio": 3 }, + "timestamp": "1453110642308" + }, + { + "connections": {}, + "ongoingRequests": { "rest": 0, "socketio": 0 }, + "completedRequests": { "socketio": 40 }, + "failedRequests": {}, + "timestamp": "1453110643308" + } +] diff --git a/doc/5/core-classes/kuzzle/index.md b/doc/5/core-classes/kuzzle/index.md new file mode 100644 index 000000000..970ce750e --- /dev/null +++ b/doc/5/core-classes/kuzzle/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +title: Kuzzle +description: Kuzzle documentation +order: 500 +--- diff --git a/doc/5/core-classes/kuzzle/list-collections/index.md b/doc/5/core-classes/kuzzle/list-collections/index.md new file mode 100644 index 000000000..da279b964 --- /dev/null +++ b/doc/5/core-classes/kuzzle/list-collections/index.md @@ -0,0 +1,58 @@ +--- +code: false +type: page +title: listCollections +description: Kuzzle:listCollections +--- + +# listCollections + +Returns the list of known collections contained in a specified index. + +--- + +## listCollections([index], [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------- | +| `index` | string | Index containing the collections to be listed | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `from` | integer | Determines the starting point of the pagination. By default, start at the beggining | `0` | +| `size` | integer | Determines the size of the returned result set. By default, no limit is applied | `undefined` | +| `type` | string | Get either `stored` collections or `realtime` ones. By default, list `all` collections | `all` | + +If no `index` argument is provided, the `defaultIndex` property is used. If no default index is found, this method throws an error. + +--- + +## Callback Response + +Returns an array of JSON objects containing the list of stored and/or realtime collections on the provided index. + +## Usage + +<<< ./snippets/list-collections-1.js + +> Callback response: + +```json +[ + { "name": "realtime_1", "type": "realtime" }, + { "name": "realtime_2", "type": "realtime" }, + { "name": "realtime_...", "type": "realtime" }, + { "name": "realtime_n", "type": "realtime" }, + { "name": "stored_1", "type": "stored" }, + { "name": "stored_2", "type": "stored" }, + { "name": "stored_...", "type": "stored" }, + { "name": "stored_n", "type": "stored" } +] +``` diff --git a/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js b/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js new file mode 100644 index 000000000..42d90486e --- /dev/null +++ b/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js @@ -0,0 +1,11 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.listCollections('index', {type: 'stored', from: 0, size: 42}, function (err, collections) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle + .listCollectionsPromise('index', {type: 'stored'}) + .then(collections => { + // ... + }); diff --git a/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js b/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js new file mode 100644 index 000000000..4f51edc2b --- /dev/null +++ b/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js @@ -0,0 +1,11 @@ +on +[ + {"name": "realtime_1", "type": "realtime"}, + {"name": "realtime_2", "type": "realtime"}, + {"name": "realtime_...", "type": "realtime"}, + {"name": "realtime_n", "type": "realtime"}, + {"name": "stored_1", "type": "stored"}, + {"name": "stored_2", "type": "stored"}, + {"name": "stored_...", "type": "stored"}, + {"name": "stored_n", "type": "stored"} +] diff --git a/doc/5/core-classes/kuzzle/list-indexes/index.md b/doc/5/core-classes/kuzzle/list-indexes/index.md new file mode 100644 index 000000000..10c74d5bd --- /dev/null +++ b/doc/5/core-classes/kuzzle/list-indexes/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: listIndexes +description: Kuzzle:listIndexes +--- + +# listIndexes + +Returns the list of indexes stored in Kuzzle. + +--- + +## listIndexes([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an `array` of index names. + +## Usage + +<<< ./snippets/list-indexes-1.js + +> Callback response: + +```json +["index", "another index", "..."] +``` diff --git a/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js b/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js new file mode 100644 index 000000000..59d4a2d3a --- /dev/null +++ b/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js @@ -0,0 +1,11 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.listIndexes(function (err, indexes) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle + .listIndexesPromise() + .then(indexes => { + // ... + }); diff --git a/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js b/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js new file mode 100644 index 000000000..428366b57 --- /dev/null +++ b/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js @@ -0,0 +1,2 @@ +on +[ "index", "another index", "..."] diff --git a/doc/5/core-classes/kuzzle/login/index.md b/doc/5/core-classes/kuzzle/login/index.md new file mode 100644 index 000000000..a5cee00fe --- /dev/null +++ b/doc/5/core-classes/kuzzle/login/index.md @@ -0,0 +1,49 @@ +--- +code: false +type: page +title: login +description: Kuzzle:login +--- + +# login + +Login a user using a specified strategy and their credentials. + +If the Kuzzle response contains a JWT Token, the Kuzzle SDK token is set and the `loginAttempt` event is fired immediately with the following object: +`{ success: true }` +This is the case, for instance, with the `local` authentication strategy. + +If the request succeeds but there is no token, then it means that the chosen strategy is a two-steps authentication method, such as the OAUTH strategy. In that case, the `loginAttempt` event is **not** fired. To complete the login, the `setJwtToken` method must be called either with a token or with an appropriate Kuzzle response. + +If the login attempt fails, the `loginAttempt` event is fired with the following response: +`{ success: false, error: 'error message' }` + +
+This method is non-queuable, meaning that during offline mode, it will be discarded and the callback will be called with an error. [Learn more.](/core/1/guides/essentials/user-authentication/#local-strategy) +
+ +--- + +## login(strategy, [credentials], [expiresIn], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------------------ | +| `strategy` | string | Authentication strategy (local, facebook, github, ...) | +| `credentials` | JSON object | Optional login credentials, depending on the strategy | +| `expiresIn` | _varies_ | Login expiration time | +| `callback` | function | Optional callback handling the response | + +**Note:** If the `expiresIn` argument is not set, the default token expiration value will be taken from the Kuzzle server configuration. + +By default, Kuzzle comes with the [kuzzle-plugin-auth-passport-local](https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local) plugin, which provides the `local` authentication strategy. +This strategy requires a `username` and `password` as `credentials` + +--- + +## Callback Response + +Returns a JSON object containing the Kuzzle response. + +## Usage + +<<< ./snippets/login-1.js diff --git a/doc/5/core-classes/kuzzle/login/snippets/login-1.js b/doc/5/core-classes/kuzzle/login/snippets/login-1.js new file mode 100644 index 000000000..6bfad2757 --- /dev/null +++ b/doc/5/core-classes/kuzzle/login/snippets/login-1.js @@ -0,0 +1,14 @@ +// Expiration time is expressed as a string following the +// time conversion library: https://www.npmjs.com/package/ms + var expiresIn = "1h"; + +// Using callbacks (NodeJS or Web Browser) +kuzzle.login("local", {username: "username", password: "password"}, expiresIn, function (err, res) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle.loginPromise("local", {username: "username", password: "password"}, expiresIn) + .then(res => { + // ... + }); diff --git a/doc/5/core-classes/kuzzle/logout/index.md b/doc/5/core-classes/kuzzle/logout/index.md new file mode 100644 index 000000000..9e4896e88 --- /dev/null +++ b/doc/5/core-classes/kuzzle/logout/index.md @@ -0,0 +1,41 @@ +--- +code: false +type: page +title: logout +description: Kuzzle:logout +--- + +# logout + +Logs the user out. + +
+This method is non-queuable, meaning that during offline mode, it will be discarded and the callback will be called with an error. +
+ +--- + +## logout([callback]) + +| Arguments | Type | Description | +| ---------- | -------- | --------------------------------------- | +| `callback` | function | Optional callback handling the response | + +This method empties the `jwtToken` property + +--- + +## Return value + +Returns the `Kuzzle` SDK object to allow chaining. + +--- + +## Callback Response + +Returns the `Kuzzle` SDK object once the logout process is complete, either successfully or not. +The `Kuzzle` SDK object will unset the `jwtToken` property if the user is successfully logged out. + +## Usage + +<<< ./snippets/logout-1.js diff --git a/doc/5/core-classes/kuzzle/logout/snippets/logout-1.js b/doc/5/core-classes/kuzzle/logout/snippets/logout-1.js new file mode 100644 index 000000000..6a74a0804 --- /dev/null +++ b/doc/5/core-classes/kuzzle/logout/snippets/logout-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.logout(function (err, res) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle.logoutPromise() + .then(res => { + // ... + }); diff --git a/doc/5/core-classes/kuzzle/memory-storage/index.md b/doc/5/core-classes/kuzzle/memory-storage/index.md new file mode 100644 index 000000000..004032f22 --- /dev/null +++ b/doc/5/core-classes/kuzzle/memory-storage/index.md @@ -0,0 +1,10 @@ +--- +code: false +type: page +title: memoryStorage +description: Kuzzle:memoryStorage +--- + +## memoryStorage + +A [MemoryStorage](/sdk/js/5/core-classes/memory-storage) singleton. diff --git a/doc/5/core-classes/kuzzle/now/index.md b/doc/5/core-classes/kuzzle/now/index.md new file mode 100644 index 000000000..5d4795393 --- /dev/null +++ b/doc/5/core-classes/kuzzle/now/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: now +description: Kuzzle:now +--- + +# now + +Retrieves the current Kuzzle time. + +--- + +## now([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an `integer` containing the current Kuzzle time, encoded as an UTC Epoch time in milliseconds. + +## Usage + +<<< ./snippets/now-1.js + +> Callback response: + +```json +1447151167622 +``` diff --git a/doc/5/core-classes/kuzzle/now/snippets/now-1.js b/doc/5/core-classes/kuzzle/now/snippets/now-1.js new file mode 100644 index 000000000..f081ec673 --- /dev/null +++ b/doc/5/core-classes/kuzzle/now/snippets/now-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.now(function (err, res) { + // 'res' contains the Kuzzle timestamp (utc, in milliseconds) +}); + +// Using promises (NodeJS only) +kuzzle.nowPromise().then(res => { + // 'res' contains the Kuzzle timestamp (utc, in milliseconds) +}); diff --git a/doc/5/core-classes/kuzzle/now/snippets/now-2.js b/doc/5/core-classes/kuzzle/now/snippets/now-2.js new file mode 100644 index 000000000..d611c182d --- /dev/null +++ b/doc/5/core-classes/kuzzle/now/snippets/now-2.js @@ -0,0 +1,2 @@ +on +1447151167622 diff --git a/doc/5/core-classes/kuzzle/query/index.md b/doc/5/core-classes/kuzzle/query/index.md new file mode 100644 index 000000000..38078616a --- /dev/null +++ b/doc/5/core-classes/kuzzle/query/index.md @@ -0,0 +1,82 @@ +--- +code: false +type: page +title: query +description: Kuzzle:query +--- + +## query + +Base method used to send queries to Kuzzle, following the [API Documentation](/core/1/api). + +
+This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
+Refer to Kuzzle's API Reference [here](/core/1/api) +
+ +--- + +## query(queryArgs, query, [options], [callback]) + +| Argument | Type | Description | +| ----------- | ----------- | -------------------- | +| `queryArgs` | JSON object | Query base arguments | +| `query` | JSON object | Query to execute | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback | + +--- + +## queryArgs + +`queryArgs` is a JSON object allowing Kuzzle to route your query to the right API method: + +| Option | Type | Description | Required? | +| ------------ | ------ | --------------------------------------- | --------- | +| `controller` | string | API Controller argument | required | +| `action` | string | API Controller action | required | +| `index` | string | Index concerned by the action | optional | +| `collection` | string | Data collection concerned by the action | optional | + +--- + +## query + +## `query` is a JSON object containing arguments specific to the query, such as a `body` property, a JWT hash, a document `_id`, or generic query options (such as `from` or `size` for [search queries](/core/1/api/controllers/document/search/)) + +## Options + +| Option | Type | Description | Default | +| ---------- | ----------- | ------------------------------------------------------------- | ------- | +| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +--- + +## Callback Response + +Returns a `JSON object` containing the raw Kuzzle response. + +## Usage + +<<< ./snippets/query-1.js + +> Callback response: + +```json +{ + "error": null, + "result": { + "action": "action", + "controller": "controller", + "requestId": "bf87b930-7c02-11e5-ab10-dfa9e9fd2e07", + "other properties": "depends of the query made" + } +} +``` diff --git a/doc/5/core-classes/kuzzle/query/snippets/query-1.js b/doc/5/core-classes/kuzzle/query/snippets/query-1.js new file mode 100644 index 000000000..b51aea5a9 --- /dev/null +++ b/doc/5/core-classes/kuzzle/query/snippets/query-1.js @@ -0,0 +1,23 @@ +const + args = { + controller: 'controller', + action: 'action' + }, + query = { + body: { + foo: 'bar' + }, + other: 'argument' + }; + +// Using callbacks (NodeJS or Web Browser) +kuzzle.query(args, query, function (err, res) { + // ... +}); + +// Using promises (NodeJS only) +kuzzle + .queryPromise(args, query) + .then(result => { + + }); diff --git a/doc/5/core-classes/kuzzle/query/snippets/query-2.js b/doc/5/core-classes/kuzzle/query/snippets/query-2.js new file mode 100644 index 000000000..efcebd8c0 --- /dev/null +++ b/doc/5/core-classes/kuzzle/query/snippets/query-2.js @@ -0,0 +1,9 @@ +on +{ "error": null, + "result": { + "action": "action", + "controller": "controller", + "requestId": "bf87b930-7c02-11e5-ab10-dfa9e9fd2e07", + "other properties": "depends of the query made" + } +} diff --git a/doc/5/core-classes/kuzzle/refresh-index/index.md b/doc/5/core-classes/kuzzle/refresh-index/index.md new file mode 100644 index 000000000..c786e737c --- /dev/null +++ b/doc/5/core-classes/kuzzle/refresh-index/index.md @@ -0,0 +1,58 @@ +--- +code: false +type: page +title: refreshIndex +description: Kuzzle:refreshIndex +--- + +# refreshIndex + +When writing or deleting documents in Kuzzle, the update needs to be indexed before being reflected +in the search index. +By default, this operation can take up to 1 second. + +Given an index, the `refresh` action forces a [`refresh`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html), +on it, making the documents visible to search immediately. + +
+ A refresh operation comes with some performance costs.
+
+ From elasticsearch documentation: +
+ "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." +
+
+ +--- + +## refreshIndex([index], [options], [callback]) + +| Argument | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------- | +| `index` | string | _Optional_. The index to refresh. If not set, defaults to [kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties). | +| `options` | JSON object | Optional parameters | +| `callback` | function | _Optional_. Callback handling the response. | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +--- + +## Callback Response + +Returns a JSON structure matching the response from Elasticsearch. + +## Usage + +<<< ./snippets/refresh-index-1.js diff --git a/doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js b/doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js new file mode 100644 index 000000000..25b7abd30 --- /dev/null +++ b/doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js @@ -0,0 +1 @@ +kuzzle.refreshIndex('myIndex'); diff --git a/doc/5/core-classes/kuzzle/remove-all-listeners/index.md b/doc/5/core-classes/kuzzle/remove-all-listeners/index.md new file mode 100644 index 000000000..4d571d6a5 --- /dev/null +++ b/doc/5/core-classes/kuzzle/remove-all-listeners/index.md @@ -0,0 +1,28 @@ +--- +code: false +type: page +title: removeAllListeners +description: Kuzzle:removeAllListeners +--- + +# removeAllListeners + +Removes all listeners, either from a specific event or from all events + +--- + +## removeAllListeners([event]) + +| Arguments | Type | Description | +| --------- | ------ | -------------------------------------------------------------------------------- | +| `event` | string | One of the event described in the `Event Handling` section of this documentation | + +--- + +## Return Value + +Returns the `Kuzzle` object to allow chaining. + +## Usage + +<<< ./snippets/remove-all-listeners-1.js diff --git a/doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js b/doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js new file mode 100644 index 000000000..7fe6782fb --- /dev/null +++ b/doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js @@ -0,0 +1,5 @@ +// Removes all listeners on the "unsubscribed" global event +kuzzle.removeAllListeners('disconnected'); + +// Removes all listeners on all global events +kuzzle.removeAllListeners(); diff --git a/doc/5/core-classes/kuzzle/remove-listener/index.md b/doc/5/core-classes/kuzzle/remove-listener/index.md new file mode 100644 index 000000000..d3a87872b --- /dev/null +++ b/doc/5/core-classes/kuzzle/remove-listener/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: removeListener +description: Kuzzle:removeListener +--- + +# removeListener + +Remove a listener from an event. + +--- + +## removeListener(event, callback) + +| Arguments | Type | Description | +| ---------- | --------------- | --------------------------------------------------------------------------------- | +| `event` | string | One of the events described in the `Event Handling` section of this documentation | +| `callback` | function/object | the callback | + +--- + +## Return Value + +Returns the `Kuzzle` object to allow chaining. + +## Usage + +<<< ./snippets/remove-listener-1.js diff --git a/doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js b/doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js new file mode 100644 index 000000000..3d9b14c46 --- /dev/null +++ b/doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js @@ -0,0 +1 @@ +kuzzle.removeListener('disconnected', callback); diff --git a/doc/5/core-classes/kuzzle/replay-queue/index.md b/doc/5/core-classes/kuzzle/replay-queue/index.md new file mode 100644 index 000000000..f7bd90ba1 --- /dev/null +++ b/doc/5/core-classes/kuzzle/replay-queue/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: replayQueue +description: Kuzzle:replayQueue +--- + +# replayQueue + +Replays the requests queued during offline mode. Works only if the SDK is not in a `disconnected` state, and if the `autoReplay` option is set to `false`. + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +## Usage + +<<< ./snippets/replay-queue-1.js diff --git a/doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js b/doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js new file mode 100644 index 000000000..527244e92 --- /dev/null +++ b/doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js @@ -0,0 +1 @@ +kuzzle.replayQueue(); diff --git a/doc/5/core-classes/kuzzle/security/index.md b/doc/5/core-classes/kuzzle/security/index.md new file mode 100644 index 000000000..83d944dda --- /dev/null +++ b/doc/5/core-classes/kuzzle/security/index.md @@ -0,0 +1,10 @@ +--- +code: false +type: page +title: security +description: Kuzzle:security +--- + +# security + +A [Security](/sdk/js/5/core-classes/security) singleton. diff --git a/doc/5/core-classes/kuzzle/set-auto-refresh/index.md b/doc/5/core-classes/kuzzle/set-auto-refresh/index.md new file mode 100644 index 000000000..e7dc7c4c5 --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-auto-refresh/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: setAutoRefresh +description: Kuzzle:setAutoRefresh +--- + +# setAutoRefresh + +The `autoRefresh` flag, when set to true, will make Kuzzle perform a +[`refresh`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html) request +immediately after each write request, causing documents to be immediately visible in a search. + +Given an index, the `setAutoRefresh` function updates its `autoRefresh` status. + +
+

+ A refresh operation comes with some performance costs. +

+

+ While forcing the autoRefresh can be convenient on a development or test environmnent, we recommend that you avoid + using it in production or at least carefully monitor its implications before using it. +

+
+ +--- + +## setAutoRefresh([index], autoRefresh, [options], [callback]) + +| Argument | Type | Description | +| ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------- | +| `index` | string | _Optional_ The index to set the `autoRefresh` for. If not set, defaults to [kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties). | +| `autoRefresh` | boolean | The value to set for the `autoRefresh` setting. | +| `options` | JSON object | Optional parameters | +| `callback` | function | _Optional_ Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +--- + +## Callback Response + +Returns a boolean with the new `autoRefresh` status. + +## Usage + +<<< ./snippets/set-auto-refresh-1.js diff --git a/doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js b/doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js new file mode 100644 index 000000000..2c4eb8b17 --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js @@ -0,0 +1 @@ +kuzzle.setAutoRefresh('myIndex', true); diff --git a/doc/5/core-classes/kuzzle/set-default-index/index.md b/doc/5/core-classes/kuzzle/set-default-index/index.md new file mode 100644 index 000000000..e6cae0556 --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-default-index/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: setDefaultIndex +description: Kuzzle:setDefaultIndex +--- + +# setDefaultIndex + +Set the default index. Has the same effect than the `defaultIndex` constructor option. + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +## Usage + +<<< ./snippets/set-default-index-1.js diff --git a/doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js b/doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js new file mode 100644 index 000000000..39611cf15 --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js @@ -0,0 +1 @@ +kuzzle.setDefaultIndex('index'); diff --git a/doc/5/core-classes/kuzzle/set-headers/index.md b/doc/5/core-classes/kuzzle/set-headers/index.md new file mode 100644 index 000000000..e2a134fca --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-headers/index.md @@ -0,0 +1,31 @@ +--- +code: false +type: page +title: setHeaders +description: Kuzzle:setHeaders +--- + +# setHeaders + +This is a helper function returning itself, allowing to easily chain calls. + +--- + +## setHeaders(content, [replace]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------------------------------------------------------- | +| `content` | JSON Object | New content | +| `replace` | boolean | true: replace the current content with the provided data, false: merge it | + +**Note:** by default, the `replace` argument is set to `false` + +--- + +## Return value + +Returns the `Kuzzle` object to allow chaining. + +## Usage + +<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js new file mode 100644 index 000000000..fa867c0ed --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js @@ -0,0 +1 @@ +kuzzle.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/kuzzle/set-jwt-token/index.md b/doc/5/core-classes/kuzzle/set-jwt-token/index.md new file mode 100644 index 000000000..131f462f1 --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-jwt-token/index.md @@ -0,0 +1,42 @@ +--- +code: false +type: page +title: setJwtToken +description: Kuzzle:setJwtToken +--- + +# setJwtToken + +Sets the internal JWT token which will be used when making requests to Kuzzle. + +If the provided token is valid, a `loginAttempt` event is fired with the following object: +`{ success: true }` + +If not, the `loginAttempt` event is fired with the following response: +`{ success: false, error: 'error message' }` + +--- + +## setJwtToken(jwtToken) + +| Arguments | Type | Description | +| ---------- | ------ | ----------------------------------- | +| `jwtToken` | string | Previously generated JSON Web Token | + +--- + +## setJwtToken(kuzzleResponse) + +| Arguments | Type | Description | +| ---------------- | ----------- | ----------------------------------------------------------- | +| `kuzzleResponse` | JSON object | Final Kuzzle response from a 2-steps authentication process | + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +## Usage + +<<< ./snippets/set-jwt-token-1.js diff --git a/doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js b/doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js new file mode 100644 index 000000000..d01baca48 --- /dev/null +++ b/doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js @@ -0,0 +1,9 @@ +// Directly with a JWT Token +kuzzle.setJwtToken('some jwt token'); + +/* + Or with a Kuzzle response. + For instance, the final OAUTH2 response is obtained with a redirection from Kuzzle, + and it can be provided to this method directly + */ +kuzzle.setJwtToken(authenticationResponse); diff --git a/doc/5/core-classes/kuzzle/start-queuing/index.md b/doc/5/core-classes/kuzzle/start-queuing/index.md new file mode 100644 index 000000000..24748085e --- /dev/null +++ b/doc/5/core-classes/kuzzle/start-queuing/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: startQueuing +description: Kuzzle:startQueuing +--- + +# startQueuing + +Starts the requests queuing. Works only in offline mode, and if the [autoQueue](/sdk/js/5/core-classes/kuzzle/#properties) option is set to `false`. + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +## Usage + +<<< ./snippets/start-queuing-1.js diff --git a/doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js b/doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js new file mode 100644 index 000000000..947392364 --- /dev/null +++ b/doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js @@ -0,0 +1 @@ +kuzzle.startQueuing(); diff --git a/doc/5/core-classes/kuzzle/stop-queuing/index.md b/doc/5/core-classes/kuzzle/stop-queuing/index.md new file mode 100644 index 000000000..87144629f --- /dev/null +++ b/doc/5/core-classes/kuzzle/stop-queuing/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: stopQueuing +description: Kuzzle:stopQueuing +--- + +# stopQueuing + +Stops the requests queuing. Works only in offline mode, and if the [autoQueue](/sdk/js/5/core-classes/kuzzle/#properties) option is set to `false`. + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +## Usage + +<<< ./snippets/stop-queuing-1.js diff --git a/doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js b/doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js new file mode 100644 index 000000000..0d82bef00 --- /dev/null +++ b/doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js @@ -0,0 +1 @@ +kuzzle.stopQueuing(); diff --git a/doc/5/core-classes/kuzzle/unset-jwt-token/index.md b/doc/5/core-classes/kuzzle/unset-jwt-token/index.md new file mode 100644 index 000000000..ec766f9a8 --- /dev/null +++ b/doc/5/core-classes/kuzzle/unset-jwt-token/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: unsetJwtToken +description: Kuzzle:unsetJwtToken +--- + +# unsetJwtToken + +Unsets the internal JSON Web Token used for authentication, and stops all existing subscriptions. + +--- + +## Return Value + +Returns the `Kuzzle` SDK object to allow chaining. + +## Usage + +<<< ./snippets/unset-jwt-token-1.js diff --git a/doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js b/doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js new file mode 100644 index 000000000..3d5c2510a --- /dev/null +++ b/doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js @@ -0,0 +1 @@ +kuzzle.unsetJwtToken(); diff --git a/doc/5/core-classes/kuzzle/update-my-credentials/index.md b/doc/5/core-classes/kuzzle/update-my-credentials/index.md new file mode 100644 index 000000000..c79cef8b0 --- /dev/null +++ b/doc/5/core-classes/kuzzle/update-my-credentials/index.md @@ -0,0 +1,39 @@ +--- +code: false +type: page +title: updateMyCredentials +description: Kuzzle:updateMyCredentials +--- + +# updateMyCredentials + +Update current user credentials for the specified `strategy`. The credentials to send depend on the authentication plugin and the strategy. + +--- + +## updateMyCredentials(strategy, credentials, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `strategy` | string | Strategy you want to create credentials in | +| `credentials` | JSON object | The credentials | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback response + +Returns an object reflecting the updated credentials. + +## Usage + +<<< ./snippets/update-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js b/doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js new file mode 100644 index 000000000..3d9a498c1 --- /dev/null +++ b/doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js @@ -0,0 +1,11 @@ +// Using callbacks (node.js or browser) +kuzzle.updateMyCredentials('local', {'username': 'foo'}, function (err, res) { + console.log(res); // {username: 'bar', kuid: ''} +}); + +// Using promises (node.js) +kuzzle + .updateMyCredentials('local', {'username': 'foo'}) + .then(res => { + console.log(res); // {username: 'foo', kuid: ''} + }); diff --git a/doc/5/core-classes/kuzzle/update-self/index.md b/doc/5/core-classes/kuzzle/update-self/index.md new file mode 100644 index 000000000..b70e919ae --- /dev/null +++ b/doc/5/core-classes/kuzzle/update-self/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: updateSelf +description: Kuzzle:updateSelf +--- + +# updateSelf + +--- + +## updateSelf(content, [options], [callback]) + +Performs a partial update on the current user. + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------- | +| `content` | JSON Object | A plain javascript object representing the user | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `Kuzzle` SDK object to allow chaining. + +--- + +## Callback Response + +Returns the updated user object. + +## Usage + +<<< ./snippets/update-self-1.js diff --git a/doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js b/doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js new file mode 100644 index 000000000..ad7d42dd4 --- /dev/null +++ b/doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js @@ -0,0 +1,18 @@ +var newContent = { + firstname: 'My Name Is', + lastname: 'Jonas' +}; + + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .updateSelf(newContent, function (err, updatedUser) { + + }); + +// Using promises (NodeJS) +kuzzle + .updateSelfPromise(newContent) + .then(updatedUser => { + + }); diff --git a/doc/5/core-classes/kuzzle/validate-my-credentials/index.md b/doc/5/core-classes/kuzzle/validate-my-credentials/index.md new file mode 100644 index 000000000..fc4cfc24d --- /dev/null +++ b/doc/5/core-classes/kuzzle/validate-my-credentials/index.md @@ -0,0 +1,39 @@ +--- +code: false +type: page +title: validateMyCredentials +description: Kuzzle:validateMyCredentials +--- + +# validateMyCredentials + +Update current user's credentials for the specified `strategy`. The credentials to send depend on the authentication plugin and the strategy. + +--- + +## validateMyCredentials(strategy, credentials, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `strategy` | string | Strategy you want to create credentials in | +| `credentials` | JSON object | The credentials | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns true or false. + +## Usage + +<<< ./snippets/validate-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js b/doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js new file mode 100644 index 000000000..5d58fd2ff --- /dev/null +++ b/doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js @@ -0,0 +1,11 @@ +// Using callbacks (node.js or browser) +kuzzle.validateMyCredentials('local', {'username': 'foo'}, function (err, res) { + console.log(res); // true or false +}); + +// Using promises (node.js) +kuzzle + .validateMyCredentials('local', {'username': 'foo'}) + .then(res => { + console.log(res); // true or false + }); diff --git a/doc/5/core-classes/kuzzle/who-am-i/index.md b/doc/5/core-classes/kuzzle/who-am-i/index.md new file mode 100644 index 000000000..da5d4ed9b --- /dev/null +++ b/doc/5/core-classes/kuzzle/who-am-i/index.md @@ -0,0 +1,28 @@ +--- +code: false +type: page +title: whoAmI +description: Kuzzle:whoAmI +--- + +# whoAmI + +Returns informations about the user who is currently loggedin. + +--- + +## whoAmI(callback) + +| Arguments | Type | Description | +| ---------- | -------- | ------------------------------ | +| `callback` | function | Callback handling the response | + +--- + +## Callback Response + +Returns an instantiated [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/who-am-i-1.js diff --git a/doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js b/doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js new file mode 100644 index 000000000..31befd392 --- /dev/null +++ b/doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.whoAmI(function (err, result) { + // "result" is a User object +}); + +// Using promises (NodeJS only) +kuzzle.whoAmIPromise() + .then(res => { + // "res" is a User object + }); diff --git a/doc/5/core-classes/memory-storage/append/index.md b/doc/5/core-classes/memory-storage/append/index.md new file mode 100644 index 000000000..c0f448827 --- /dev/null +++ b/doc/5/core-classes/memory-storage/append/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: append +description: MemoryStorage:append +--- + +# append + +Appends a value to a key. If the key does not exist, it is created. + +[[_Redis documentation_]](https://redis.io/commands/append) + +--- + +## append(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------- | +| `key` | string | Key identifier | +| `value` | string | Value to append to the key | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Return an integer containing the new length of the key's value. + +## Usage + +<<< ./snippets/append-1.js + +> Callback response: + +```json +5 +``` diff --git a/doc/5/core-classes/memory-storage/append/snippets/append-1.js b/doc/5/core-classes/memory-storage/append/snippets/append-1.js new file mode 100644 index 000000000..3dca48f14 --- /dev/null +++ b/doc/5/core-classes/memory-storage/append/snippets/append-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.append('key', 'value', function (err, newLength) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.appendPromise('key', 'value') + .then(newLength => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/append/snippets/append-2.js b/doc/5/core-classes/memory-storage/append/snippets/append-2.js new file mode 100644 index 000000000..151b916ea --- /dev/null +++ b/doc/5/core-classes/memory-storage/append/snippets/append-2.js @@ -0,0 +1,2 @@ +on +5 diff --git a/doc/5/core-classes/memory-storage/bitcount/index.md b/doc/5/core-classes/memory-storage/bitcount/index.md new file mode 100644 index 000000000..d8706973d --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitcount/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: bitcount +description: MemoryStorage:bitcount +--- + +# bitcount + +Counts the number of set bits (population counting) in a string. + +[[_Redis documentation_]](https://redis.io/commands/bitcount) + +--- + +## bitcount(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `end` | int | Ending offset | `-1` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `start` | int | Starting offset | `0` | + +--- + +## Callback Response + +Return an integer containing the count of set bits. + +## Usage + +<<< ./snippets/bitcount-1.js + +> Callback response: + +```json +21 +``` diff --git a/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js b/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js new file mode 100644 index 000000000..556ef98d9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.bitcount('key', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.bitcountPromise('key') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js b/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js new file mode 100644 index 000000000..edd1f5c86 --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js @@ -0,0 +1,2 @@ +on +21 diff --git a/doc/5/core-classes/memory-storage/bitop/index.md b/doc/5/core-classes/memory-storage/bitop/index.md new file mode 100644 index 000000000..0fc0ecaaa --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitop/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: bitop +description: MemoryStorage:bitop +--- + +# bitop + +Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key. + +[[_Redis documentation_]](https://redis.io/commands/bitop) + +--- + +## bitop(key, operation, keys, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | --------------------------------------------------------------------------- | +| `key` | string | Destination key identifier | +| `operation` | string | Bitwise operation to perform.
Allowed values: `AND`, `OR`, `XOR`, `NOT` | +| `keys` | array | list of source keys on which the bitwise operation will be applied | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the length of the new key's value. + +## Usage + +<<< ./snippets/bitop-1.js + +> Callback response: + +```json +42 +``` diff --git a/doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js b/doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js new file mode 100644 index 000000000..42302c9bc --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.bitop('key', 'AND', ['srckey1', 'srckey2', '...'], function (err, length) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.bitopPromise('key', 'AND', ['srckey1', 'srckey2', '...']) + .then(length => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js b/doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js new file mode 100644 index 000000000..37c3eb98c --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js @@ -0,0 +1,2 @@ +on +42 diff --git a/doc/5/core-classes/memory-storage/bitpos/index.md b/doc/5/core-classes/memory-storage/bitpos/index.md new file mode 100644 index 000000000..a97cf2347 --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitpos/index.md @@ -0,0 +1,49 @@ +--- +code: false +type: page +title: bitpos +description: MemoryStorage:bitpos +--- + +# bitpos + +Returns the position of the first bit set to 1 or 0 in a string, or in a substring. + +[[_Redis documentation_]](https://redis.io/commands/bitpos) + +--- + +## bitpos(key, bit, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `bit` | int | Bit to search.
Allowed values: `0`, `1` | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `end` | int | Ending offset | `-1` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `start` | int | Starting offset | `0` | + +--- + +## Callback Response + +Returns an integer containing the first position of the searched bit in the string value. + +## Usage + +<<< ./snippets/bitpos-1.js + +> Callback response: + +```json +0 +``` diff --git a/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js b/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js new file mode 100644 index 000000000..ca2c8114d --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.bitpos('key', 0, function (err, position) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.bitpos('key', 0) + .then(position => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js b/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js new file mode 100644 index 000000000..41199acf8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js @@ -0,0 +1,2 @@ +on +0 diff --git a/doc/5/core-classes/memory-storage/constructor/index.md b/doc/5/core-classes/memory-storage/constructor/index.md new file mode 100644 index 000000000..25829924d --- /dev/null +++ b/doc/5/core-classes/memory-storage/constructor/index.md @@ -0,0 +1,24 @@ +--- +code: false +type: page +title: constructor +description: MemoryStorage:constructor +order: 1 +--- + +# Constructor + +Kuzzle's memory storage is a data store separate from the database layer. +It uses Redis internally, and most of its underlying functions are exposed by Kuzzle. + +--- + +## MemoryStorage(Kuzzle) + +| Arguments | Type | Description | +| --------- | ------ | ----------------------------------------------------- | +| `Kuzzle` | object | An instantiated [Kuzzle](/sdk/js/5/core-classes/kuzzle) SDK object | + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js b/doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..cb06ac37e --- /dev/null +++ b/doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js @@ -0,0 +1,5 @@ +/* + Constructor is not exposed in the JS/Node SDK. You may get the instantiated + MemoryStorage object by calling Kuzzle.memoryStorage + */ +var memoryStorage = kuzzle.memoryStorage; diff --git a/doc/5/core-classes/memory-storage/dbsize/index.md b/doc/5/core-classes/memory-storage/dbsize/index.md new file mode 100644 index 000000000..f56d31c29 --- /dev/null +++ b/doc/5/core-classes/memory-storage/dbsize/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: dbsize +description: MemoryStorage:dbsize +--- + +# dbsize + +Returns the number of keys in the application database. + +[[_Redis documentation_]](https://redis.io/commands/dbsize) + +--- + +## dbsize([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of keys in the application database. + +## Usage + +<<< ./snippets/dbsize-1.js + +> Callback response: + +```json +12 +``` diff --git a/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js b/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js new file mode 100644 index 000000000..a8733f009 --- /dev/null +++ b/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.dbsize(function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.dbsize() + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js b/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js new file mode 100644 index 000000000..a300bc6b4 --- /dev/null +++ b/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js @@ -0,0 +1,2 @@ +on +12 diff --git a/doc/5/core-classes/memory-storage/decr/index.md b/doc/5/core-classes/memory-storage/decr/index.md new file mode 100644 index 000000000..1f3665a12 --- /dev/null +++ b/doc/5/core-classes/memory-storage/decr/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: decr +description: MemoryStorage:decr +--- + +# decr + +Decrements the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/decr) + +--- + +## decr(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated key value. + +## Usage + +<<< ./snippets/decr-1.js + +> Callback response: + +```json +-1 +``` diff --git a/doc/5/core-classes/memory-storage/decr/snippets/decr-1.js b/doc/5/core-classes/memory-storage/decr/snippets/decr-1.js new file mode 100644 index 000000000..540c9fec1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/decr/snippets/decr-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.decr('key', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.decrPromise('key') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/decr/snippets/decr-2.js b/doc/5/core-classes/memory-storage/decr/snippets/decr-2.js new file mode 100644 index 000000000..222304a0a --- /dev/null +++ b/doc/5/core-classes/memory-storage/decr/snippets/decr-2.js @@ -0,0 +1,2 @@ +on +-1 diff --git a/doc/5/core-classes/memory-storage/decrby/index.md b/doc/5/core-classes/memory-storage/decrby/index.md new file mode 100644 index 000000000..3b944e405 --- /dev/null +++ b/doc/5/core-classes/memory-storage/decrby/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: decrby +description: MemoryStorage:decrby +--- + +# decrby + +Decrements the number stored at `key` by a provided integer value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/decrby) + +--- + +## decrby(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `value` | int | Decrement value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated key value. + +## Usage + +<<< ./snippets/decrby-1.js + +> Callback response: + +```json +57 +``` diff --git a/doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js b/doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js new file mode 100644 index 000000000..e4fc69cc7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.decrby('key', 42, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.decrbyPromise('key', 42) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js b/doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js new file mode 100644 index 000000000..f48a95b8f --- /dev/null +++ b/doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js @@ -0,0 +1,2 @@ +on +57 diff --git a/doc/5/core-classes/memory-storage/del/index.md b/doc/5/core-classes/memory-storage/del/index.md new file mode 100644 index 000000000..28111fa9c --- /dev/null +++ b/doc/5/core-classes/memory-storage/del/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: del +description: MemoryStorage:del +--- + +# del + +Deletes a list of keys. + +[[_Redis documentation_]](https://redis.io/commands/del) + +--- + +## del(keys, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------- | +| `keys` | array | List of keys to delete | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Return an integer containing the number of deleted keys. + +## Usage + +<<< ./snippets/del-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/del/snippets/del-1.js b/doc/5/core-classes/memory-storage/del/snippets/del-1.js new file mode 100644 index 000000000..849185f3d --- /dev/null +++ b/doc/5/core-classes/memory-storage/del/snippets/del-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.del(['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.delPromise(['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/del/snippets/del-2.js b/doc/5/core-classes/memory-storage/del/snippets/del-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/del/snippets/del-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/exists/index.md b/doc/5/core-classes/memory-storage/exists/index.md new file mode 100644 index 000000000..7e1429376 --- /dev/null +++ b/doc/5/core-classes/memory-storage/exists/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: exists +description: MemoryStorage:exists +--- + +# exists + +Checks if the specified keys exist in the database. + +[[_Redis documentation_]](https://redis.io/commands/exists) + +--- + +## exists(keys, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------- | +| `keys` | array | List of keys to check for existence | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of existing keys amongst the provided list. + +## Usage + +<<< ./snippets/exists-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/exists/snippets/exists-1.js b/doc/5/core-classes/memory-storage/exists/snippets/exists-1.js new file mode 100644 index 000000000..ae851b6ef --- /dev/null +++ b/doc/5/core-classes/memory-storage/exists/snippets/exists-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.exists(['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.existsPromise(['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/exists/snippets/exists-2.js b/doc/5/core-classes/memory-storage/exists/snippets/exists-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/exists/snippets/exists-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/expire/index.md b/doc/5/core-classes/memory-storage/expire/index.md new file mode 100644 index 000000000..50f009038 --- /dev/null +++ b/doc/5/core-classes/memory-storage/expire/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: expire +description: MemoryStorage:expire +--- + +# expire + +Sets a timeout (in seconds) on a key. After the timeout has expired, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/expire) + +--- + +## expire(key, seconds, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------ | +| `key` | string | Key identifier | +| `seconds` | int | Time to live, in seconds | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/expire-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/expire/snippets/expire-1.js b/doc/5/core-classes/memory-storage/expire/snippets/expire-1.js new file mode 100644 index 000000000..a4f312e8b --- /dev/null +++ b/doc/5/core-classes/memory-storage/expire/snippets/expire-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.expire('key', 42, function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.expirePromise('key', 42) + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/expire/snippets/expire-2.js b/doc/5/core-classes/memory-storage/expire/snippets/expire-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/expire/snippets/expire-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/expireat/index.md b/doc/5/core-classes/memory-storage/expireat/index.md new file mode 100644 index 000000000..fd4d4a3e7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/expireat/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: expireat +description: MemoryStorage:expireat +--- + +# expireat + +Sets an expiration timestamp on a key. After the timestamp has been reached, the key will automatically be deleted. +The `timestamp` parameter accepts an [Epoch time](https://en.wikipedia.org/wiki/Unix_time) value. + +[[_Redis documentation_]](https://redis.io/commands/expireat) + +--- + +## expireat(key, timestamp, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | -------------------- | +| `key` | string | Key identifier | +| `timestamp` | int | Expiration timestamp | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/expireat-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js b/doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js new file mode 100644 index 000000000..c48464b33 --- /dev/null +++ b/doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.expireat('key', 1488372354, function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.expireatPromise('key', 1488372354) + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js b/doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/flushdb/index.md b/doc/5/core-classes/memory-storage/flushdb/index.md new file mode 100644 index 000000000..fea0cd9f5 --- /dev/null +++ b/doc/5/core-classes/memory-storage/flushdb/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: flushdb +description: MemoryStorage:flushdb +--- + +# flushdb + +Deletes all the keys of the database dedicated to client applications (the reserved space for Kuzzle is unaffected). + +[[_Redis documentation_]](https://redis.io/commands/flushdb) + +--- + +## flushdb([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/flushdb-1.js diff --git a/doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js b/doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js new file mode 100644 index 000000000..7488c9fed --- /dev/null +++ b/doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.flushdb(function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.flushdbPromise() + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/geoadd/index.md b/doc/5/core-classes/memory-storage/geoadd/index.md new file mode 100644 index 000000000..9afecc2ea --- /dev/null +++ b/doc/5/core-classes/memory-storage/geoadd/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: geoadd +description: MemoryStorage:geoadd +--- + +# geoadd + +Adds geospatial points to the specified key. + +[[_Redis documentation_]](https://redis.io/commands/geoadd) + +--- + +## geoadd(key, points, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `key` | string | Destination key identifier | +| `points` | array of objects | List of geospatial points to add. Each point is described by a JSON object containing the following properties:
`lon` (longitude, `float`), `lat` (latitude, `float`), `name` (point identifier, `string`) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of points added to the key. + +## Usage + +<<< ./snippets/geoadd-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js b/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js new file mode 100644 index 000000000..d58f22050 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js @@ -0,0 +1,23 @@ +// Using callbacks (NodeJS or Web Browser) +var points = [ + { + lon: 13.361389, + lat: 38.115556, + name: 'Palermo' + }, + { + lon: 15.087269, + lat: 37.502669, + name: 'Catania' + } +]; + +kuzzle.memoryStorage.geoadd('key', points, function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.geoaddPromise('key', points) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js b/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/geodist/index.md b/doc/5/core-classes/memory-storage/geodist/index.md new file mode 100644 index 000000000..66fa1674c --- /dev/null +++ b/doc/5/core-classes/memory-storage/geodist/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: geodist +description: MemoryStorage:geodist +--- + +# geodist + +Returns the distance between two geospatial members of a key (see [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)). +The returned distance is expressed in meters by default. + +[[_Redis documentation_]](https://redis.io/commands/geodist) + +--- + +## geodist(key, member1, member2, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------- | +| `key` | string | Key identifier | +| `member1` | string | Name of the first geospatial point | +| `member2` | string | Name of the second geospatial point | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `unit` | string | Distance unit.
Allowed values: `m`, `km`, `mi`, `ft` | `m` | + +--- + +## Callback Response + +Returns the calculated distance between the two provided geospatial points. + +## Usage + +<<< ./snippets/geodist-1.js + +> Callback response: + +```json +166274.1516 +``` diff --git a/doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js b/doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js new file mode 100644 index 000000000..88cdfb0cc --- /dev/null +++ b/doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.geodist('key', 'Palermo', 'Catania', function (err, distance) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.geodistPromise('key', 'Palermo', 'Catania') + .then(distance => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js b/doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js new file mode 100644 index 000000000..693f2c08d --- /dev/null +++ b/doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js @@ -0,0 +1,2 @@ +on +166274.1516 diff --git a/doc/5/core-classes/memory-storage/geohash/index.md b/doc/5/core-classes/memory-storage/geohash/index.md new file mode 100644 index 000000000..b8c934f64 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geohash/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: geohash +description: MemoryStorage:geohash +--- + +# geohash + +Returns a valid [geohash](https://en.wikipedia.org/wiki/Geohash) for the provided key's members (see [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)). + +[[_Redis documentation_]](https://redis.io/commands/geohash) + +--- + +## geohash(key, members, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------------- | +| `key` | string | Key identifier | +| `members` | array | List of geospatial points contained in the key | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of geohashes, in the same order than the provided members list. + +## Usage + +<<< ./snippets/geohash-1.js + +> Callback response: + +```json +["sqc8b49rny0", "sqdtr74hyu0"] +``` diff --git a/doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js b/doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js new file mode 100644 index 000000000..fc54fd8b1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.geohash('key', ['Palermo', 'Catania'], function (err, hashes) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.geohashPromise('key', ['Palermo', 'Catania']) + .then(hashes => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js b/doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js new file mode 100644 index 000000000..e12045358 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js @@ -0,0 +1,2 @@ +on +["sqc8b49rny0", "sqdtr74hyu0"] diff --git a/doc/5/core-classes/memory-storage/geopos/index.md b/doc/5/core-classes/memory-storage/geopos/index.md new file mode 100644 index 000000000..fc7c7b489 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geopos/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: geopos +description: MemoryStorage:geopos +--- + +# geopos + +Returns the positions (longitude, latitude) of the provided key's members (see [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)). + +[[_Redis documentation_]](https://redis.io/commands/geopos) + +--- + +## geopos(key, members, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------------- | +| `key` | string | Key identifier | +| `members` | array | List of geospatial points contained in the key | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of longitude-latitude pairs, in the same order as the provided members list. + +## Usage + +<<< ./snippets/geopos-1.js + +> Callback response: + +```json +[[13.361389, 38.115556], [15.087269, 37.502669]] +``` diff --git a/doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js b/doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js new file mode 100644 index 000000000..5ceba6ff6 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.geopos('key', ['Palermo', 'Catania'], function (err, positions) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.geoposPromise('key', ['Palermo', 'Catania']) + .then(positions => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js b/doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js new file mode 100644 index 000000000..2e0bb3357 --- /dev/null +++ b/doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js @@ -0,0 +1,2 @@ +on +[ [13.361389, 38.115556], [15.087269, 37.502669]] diff --git a/doc/5/core-classes/memory-storage/georadius/index.md b/doc/5/core-classes/memory-storage/georadius/index.md new file mode 100644 index 000000000..8f24a2389 --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadius/index.md @@ -0,0 +1,72 @@ +--- +code: false +type: page +title: georadius +description: MemoryStorage:georadius +--- + +# georadius + +> Callback response, with no option provided: + +```json +[{ "name": "Palermo" }, { "name": "Catania" }] +``` + +> Callback response, with the "withcoord" option: + +```json +[ + { "name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963] }, + { "name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162] } +] +``` + +> Callback response, with the "withdist" option: + +```json +[ + { "name": "Palermo", "distance": 190.4424 }, + { "name": "Catania", "distance": 56.4413 } +] +``` + +Returns the members (added with [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)) of a given key inside the provided geospatial radius. + +[[_Redis documentation_]](https://redis.io/commands/georadius) + +--- + +## georadius(key, longitude, latitude, distance, unit, [options], callback) + +| Arguments | Type | Description | +| ----------- | ----------- | ------------------------------------- | +| `key` | string | Key identifier | +| `longitude` | double | Longitude of the center of the radius | +| `latitude` | double | Latitude of the center of the radius | +| `distance` | double | Maximum distance from the center | +| `unit` | string | Distance unit | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | +| `count` | int | Limit the result set to `count` members | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `sort` | string | Return items from the nearest to the farthest to the center (`ASC`) or vice versa (`DESC`) | `null` | +| `withcoord` | boolean | Also return the longitude and latitude coordinates of the matching items | `false` | +| `withdist` | boolean | Also return the distance of the returned items from the specified center, in the same unit than the one provided with `unit` | `false` | + +--- + +## Callback Response + +Returns an array of names for points that are inside the provided radius. + +## Usage + +<<< ./snippets/georadius-1.js diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js new file mode 100644 index 000000000..417ea2401 --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.georadius('key', 15, 37, 200, 'km', function (err, points) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.georadiusPromise('key', 15, 37, 200, 'km') + .then(points => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js new file mode 100644 index 000000000..814c3f98c --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js @@ -0,0 +1,5 @@ +on +[ + {"name": "Palermo"}, + {"name": "Catania"} +] diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js new file mode 100644 index 000000000..c2f47e84a --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js @@ -0,0 +1,5 @@ +on +[ + {"name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963]}, + {"name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162]} +] diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js new file mode 100644 index 000000000..c57742f47 --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js @@ -0,0 +1,5 @@ +on +[ + {"name": "Palermo", "distance": 190.4424}, + {"name": "Catania", "distance": 56.4413} +] diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/index.md b/doc/5/core-classes/memory-storage/georadiusbymember/index.md new file mode 100644 index 000000000..829fa499c --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadiusbymember/index.md @@ -0,0 +1,70 @@ +--- +code: false +type: page +title: georadiusbymember +description: MemoryStorage:georadiusbymember +--- + +# georadiusbymember + +> Callback response, with the "withcoord" option: + +```json +[ + { "name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963] }, + { "name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162] } +] +``` + +> Callback response, with the "withdist" option: + +```json +[ + { "name": "Palermo", "distance": 190.4424 }, + { "name": "Catania", "distance": 56.4413 } +] +``` + +Returns the members (added with [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)) of a given key inside the provided geospatial radius, centered around one of a key's member. +[[_Redis documentation_]](https://redis.io/commands/georadiusbymember) + +--- + +## georadiusbymember(key, member, distance, unit, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------------------- | +| `key` | string | Key identifier | +| `member` | string | Name of the point to use as the center of the radius | +| `distance` | double | Maximum distance from the center | +| `unit` | string | Distance unit | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | +| `count` | int | Limit the result set to `count` members | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `sort` | string | Return items from the nearest to the farthest to the center (`ASC`) or vice versa (`DESC`) | `null` | +| `withcoord` | boolean | Also return the longitude and latitude coordinates of the matching items | `false` | +| `withdist` | boolean | Also return the distance of the returned items from the specified center, in the same unit than the one provided with `unit` | `false` | + +--- + +## Callback Response + +Returns an array of names for points that are inside the provided radius. + +## Usage + +<<< ./snippets/georadiusbymember-1.js + +> Callback response: + +```json +[{ "name": "Palermo" }, { "name": "Catania" }] +``` diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js new file mode 100644 index 000000000..1553ad7f1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.georadiusbymember('key', 'Palermo', 200, 'km', function (err, points) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.georadiusbymemberPromise('key', 'Palermo', 200, 'km') + .then(points => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js new file mode 100644 index 000000000..814c3f98c --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js @@ -0,0 +1,5 @@ +on +[ + {"name": "Palermo"}, + {"name": "Catania"} +] diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js new file mode 100644 index 000000000..c2f47e84a --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js @@ -0,0 +1,5 @@ +on +[ + {"name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963]}, + {"name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162]} +] diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js new file mode 100644 index 000000000..c57742f47 --- /dev/null +++ b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js @@ -0,0 +1,5 @@ +on +[ + {"name": "Palermo", "distance": 190.4424}, + {"name": "Catania", "distance": 56.4413} +] diff --git a/doc/5/core-classes/memory-storage/get/index.md b/doc/5/core-classes/memory-storage/get/index.md new file mode 100644 index 000000000..6efa32bae --- /dev/null +++ b/doc/5/core-classes/memory-storage/get/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: get +description: MemoryStorage:get +--- + +# get + +Returns the value of a key, or null if the key doesn’t exist. + +[[_Redis documentation_]](https://redis.io/commands/get) + +--- + +## get(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the key's value. + +## Usage + +<<< ./snippets/get-1.js + +> Callback response: + +```json +"value" +``` diff --git a/doc/5/core-classes/memory-storage/get/snippets/get-1.js b/doc/5/core-classes/memory-storage/get/snippets/get-1.js new file mode 100644 index 000000000..88dc20a45 --- /dev/null +++ b/doc/5/core-classes/memory-storage/get/snippets/get-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.get('key', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.getPromise('key') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/get/snippets/get-2.js b/doc/5/core-classes/memory-storage/get/snippets/get-2.js new file mode 100644 index 000000000..232c95de2 --- /dev/null +++ b/doc/5/core-classes/memory-storage/get/snippets/get-2.js @@ -0,0 +1,2 @@ +on +"value" diff --git a/doc/5/core-classes/memory-storage/getbit/index.md b/doc/5/core-classes/memory-storage/getbit/index.md new file mode 100644 index 000000000..056aee190 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getbit/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: getbit +description: MemoryStorage:getbit +--- + +# getbit + +Returns the bit value at `offset`, in the string value stored in a key. + +[[_Redis documentation_]](https://redis.io/commands/getbit) + +--- + +## getbit(key, offset, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------- | +| `key` | string | Key identifier | +| `offset` | int | Offset position in the key's value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the bit value at the provided offset. + +## Usage + +<<< ./snippets/getbit-1.js + +> Callback response: + +```json +1 +``` diff --git a/doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js b/doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js new file mode 100644 index 000000000..c34fc3b73 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.getbit('key', 10, function (err, bit) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.getbitPromise('key', 10) + .then(bit => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js b/doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js new file mode 100644 index 000000000..b52a3a5b9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js @@ -0,0 +1,2 @@ +on +1 diff --git a/doc/5/core-classes/memory-storage/getrange/index.md b/doc/5/core-classes/memory-storage/getrange/index.md new file mode 100644 index 000000000..25f2f2a61 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getrange/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: getrange +description: MemoryStorage:getrange +--- + +# getrange + +Returns a substring of a key's value (index starts at position `0`). + +[[_Redis documentation_]](https://redis.io/commands/getrange) + +--- + +## getrange(key, start, end, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `start` | int | Starting index | +| `end` | int | Ending index | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a substring of the key's value. + +## Usage + +<<< ./snippets/getrange-1.js + +> Callback response: + +```json +"lue" +``` diff --git a/doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js b/doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js new file mode 100644 index 000000000..d95017c5c --- /dev/null +++ b/doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.getrange('key', 2, 4, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.getrangePromise('key', 2, 4) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js b/doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js new file mode 100644 index 000000000..2c016d6db --- /dev/null +++ b/doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js @@ -0,0 +1,2 @@ +on +"lue" diff --git a/doc/5/core-classes/memory-storage/getset/index.md b/doc/5/core-classes/memory-storage/getset/index.md new file mode 100644 index 000000000..ae9ca06d8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getset/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: getset +description: MemoryStorage:getset +--- + +# getset + +Sets a new value for a key and returns its previous value. + +[[_Redis documentation_]](https://redis.io/commands/getset) + +--- + +## getset(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `value` | string | Key's new value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the key's previous value. + +## Usage + +<<< ./snippets/getset-1.js + +> Callback response: + +```json +"value" +``` diff --git a/doc/5/core-classes/memory-storage/getset/snippets/getset-1.js b/doc/5/core-classes/memory-storage/getset/snippets/getset-1.js new file mode 100644 index 000000000..e7fa29268 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getset/snippets/getset-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.getset('key', 'new value', function (err, oldValue) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.getsetPromise('key', 'new value') + .then(oldValue => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/getset/snippets/getset-2.js b/doc/5/core-classes/memory-storage/getset/snippets/getset-2.js new file mode 100644 index 000000000..232c95de2 --- /dev/null +++ b/doc/5/core-classes/memory-storage/getset/snippets/getset-2.js @@ -0,0 +1,2 @@ +on +"value" diff --git a/doc/5/core-classes/memory-storage/hdel/index.md b/doc/5/core-classes/memory-storage/hdel/index.md new file mode 100644 index 000000000..bb45ad605 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hdel/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: hdel +description: MemoryStorage:hdel +--- + +# hdel + +Removes fields from a hash. + +[[_Redis documentation_]](https://redis.io/commands/hdel) + +--- + +## hdel(key, fields, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------- | +| `key` | string | Key identifier | +| `fields` | array | List of field names to delete | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the number of removed fields. + +## Usage + +<<< ./snippets/hdel-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js b/doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js new file mode 100644 index 000000000..0c5b40e42 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hdel('key', ['field1', 'field2'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hdelPromise('key', ['field1', 'field2']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js b/doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/hexists/index.md b/doc/5/core-classes/memory-storage/hexists/index.md new file mode 100644 index 000000000..3e94401ed --- /dev/null +++ b/doc/5/core-classes/memory-storage/hexists/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: hexists +description: MemoryStorage:hexists +--- + +# hexists + +Checks if a field exists in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hexists) + +--- + +## hexists(key, field, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `field` | string | Field name | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +A boolean value specifying if the field exists or not. + +## Usage + +<<< ./snippets/hexists-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js b/doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js new file mode 100644 index 000000000..26c260fe7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hexists('key', 'field1', function (err, exists) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hexistsPromise('key', 'field1') + .then(exists => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js b/doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/hget/index.md b/doc/5/core-classes/memory-storage/hget/index.md new file mode 100644 index 000000000..5322b41f1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hget/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: hget +description: MemoryStorage:hget +--- + +# hget + +Returns the field’s value of a hash. + +[[_Redis documentation_]](https://redis.io/commands/hget) + +--- + +## hget(key, field, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `field` | string | Field name | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the requested field's value. + +## Usage + +<<< ./snippets/hget-1.js + +> Callback response: + +```json +"foo" +``` diff --git a/doc/5/core-classes/memory-storage/hget/snippets/hget-1.js b/doc/5/core-classes/memory-storage/hget/snippets/hget-1.js new file mode 100644 index 000000000..461d8350a --- /dev/null +++ b/doc/5/core-classes/memory-storage/hget/snippets/hget-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hget('key', 'field1', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hgetPromise('key', 'field1') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hget/snippets/hget-2.js b/doc/5/core-classes/memory-storage/hget/snippets/hget-2.js new file mode 100644 index 000000000..f24302b01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hget/snippets/hget-2.js @@ -0,0 +1,2 @@ +on +"foo" diff --git a/doc/5/core-classes/memory-storage/hgetall/index.md b/doc/5/core-classes/memory-storage/hgetall/index.md new file mode 100644 index 000000000..2418b5e26 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hgetall/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: hgetall +description: MemoryStorage:hgetall +--- + +# hgetall + +Returns all fields and values of a hash. + +[[_Redis documentation_]](https://redis.io/commands/hgetall) + +--- + +## hgetall(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a JSON object containing the fields and values of a hash. + +## Usage + +<<< ./snippets/hgetall-1.js + +> Callback response: + +```json +{ + "field1": "value", + "field2": "value", + "...": "..." +} +``` diff --git a/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js b/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js new file mode 100644 index 000000000..dab553b94 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hgetall('key', function (err, hash) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hgetallPromise('key') + .then(hash => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js b/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js new file mode 100644 index 000000000..dfe6f2c8a --- /dev/null +++ b/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js @@ -0,0 +1,6 @@ +on +{ + "field1": "value", + "field2": "value", + "...": "..." +} diff --git a/doc/5/core-classes/memory-storage/hincrby/index.md b/doc/5/core-classes/memory-storage/hincrby/index.md new file mode 100644 index 000000000..9fd655fc6 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hincrby/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: hincrby +description: MemoryStorage:hincrby +--- + +# hincrby + +Increments the number stored in a hash field by the provided integer value. + +[[_Redis documentation_]](https://redis.io/commands/hincrby) + +--- + +## hincrby(key, field, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------- | +| `key` | string | Key identifier | +| `field` | string | Hash field to increment | +| `value` | int | Increment value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the newly incremented value. + +## Usage + +<<< ./snippets/hincrby-1.js + +> Callback response: + +```json +45 +``` diff --git a/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js b/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js new file mode 100644 index 000000000..b31e0f98f --- /dev/null +++ b/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hincrby('key', 'field', 42, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hincrbyPromise('key', 'field', 42) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js b/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js new file mode 100644 index 000000000..8851a4c48 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js @@ -0,0 +1,2 @@ +on +45 diff --git a/doc/5/core-classes/memory-storage/hincrbyfloat/index.md b/doc/5/core-classes/memory-storage/hincrbyfloat/index.md new file mode 100644 index 000000000..928ddf69b --- /dev/null +++ b/doc/5/core-classes/memory-storage/hincrbyfloat/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: hincrbyfloat +description: MemoryStorage:hincrbyfloat +--- + +# hincrbyfloat + +Increments the number stored in a hash field by the provided float value. + +[[_Redis documentation_]](https://redis.io/commands/hincrbyfloat) + +--- + +## hincrbyfloat(key, field, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------- | +| `key` | string | Key identifier | +| `field` | string | Hash field to increment | +| `value` | double | Increment value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the newly incremented value, as a floating point number. + +## Usage + +<<< ./snippets/hincrbyfloat-1.js + +> Callback response: + +```json +48.14159 +``` diff --git a/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js b/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js new file mode 100644 index 000000000..c3c07babc --- /dev/null +++ b/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hincrbyfloat('key', 'field', 3.14159, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hincrbyfloatPromise('key', 'field', 3.14159) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js b/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js new file mode 100644 index 000000000..36507f180 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js @@ -0,0 +1,2 @@ +on +48.14159 diff --git a/doc/5/core-classes/memory-storage/hkeys/index.md b/doc/5/core-classes/memory-storage/hkeys/index.md new file mode 100644 index 000000000..48642fcd3 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hkeys/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: hkeys +description: MemoryStorage:hkeys +--- + +# hkeys + +Returns all field names contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hkeys) + +--- + +## hkeys(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of field names. + +## Usage + +<<< ./snippets/hkeys-1.js + +> Callback response: + +```json +["field1", "field2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js b/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js new file mode 100644 index 000000000..9733a9c40 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hkeys('key', function (err, fields) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hkeysPromise('key') + .then(fields => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js b/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js new file mode 100644 index 000000000..9ca12bcb4 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js @@ -0,0 +1,6 @@ +on +[ + "field1", + "field2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/hlen/index.md b/doc/5/core-classes/memory-storage/hlen/index.md new file mode 100644 index 000000000..df5c9e431 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hlen/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: hlen +description: MemoryStorage:hlen +--- + +# hlen + +Returns the number of fields contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hlen) + +--- + +## hlen(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of fields in the hash. + +## Usage + +<<< ./snippets/hlen-1.js + +> Callback response: + +```json +13 +``` diff --git a/doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js b/doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js new file mode 100644 index 000000000..744995c88 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hlen('key', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hlenPromise('key') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js b/doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js new file mode 100644 index 000000000..f1b8f19fe --- /dev/null +++ b/doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js @@ -0,0 +1,2 @@ +on +13 diff --git a/doc/5/core-classes/memory-storage/hmget/index.md b/doc/5/core-classes/memory-storage/hmget/index.md new file mode 100644 index 000000000..5c1717013 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hmget/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: hmget +description: MemoryStorage:hmget +--- + +# hmget + +Returns the values of the specified hash’s fields. + +[[_Redis documentation_]](https://redis.io/commands/hmget) + +--- + +## hmget(key, fields, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------- | +| `key` | string | Key identifier | +| `fields` | array | List of fields to examine | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array containing the specified fields values. + +## Usage + +<<< ./snippets/hmget-1.js + +> Callback response: + +```json +["field1's value", "field2's value", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js b/doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js new file mode 100644 index 000000000..2daf16594 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hmget('key', ['field1', 'field2', '...'], function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hmgetPromise('key', ['field1', 'field2', '...']) + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js b/doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js new file mode 100644 index 000000000..2091a55af --- /dev/null +++ b/doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js @@ -0,0 +1,6 @@ +on +[ + "field1's value", + "field2's value", + "..." +] diff --git a/doc/5/core-classes/memory-storage/hmset/index.md b/doc/5/core-classes/memory-storage/hmset/index.md new file mode 100644 index 000000000..cfd9485f1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hmset/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: hmset +description: MemoryStorage:hmset +--- + +# hmset + +Sets multiple fields at once in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hmset) + +--- + +## hmset(key, entries, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `key` | string | Key identifier | +| `entries` | array | List of fields to add, with their value. Each entry is described by a JSON object containing the following properties:
`field` (field name), `value` (field's value) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/hmset-1.js diff --git a/doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js b/doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js new file mode 100644 index 000000000..f95b22c00 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js @@ -0,0 +1,16 @@ +var entries = [ + {"field": "field1", "value": "foo"}, + {"field": "field2", "value": "bar"}, + {"field": "...", "value": "..."} +]; + +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hmset('key', entries, function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hmsetPromise('key', entries) + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hscan/index.md b/doc/5/core-classes/memory-storage/hscan/index.md new file mode 100644 index 000000000..a22c45412 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hscan/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: hscan +description: MemoryStorage:hscan +--- + +# hscan + +Identical to [scan](/sdk/js/5/core-classes/memory-storage/scan), except that `hscan` iterates over the fields contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hscan) + +--- + +## hscan(key, cursor, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | +| `key` | string | Key identifier | +| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------- | ------- | +| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | +| `match` | string | Search only for field names matching the provided pattern | `*` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object containing 2 entries: + +- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) +- an array of field names and values + +## Usage + +<<< ./snippets/hscan-1.js + +> Callback response: + +```json +{ + "cursor": 18, + "values": ["field1", "field1 value", "field2", "field2 value"] +} +``` diff --git a/doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js b/doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js new file mode 100644 index 000000000..7facec61c --- /dev/null +++ b/doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hscan('key', 0, function (err, page) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hscanPromise('key', 0) + .then(page => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js b/doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js new file mode 100644 index 000000000..1cfcb5088 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js @@ -0,0 +1,10 @@ +on +{ + "cursor": 18, + "values": [ + "field1", + "field1 value", + "field2", + "field2 value" + ] +} diff --git a/doc/5/core-classes/memory-storage/hset/index.md b/doc/5/core-classes/memory-storage/hset/index.md new file mode 100644 index 000000000..681f1df14 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hset/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: hset +description: MemoryStorage:hset +--- + +# hset + +Sets a field and its value in a hash. If the key does not exist, a new key holding a hash is created. If the field already exists, its value is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/hset) + +--- + +## hset(key, field, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------- | +| `key` | string | Key identifier | +| `field` | string | Field name to insert or to update | +| `value` | string | Associated field value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/hset-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/hset/snippets/hset-1.js b/doc/5/core-classes/memory-storage/hset/snippets/hset-1.js new file mode 100644 index 000000000..d9ea2c703 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hset/snippets/hset-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hset('key', 'field', 'value', function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hsetPromise('key', 'field', 'value') + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hset/snippets/hset-2.js b/doc/5/core-classes/memory-storage/hset/snippets/hset-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/hset/snippets/hset-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/hsetnx/index.md b/doc/5/core-classes/memory-storage/hsetnx/index.md new file mode 100644 index 000000000..967dae516 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hsetnx/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: hsetnx +description: MemoryStorage:hsetnx +--- + +# hsetnx + +Sets a field and its value in a hash, only if the field does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/hsetnx) + +--- + +## hsetnx(key, field, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------- | +| `key` | string | Key identifier | +| `field` | string | Field name to insert or to update | +| `value` | string | Associated field value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/hsetnx-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js b/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js new file mode 100644 index 000000000..60e63cf92 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hsetnx('key', 'field', 'value', function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hsetnxPromise('key', 'field', 'value') + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js b/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/hstrlen/index.md b/doc/5/core-classes/memory-storage/hstrlen/index.md new file mode 100644 index 000000000..cf3896557 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hstrlen/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: hstrlen +description: MemoryStorage:hstrlen +--- + +# hstrlen + +Returns the string length of a field’s value in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hstrlen) + +--- + +## hstrlen(key, field, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `field` | string | Hash field name | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the string length of a field's value. + +## Usage + +<<< ./snippets/hstrlen-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js b/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js new file mode 100644 index 000000000..c40752775 --- /dev/null +++ b/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hstrlen('key', 'field', function (err, length) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hstrlenPromise('key', 'field') + .then(length => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js b/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/hvals/index.md b/doc/5/core-classes/memory-storage/hvals/index.md new file mode 100644 index 000000000..32037b88e --- /dev/null +++ b/doc/5/core-classes/memory-storage/hvals/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: hvals +description: MemoryStorage:hvals +--- + +# hvals + +Returns all values contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hvals) + +--- + +## hvals(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array containing the values of a hash. + +## Usage + +<<< ./snippets/hvals-1.js + +> Callback response: + +```json +["field1's value", "field2's value", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js b/doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js new file mode 100644 index 000000000..de4bf1abd --- /dev/null +++ b/doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.hvals('key', function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.hvalsPromise('key') + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js b/doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js new file mode 100644 index 000000000..2091a55af --- /dev/null +++ b/doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js @@ -0,0 +1,6 @@ +on +[ + "field1's value", + "field2's value", + "..." +] diff --git a/doc/5/core-classes/memory-storage/incr/index.md b/doc/5/core-classes/memory-storage/incr/index.md new file mode 100644 index 000000000..0a4e352d9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/incr/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: incr +description: MemoryStorage:incr +--- + +# incr + +Increments the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incr) + +--- + +## incr(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated key value. + +## Usage + +<<< ./snippets/incr-1.js + +> Callback response: + +```json +42 +``` diff --git a/doc/5/core-classes/memory-storage/incr/snippets/incr-1.js b/doc/5/core-classes/memory-storage/incr/snippets/incr-1.js new file mode 100644 index 000000000..4738ccff7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/incr/snippets/incr-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.incr('key', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.incrPromise('key') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/incr/snippets/incr-2.js b/doc/5/core-classes/memory-storage/incr/snippets/incr-2.js new file mode 100644 index 000000000..37c3eb98c --- /dev/null +++ b/doc/5/core-classes/memory-storage/incr/snippets/incr-2.js @@ -0,0 +1,2 @@ +on +42 diff --git a/doc/5/core-classes/memory-storage/incrby/index.md b/doc/5/core-classes/memory-storage/incrby/index.md new file mode 100644 index 000000000..1120542e1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/incrby/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: incrby +description: MemoryStorage:incrby +--- + +# incrby + +Increments the number stored at `key` by the provided integer value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incrby) + +--- + +## incrby(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `value` | int | Increment value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated key value. + +## Usage + +<<< ./snippets/incrby-1.js + +> Callback response: + +```json +39 +``` diff --git a/doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js b/doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js new file mode 100644 index 000000000..c000641e1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.incrby('key', -3, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.incrbyPromise('key', -3) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js b/doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js new file mode 100644 index 000000000..e16c5dd01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js @@ -0,0 +1,2 @@ +on +39 diff --git a/doc/5/core-classes/memory-storage/incrbyfloat/index.md b/doc/5/core-classes/memory-storage/incrbyfloat/index.md new file mode 100644 index 000000000..3e7c6b584 --- /dev/null +++ b/doc/5/core-classes/memory-storage/incrbyfloat/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: incrbyfloat +description: MemoryStorage:incrbyfloat +--- + +# incrbyfloat + +Increments the number stored at `key` by the provided float value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incrbyfloat) + +--- + +## incrbyfloat(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `value` | double | Increment value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a floating point number that contains the updated key value. + +## Usage + +<<< ./snippets/incrbyfloat-1.js + +> Callback response: + +```json +38.85841 +``` diff --git a/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js b/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js new file mode 100644 index 000000000..23a466e0b --- /dev/null +++ b/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.incrbyfloat('key', -3.14159, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.incrbyfloatPromise('key', -3.14159) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js b/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js new file mode 100644 index 000000000..ee0587c3d --- /dev/null +++ b/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js @@ -0,0 +1,2 @@ +on +38.85841 diff --git a/doc/5/core-classes/memory-storage/index.md b/doc/5/core-classes/memory-storage/index.md new file mode 100644 index 000000000..8cca5f310 --- /dev/null +++ b/doc/5/core-classes/memory-storage/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: MemoryStorage +description: MemoryStorage documentation +--- diff --git a/doc/5/core-classes/memory-storage/keys/index.md b/doc/5/core-classes/memory-storage/keys/index.md new file mode 100644 index 000000000..124460575 --- /dev/null +++ b/doc/5/core-classes/memory-storage/keys/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: keys +description: MemoryStorage:keys +--- + +# keys + +Returns all keys matching the provided pattern. + +[[_Redis documentation_]](https://redis.io/commands/keys) + +--- + +## keys(pattern, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------- | +| `pattern` | string | Pattern used to filter the returned key names | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of key names matching the provided pattern. + +## Usage + +<<< ./snippets/keys-1.js + +> Callback response: + +```json +["foo", "foobar", "foofighters"] +``` diff --git a/doc/5/core-classes/memory-storage/keys/snippets/keys-1.js b/doc/5/core-classes/memory-storage/keys/snippets/keys-1.js new file mode 100644 index 000000000..8f76af182 --- /dev/null +++ b/doc/5/core-classes/memory-storage/keys/snippets/keys-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.keys('foo*', function (err, keys) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.keysPromise('foo*') + .then(keys => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/keys/snippets/keys-2.js b/doc/5/core-classes/memory-storage/keys/snippets/keys-2.js new file mode 100644 index 000000000..20d7ee850 --- /dev/null +++ b/doc/5/core-classes/memory-storage/keys/snippets/keys-2.js @@ -0,0 +1,6 @@ +on +[ + "foo", + "foobar", + "foofighters" +] diff --git a/doc/5/core-classes/memory-storage/lindex/index.md b/doc/5/core-classes/memory-storage/lindex/index.md new file mode 100644 index 000000000..81d068f4c --- /dev/null +++ b/doc/5/core-classes/memory-storage/lindex/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: lindex +description: MemoryStorage:lindex +--- + +# lindex + +Returns the element at the provided index in a list. + +[[_Redis documentation_]](https://redis.io/commands/lindex) + +--- + +## lindex(key, index, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------- | +| `key` | string | Key identifier | +| `index` | int | Element position in the list | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a string containing the retrieved element's value. + +## Usage + +<<< ./snippets/lindex-1.js + +> Callback response: + +```json +"foo" +``` diff --git a/doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js b/doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js new file mode 100644 index 000000000..f6aee8d19 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lindex('key', 3, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lindexPromise('key', 3) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js b/doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js new file mode 100644 index 000000000..f24302b01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js @@ -0,0 +1,2 @@ +on +"foo" diff --git a/doc/5/core-classes/memory-storage/linsert/index.md b/doc/5/core-classes/memory-storage/linsert/index.md new file mode 100644 index 000000000..2a8f02880 --- /dev/null +++ b/doc/5/core-classes/memory-storage/linsert/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: linsert +description: MemoryStorage:linsert +--- + +# linsert + +Inserts a value in a list, either before or after the reference pivot value. + +[[_Redis documentation_]](https://redis.io/commands/linsert) + +--- + +## linsert(key, position, pivot, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------- | +| `key` | string | Key identifier | +| `position` | string | Indicates if the new value is to be inserted before or after the pivot value.
Allowed values: `before`, `after` | +| `pivot` | string | Pivot value used as a point of reference in the list | +| `value` | string | The value to insert | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated number of items in the list. + +## Usage + +<<< ./snippets/linsert-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js b/doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js new file mode 100644 index 000000000..eceeb012f --- /dev/null +++ b/doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.linsert('key', 'after', 'foo', 'bar', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.linsertPromise('key', 'after', 'foo', 'bar') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js b/doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/llen/index.md b/doc/5/core-classes/memory-storage/llen/index.md new file mode 100644 index 000000000..680aad099 --- /dev/null +++ b/doc/5/core-classes/memory-storage/llen/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: llen +description: MemoryStorage:llen +--- + +# llen + +Counts the number of items in a list. + +[[_Redis documentation_]](https://redis.io/commands/llen) + +--- + +## llen(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of items of a list. + +## Usage + +<<< ./snippets/llen-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/llen/snippets/llen-1.js b/doc/5/core-classes/memory-storage/llen/snippets/llen-1.js new file mode 100644 index 000000000..2cdc6f787 --- /dev/null +++ b/doc/5/core-classes/memory-storage/llen/snippets/llen-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.llen('key', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.llenPromise('key') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/llen/snippets/llen-2.js b/doc/5/core-classes/memory-storage/llen/snippets/llen-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/llen/snippets/llen-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/lpop/index.md b/doc/5/core-classes/memory-storage/lpop/index.md new file mode 100644 index 000000000..f1bbed674 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpop/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: lpop +description: MemoryStorage:lpop +--- + +# lpop + +Removes and returns the first element of a list. + +[[_Redis documentation_]](https://redis.io/commands/lpop) + +--- + +## lpop(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the value of the removed item. + +## Usage + +<<< ./snippets/lpop-1.js + +> Callback response: + +```json +"foo" +``` diff --git a/doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js b/doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js new file mode 100644 index 000000000..7de8b04fa --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lpop('key', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lpopPromise('key') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js b/doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js new file mode 100644 index 000000000..f24302b01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js @@ -0,0 +1,2 @@ +on +"foo" diff --git a/doc/5/core-classes/memory-storage/lpush/index.md b/doc/5/core-classes/memory-storage/lpush/index.md new file mode 100644 index 000000000..e76093e27 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpush/index.md @@ -0,0 +1,51 @@ +--- +code: false +type: page +title: lpush +description: MemoryStorage:lpush +--- + +# lpush + +Prepends the specified values to a list. If the key does not exist, it is created holding an empty list before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/lpush) + +--- + +## lpush(key, values, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------ | +| `key` | string | Key identifier | +| `values` | array | Values to add at the beginning of the list | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated number of items in the list. + +## Usage + +<<< ./snippets/lpush-1.js + +> Callback response: + +```json +6 +``` diff --git a/doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js b/doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js new file mode 100644 index 000000000..dcceb1321 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lpush('key', ['foo', 'bar', 'baz'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lpushPromise('key', ['foo', 'bar', 'baz']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js b/doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js new file mode 100644 index 000000000..eb054e2c9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js @@ -0,0 +1,2 @@ +on +6 diff --git a/doc/5/core-classes/memory-storage/lpushx/index.md b/doc/5/core-classes/memory-storage/lpushx/index.md new file mode 100644 index 000000000..e35a3874f --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpushx/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: lpushx +description: MemoryStorage:lpushx +--- + +# lpushx + +Prepends the specified value to a list, only if the key already exists and if it holds a list. + +[[_Redis documentation_]](https://redis.io/commands/lpushx) + +--- + +## lpushx(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `key` | string | Key identifier | +| `value` | array | Value to add at the beginning of the list | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated number of items in the list. + +## Usage + +<<< ./snippets/lpushx-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js b/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js new file mode 100644 index 000000000..6402a95de --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lpushx('key', 'foo', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lpushxPromise('key', 'foo') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js b/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/lrange/index.md b/doc/5/core-classes/memory-storage/lrange/index.md new file mode 100644 index 000000000..7197445c8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lrange/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: lrange +description: MemoryStorage:lrange +--- + +# lrange + +Returns the list elements between the start and stop positions (inclusive). + +[[_Redis documentation_]](https://redis.io/commands/lrange) + +--- + +## lrange(key, start, stop, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `start` | int | Start position | +| `stop` | int | End position | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of retrieved values. + +## Usage + +<<< ./snippets/lrange-1.js + +> Callback response: + +```json +["foo", "bar"] +``` diff --git a/doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js b/doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js new file mode 100644 index 000000000..f5d626418 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lrange('key', 0, 1, function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lrangePromise('key', 0, 1) + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js b/doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js new file mode 100644 index 000000000..40f7d1c40 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js @@ -0,0 +1,5 @@ +on +[ + "foo", + "bar" +] diff --git a/doc/5/core-classes/memory-storage/lrem/index.md b/doc/5/core-classes/memory-storage/lrem/index.md new file mode 100644 index 000000000..29f5f02ef --- /dev/null +++ b/doc/5/core-classes/memory-storage/lrem/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: lrem +description: MemoryStorage:lrem +--- + +# lrem + +Removes the first `count` occurences of elements equal to `value` from a list. + +[[_Redis documentation_]](https://redis.io/commands/lrem) + +--- + +## lrem(key, count, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `count` | int | Number of occurences of the value to remove | +| `value` | string | Value to be removed from the list | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of removed elements. + +## Usage + +<<< ./snippets/lrem-1.js + +> Callback response: + +```json +1 +``` diff --git a/doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js b/doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js new file mode 100644 index 000000000..0edd79920 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lrem('key', 1, 'foo', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lremPromise('key', 1, 'foo') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js b/doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js new file mode 100644 index 000000000..b52a3a5b9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js @@ -0,0 +1,2 @@ +on +1 diff --git a/doc/5/core-classes/memory-storage/lset/index.md b/doc/5/core-classes/memory-storage/lset/index.md new file mode 100644 index 000000000..8a00bee81 --- /dev/null +++ b/doc/5/core-classes/memory-storage/lset/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: lset +description: MemoryStorage:lset +--- + +# lset + +Sets the list element at `index` with the provided value. + +[[_Redis documentation_]](https://redis.io/commands/lset) + +--- + +## lset(key, index, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------ | +| `key` | string | Key identifier | +| `index` | int | Position of the list to update | +| `value` | string | New value at the provided list index | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/lset-1.js diff --git a/doc/5/core-classes/memory-storage/lset/snippets/lset-1.js b/doc/5/core-classes/memory-storage/lset/snippets/lset-1.js new file mode 100644 index 000000000..e6d1e2dcd --- /dev/null +++ b/doc/5/core-classes/memory-storage/lset/snippets/lset-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.lset('key', 2, 'bar', function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.lsetPromise('key', 2, 'bar') + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/ltrim/index.md b/doc/5/core-classes/memory-storage/ltrim/index.md new file mode 100644 index 000000000..0d8622dee --- /dev/null +++ b/doc/5/core-classes/memory-storage/ltrim/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: ltrim +description: MemoryStorage:ltrim +--- + +# ltrim + +Trims an existing list so that it will contain only the specified range of elements specified. + +[[_Redis documentation_]](https://redis.io/commands/ltrim) + +--- + +## ltrim(key, start, stop, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------------- | +| `key` | string | Key identifier | +| `start` | int | Starting position of the range of items to keep (inclusive) | +| `stop` | int | Ending position of the range of items to keep (inclusive) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/ltrim-1.js diff --git a/doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js b/doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js new file mode 100644 index 000000000..c71aa0893 --- /dev/null +++ b/doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.ltrim('key', 1, 2, function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.ltrimPromise('key', 1, 2) + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/mget/index.md b/doc/5/core-classes/memory-storage/mget/index.md new file mode 100644 index 000000000..12214475f --- /dev/null +++ b/doc/5/core-classes/memory-storage/mget/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: mget +description: MemoryStorage:mget +--- + +# mget + +Returns the values of the provided keys. + +[[_Redis documentation_]](https://redis.io/commands/mget) + +--- + +## mget(keys, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------ | +| `keys` | string | List of keys to retrieve | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of the specified keys' values. + +## Usage + +<<< ./snippets/mget-1.js + +> Callback response: + +```json +["key1's value", "key2's value", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/mget/snippets/mget-1.js b/doc/5/core-classes/memory-storage/mget/snippets/mget-1.js new file mode 100644 index 000000000..19c8fc02e --- /dev/null +++ b/doc/5/core-classes/memory-storage/mget/snippets/mget-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.mget(['key1', 'key2', '...'], function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.mgetPromise(['key1', 'key2', '...']) + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/mget/snippets/mget-2.js b/doc/5/core-classes/memory-storage/mget/snippets/mget-2.js new file mode 100644 index 000000000..dde14abc8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/mget/snippets/mget-2.js @@ -0,0 +1,6 @@ +on +[ + "key1's value", + "key2's value", + "..." +] diff --git a/doc/5/core-classes/memory-storage/mset/index.md b/doc/5/core-classes/memory-storage/mset/index.md new file mode 100644 index 000000000..e5dac6ff3 --- /dev/null +++ b/doc/5/core-classes/memory-storage/mset/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: mset +description: MemoryStorage:mset +--- + +# mset + +Sets the provided keys to their respective values. If a key does not exist, it is created. Otherwise, the key’s value is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/mset) + +--- + +## mset(entries, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `entries` | array | List of objects each containing the key identifier to add with its associated value.
Properties: `key` (key identifier), `value` (associated value) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/mset-1.js diff --git a/doc/5/core-classes/memory-storage/mset/snippets/mset-1.js b/doc/5/core-classes/memory-storage/mset/snippets/mset-1.js new file mode 100644 index 000000000..b6fa0b3e0 --- /dev/null +++ b/doc/5/core-classes/memory-storage/mset/snippets/mset-1.js @@ -0,0 +1,16 @@ +var entries = [ + {key: 'key1', value: 'foo'}, + {key: 'key2', value: 'bar'}, + {key: '...', value: '...'} +]; + +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.mset(entries, function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.msetPromise(entries) + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/msetnx/index.md b/doc/5/core-classes/memory-storage/msetnx/index.md new file mode 100644 index 000000000..bcf95432f --- /dev/null +++ b/doc/5/core-classes/memory-storage/msetnx/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: msetnx +description: MemoryStorage:msetnx +--- + +# msetnx + +Sets the provided keys to their respective values, only if they do not exist. If a key exists, then the whole operation is aborted and no key is set. + +[[_Redis documentation_]](https://redis.io/commands/msetnx) + +--- + +## msetnx(entries, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `entries` | array | List of objects each containing the key identifier to add with its associated value.
Properties: `key` (key identifier), `value` (associated value) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/msetnx-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js b/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js new file mode 100644 index 000000000..76719e44b --- /dev/null +++ b/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js @@ -0,0 +1,16 @@ +var entries = [ + {key: 'key1', value: 'foo'}, + {key: 'key2', value: 'bar'}, + {key: '...', value: '...'} +]; + +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.msetnx(entries, function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.msetnxPromise(entries) + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js b/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/object/index.md b/doc/5/core-classes/memory-storage/object/index.md new file mode 100644 index 000000000..7d836228e --- /dev/null +++ b/doc/5/core-classes/memory-storage/object/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: object +description: MemoryStorage:object +--- + +# object + +Inspects the low-level properties of a key. + +[[_Redis documentation_]](https://redis.io/commands/object) + +--- + +## object(key, subcommand, [options], callback) + +| Arguments | Type | Description | +| ------------ | ----------- | ------------------------------------------------------------------------------------------------- | +| `key` | string | Key identifier | +| `subcommand` | string | Name of the low-level property to inspect.
Allowed values: `refcount`, `encoding`, `idletime` | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the value of the inspected property. + +## Usage + +<<< ./snippets/object-1.js + +> Callback response: + +```json +"raw" +``` diff --git a/doc/5/core-classes/memory-storage/object/snippets/object-1.js b/doc/5/core-classes/memory-storage/object/snippets/object-1.js new file mode 100644 index 000000000..eb7772c75 --- /dev/null +++ b/doc/5/core-classes/memory-storage/object/snippets/object-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.object('key', 'encoding', function (err, property) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.objectPromise('key', 'encoding') + .then(property => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/object/snippets/object-2.js b/doc/5/core-classes/memory-storage/object/snippets/object-2.js new file mode 100644 index 000000000..59e8899c6 --- /dev/null +++ b/doc/5/core-classes/memory-storage/object/snippets/object-2.js @@ -0,0 +1,2 @@ +on +"raw" diff --git a/doc/5/core-classes/memory-storage/persist/index.md b/doc/5/core-classes/memory-storage/persist/index.md new file mode 100644 index 000000000..50d26e174 --- /dev/null +++ b/doc/5/core-classes/memory-storage/persist/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: persist +description: MemoryStorage:persist +--- + +# persist + +Removes the expiration delay or timestamp from a key, making it persistent. + +[[_Redis documentation_]](https://redis.io/commands/persist) + +--- + +## persist(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/persist-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/persist/snippets/persist-1.js b/doc/5/core-classes/memory-storage/persist/snippets/persist-1.js new file mode 100644 index 000000000..88143a266 --- /dev/null +++ b/doc/5/core-classes/memory-storage/persist/snippets/persist-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.persist('key', function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.persistPromise('key') + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/persist/snippets/persist-2.js b/doc/5/core-classes/memory-storage/persist/snippets/persist-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/persist/snippets/persist-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/pexpire/index.md b/doc/5/core-classes/memory-storage/pexpire/index.md new file mode 100644 index 000000000..57757e0b7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pexpire/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: pexpire +description: MemoryStorage:pexpire +--- + +# pexpire + +Sets a timeout (in milliseconds) on a key. After the timeout has expired, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/pexpire) + +--- + +## pexpire(key, ttl, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------- | +| `key` | string | Key identifier | +| `ttl` | int | Time to live of the key, in milliseconds | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/pexpire-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js b/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js new file mode 100644 index 000000000..76c8a0ba4 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.pexpire('key', 42000, function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pexpirePromise('key', 42000) + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js b/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/pexpireat/index.md b/doc/5/core-classes/memory-storage/pexpireat/index.md new file mode 100644 index 000000000..584e13120 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pexpireat/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: pexpireat +description: MemoryStorage:pexpireat +--- + +# pexpireat + +Sets an expiration timestamp on a key. After the timestamp has been reached, the key will automatically be deleted. +The `timestamp` parameter accepts an [Epoch time](https://en.wikipedia.org/wiki/Unix_time) value, in milliseconds. + +[[_Redis documentation_]](https://redis.io/commands/pexpireat) + +--- + +## pexpireat(key, timestamp, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `timestamp` | int | Key's expiration timestamp, in milliseconds | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/pexpireat-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js b/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js new file mode 100644 index 000000000..26c040991 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.pexpireat('key', 1488540242465, function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pexpireatPromise('key', 1488540242465) + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js b/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/pfadd/index.md b/doc/5/core-classes/memory-storage/pfadd/index.md new file mode 100644 index 000000000..d1298f3e2 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfadd/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: pfadd +description: MemoryStorage:pfadd +--- + +# pfadd + +Adds elements to an [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure. + +[[_Redis documentation_]](https://redis.io/commands/pfadd) + +--- + +## pfadd(key, elements, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------- | +| `key` | string | Key identifier | +| `elements` | array | Elements to add to the HyperLogLog structure | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/pfadd-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js b/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js new file mode 100644 index 000000000..1d2e9e7d5 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.pfadd('key', ['foo', 'bar', 'baz'], function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pfaddPromise('key', ['foo', 'bar', 'baz']) + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js b/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/pfcount/index.md b/doc/5/core-classes/memory-storage/pfcount/index.md new file mode 100644 index 000000000..1d0e36b2c --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfcount/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: pfcount +description: MemoryStorage:pfcount +--- + +# pfcount + +Returns the probabilistic cardinality of a [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure, or of the merged HyperLogLog structures if more than 1 is provided (see [pfadd](/sdk/js/5/core-classes/memory-storage/pfadd)). + +[[_Redis documentation_]](https://redis.io/commands/pfcount) + +--- + +## pfcount(keys, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------- | +| `keys` | string | List of HyperLogLog key identifiers | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the aggregated probabilistic cardinality of HyperLogLog structures. + +## Usage + +<<< ./snippets/pfcount-1.js + +> Callback response: + +```json +42 +``` diff --git a/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js b/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js new file mode 100644 index 000000000..6ee5d9765 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.pfcount(['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pfcountPromise(['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js b/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js new file mode 100644 index 000000000..37c3eb98c --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js @@ -0,0 +1,2 @@ +on +42 diff --git a/doc/5/core-classes/memory-storage/pfmerge/index.md b/doc/5/core-classes/memory-storage/pfmerge/index.md new file mode 100644 index 000000000..cc0ba41a2 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfmerge/index.md @@ -0,0 +1,41 @@ +--- +code: false +type: page +title: pfmerge +description: MemoryStorage:pfmerge +--- + +# pfmerge + +Merges multiple [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structures into an unique HyperLogLog structure stored at `key`, approximating the cardinality of the union of the source structures. + +[[_Redis documentation_]](https://redis.io/commands/pfmerge) + +--- + +## pfmerge(key, sources, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------ | +| `key` | string | Destination key identifier | +| `sources` | string | List of HyperLogLog source key identifiers | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/pfmerge-1.js diff --git a/doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js b/doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js new file mode 100644 index 000000000..ef22a9359 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.pfmerge('key', ['key1', 'key2', '...'], function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pfmergePromise('key', ['key1', 'key2', '...']) + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/ping/index.md b/doc/5/core-classes/memory-storage/ping/index.md new file mode 100644 index 000000000..44ea61ff7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/ping/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: ping +description: MemoryStorage:ping +--- + +# ping + +Pings the memory storage database. + +[[_Redis documentation_]](https://redis.io/commands/ping) + +--- + +## ping([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a simple "PONG" string. + +## Usage + +<<< ./snippets/ping-1.js + +> Callback response: + +```json +"PONG" +``` diff --git a/doc/5/core-classes/memory-storage/ping/snippets/ping-1.js b/doc/5/core-classes/memory-storage/ping/snippets/ping-1.js new file mode 100644 index 000000000..6f9f8e273 --- /dev/null +++ b/doc/5/core-classes/memory-storage/ping/snippets/ping-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.ping(function (err, response) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pingPromise() + .then(response => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/ping/snippets/ping-2.js b/doc/5/core-classes/memory-storage/ping/snippets/ping-2.js new file mode 100644 index 000000000..ef9b43de6 --- /dev/null +++ b/doc/5/core-classes/memory-storage/ping/snippets/ping-2.js @@ -0,0 +1,2 @@ +on +"PONG" diff --git a/doc/5/core-classes/memory-storage/psetex/index.md b/doc/5/core-classes/memory-storage/psetex/index.md new file mode 100644 index 000000000..1bbb33cb7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/psetex/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: psetex +description: MemoryStorage:psetex +--- + +# psetex + +Sets a key with the provided value, and an expiration delay expressed in milliseconds. If the key does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/psetex) + +--- + +## psetex(key, value, ttl, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------- | +| `key` | string | Key identifier | +| `value` | string | Value to set | +| `ttl` | int | Time to live of the key, in milliseconds | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/psetex-1.js diff --git a/doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js b/doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js new file mode 100644 index 000000000..322d8d30c --- /dev/null +++ b/doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.psetex('key', 'value', 42000, function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.psetexPromise('key', 'value', 42000) + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/pttl/index.md b/doc/5/core-classes/memory-storage/pttl/index.md new file mode 100644 index 000000000..009463f8b --- /dev/null +++ b/doc/5/core-classes/memory-storage/pttl/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: pttl +description: MemoryStorage:pttl +--- + +# pttl + +Returns the remaining time to live of a key, in milliseconds. + +[[_Redis documentation_]](https://redis.io/commands/pttl) + +--- + +## pttl(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the remaining time to live of the key, in milliseconds. + +## Usage + +<<< ./snippets/pttl-1.js + +> Callback response: + +```json +43159 +``` diff --git a/doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js b/doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js new file mode 100644 index 000000000..b596c3544 --- /dev/null +++ b/doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.pttl('key', function (err, ttl) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.pttlPromise('key') + .then(ttl => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js b/doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js new file mode 100644 index 000000000..839222ead --- /dev/null +++ b/doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js @@ -0,0 +1,2 @@ +on +43159 diff --git a/doc/5/core-classes/memory-storage/randomkey/index.md b/doc/5/core-classes/memory-storage/randomkey/index.md new file mode 100644 index 000000000..b3ccbfce6 --- /dev/null +++ b/doc/5/core-classes/memory-storage/randomkey/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: randomkey +description: MemoryStorage:randomkey +--- + +# randomkey + +Returns a random key from the memory storage. + +[[_Redis documentation_]](https://redis.io/commands/randomkey) + +--- + +## randomkey([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns one of the stored key names, at random. + +## Usage + +<<< ./snippets/randomkey-1.js + +> Callback response: + +```json +"key2" +``` diff --git a/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js b/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js new file mode 100644 index 000000000..0c2bb2d31 --- /dev/null +++ b/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.randomkey(function (err, key) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.randomkeyPromise() + .then(key => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js b/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js new file mode 100644 index 000000000..682be0988 --- /dev/null +++ b/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js @@ -0,0 +1,2 @@ +on +"key2" diff --git a/doc/5/core-classes/memory-storage/rename/index.md b/doc/5/core-classes/memory-storage/rename/index.md new file mode 100644 index 000000000..5d2e410f8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rename/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: rename +description: MemoryStorage:rename +--- + +# rename + +Renames a key to `newkey`. If `newkey` already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/rename) + +--- + +## rename(key, newkey, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `newkey` | string | New key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/rename-1.js diff --git a/doc/5/core-classes/memory-storage/rename/snippets/rename-1.js b/doc/5/core-classes/memory-storage/rename/snippets/rename-1.js new file mode 100644 index 000000000..ebd89d174 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rename/snippets/rename-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.rename('key', 'newId', function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.renamePromise('key', 'newId') + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/renamenx/index.md b/doc/5/core-classes/memory-storage/renamenx/index.md new file mode 100644 index 000000000..af2ad4dd0 --- /dev/null +++ b/doc/5/core-classes/memory-storage/renamenx/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: renamenx +description: MemoryStorage:renamenx +--- + +# renamenx + +Renames a key to `newkey`, only if `newkey` does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/renamenx) + +--- + +## renamenx(key, newkey, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `newkey` | string | New key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/renamenx-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js b/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js new file mode 100644 index 000000000..24151ddf0 --- /dev/null +++ b/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.renamenx('key', 'newId', function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.renamenxPromise('key', 'newId') + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js b/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/rpop/index.md b/doc/5/core-classes/memory-storage/rpop/index.md new file mode 100644 index 000000000..0c18a7e88 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpop/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: rpop +description: MemoryStorage:rpop +--- + +# rpop + +Removes and returns the last element of a list. + +[[_Redis documentation_]](https://redis.io/commands/rpop) + +--- + +## rpop(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the value of the removed item. + +## Usage + +<<< ./snippets/rpop-1.js + +> Callback response: + +```json +"foo" +``` diff --git a/doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js b/doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js new file mode 100644 index 000000000..b6a5fcd50 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.rpop('key', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.rpopPromise('key') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js b/doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js new file mode 100644 index 000000000..f24302b01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js @@ -0,0 +1,2 @@ +on +"foo" diff --git a/doc/5/core-classes/memory-storage/rpoplpush/index.md b/doc/5/core-classes/memory-storage/rpoplpush/index.md new file mode 100644 index 000000000..3afc95506 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpoplpush/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: rpoplpush +description: MemoryStorage:rpoplpush +--- + +# rpoplpush + +Removes the last element of the list at `source` and pushes it back at the start of the list at `destination`. + +[[_Redis documentation_]](https://redis.io/commands/rpoplpush) + +--- + +## rpoplpush(source, destination, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | -------------------------- | +| `source` | string | Source key identifier | +| `destination` | string | Destination key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns the value of the removed and pushed item. + +## Usage + +<<< ./snippets/rpoplpush-1.js + +> Callback response: + +```json +"foo" +``` diff --git a/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js b/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js new file mode 100644 index 000000000..ca762bdab --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.rpoplpush('sourceKey', 'destKey', function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.rpoplpushPromise('sourceKey', 'destKey') + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js b/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js new file mode 100644 index 000000000..f24302b01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js @@ -0,0 +1,2 @@ +on +"foo" diff --git a/doc/5/core-classes/memory-storage/rpush/index.md b/doc/5/core-classes/memory-storage/rpush/index.md new file mode 100644 index 000000000..034ab8686 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpush/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: rpush +description: MemoryStorage:rpush +--- + +# rpush + +Appends the specified values at the end of a list. If the key does not exist, it is created holding an empty list before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/rpush) + +--- + +## rpush(key, values, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------ | +| `key` | string | Key identifier | +| `values` | array | Values to add at the end of the list | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated number of items in the list. + +## Usage + +<<< ./snippets/rpush-1.js + +> Callback response: + +```json +6 +``` diff --git a/doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js b/doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js new file mode 100644 index 000000000..e1661871a --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.rpush('key', ['foo', 'bar', 'baz'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.rpushPromise('key', ['foo', 'bar', 'baz']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js b/doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js new file mode 100644 index 000000000..eb054e2c9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js @@ -0,0 +1,2 @@ +on +6 diff --git a/doc/5/core-classes/memory-storage/rpushx/index.md b/doc/5/core-classes/memory-storage/rpushx/index.md new file mode 100644 index 000000000..5a16c6f9c --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpushx/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: rpushx +description: MemoryStorage:rpushx +--- + +# rpushx + +Appends the specified value at the end of a list, only if the key already exists and if it holds a list. + +[[_Redis documentation_]](https://redis.io/commands/rpushx) + +--- + +## rpushx(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------- | +| `key` | string | Key identifier | +| `value` | string | Value to add at the end of the list | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the updated number of items in the list. + +## Usage + +<<< ./snippets/rpushx-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js b/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js new file mode 100644 index 000000000..995e4a6bf --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.rpushx('key', 'foo', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.rpushxPromise('key', 'foo') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js b/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/sadd/index.md b/doc/5/core-classes/memory-storage/sadd/index.md new file mode 100644 index 000000000..cd72c8e58 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sadd/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: sadd +description: MemoryStorage:sadd +--- + +# sadd + +Adds members to a set of unique values stored at `key`. If the `key` does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/sadd) + +--- + +## sadd(key, members, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `members` | array | Members to add to the list of unique values | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of added elements to the set. + +## Usage + +<<< ./snippets/sadd-1.js + +> Callback response: + +```json +6 +``` diff --git a/doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js b/doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js new file mode 100644 index 000000000..72f38b802 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sadd('key', ['foo', 'bar', 'baz'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.saddPromise('key', ['foo', 'bar', 'baz']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js b/doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js new file mode 100644 index 000000000..eb054e2c9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js @@ -0,0 +1,2 @@ +on +6 diff --git a/doc/5/core-classes/memory-storage/scan/index.md b/doc/5/core-classes/memory-storage/scan/index.md new file mode 100644 index 000000000..16c98f17a --- /dev/null +++ b/doc/5/core-classes/memory-storage/scan/index.md @@ -0,0 +1,58 @@ +--- +code: false +type: page +title: scan +description: MemoryStorage:scan +--- + +# scan + +Iterates incrementally over the set of keys in the database using a cursor. + +An iteration starts when the cursor is set to `0`. +To get the next page of results, simply re-send the identical request with the updated cursor position provided in the result set. +The scan terminates when the next position cursor returned by the server is `0`. + +[[_Redis documentation_]](https://redis.io/commands/scan) + +--- + +## scan(cursor, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | +| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------- | ------- | +| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | +| `match` | string | Search only for field names matching the provided pattern | `*` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a JSON object containing 2 entries: + +- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) +- a list of fetched keys + +## Usage + +<<< ./snippets/scan-1.js + +> Callback response: + +```json +{ + "cursor": 18, + "values": ["key1", "key2", "..."] +} +``` diff --git a/doc/5/core-classes/memory-storage/scan/snippets/scan-1.js b/doc/5/core-classes/memory-storage/scan/snippets/scan-1.js new file mode 100644 index 000000000..fbede7508 --- /dev/null +++ b/doc/5/core-classes/memory-storage/scan/snippets/scan-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.scan(0, function (err, page) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.scanPromise(0) + .then(page => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/scan/snippets/scan-2.js b/doc/5/core-classes/memory-storage/scan/snippets/scan-2.js new file mode 100644 index 000000000..a244e04b7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/scan/snippets/scan-2.js @@ -0,0 +1,9 @@ +on +{ + "cursor": 18, + "values": [ + "key1", + "key2", + "..." + ] +} diff --git a/doc/5/core-classes/memory-storage/scard/index.md b/doc/5/core-classes/memory-storage/scard/index.md new file mode 100644 index 000000000..a23f6cbe7 --- /dev/null +++ b/doc/5/core-classes/memory-storage/scard/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: scard +description: MemoryStorage:scard +--- + +# scard + +Returns the number of members stored in a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/scard) + +--- + +## scard(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of items in the set. + +## Usage + +<<< ./snippets/scard-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/scard/snippets/scard-1.js b/doc/5/core-classes/memory-storage/scard/snippets/scard-1.js new file mode 100644 index 000000000..bf37bd413 --- /dev/null +++ b/doc/5/core-classes/memory-storage/scard/snippets/scard-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.scard('key', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.scardPromise('key') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/scard/snippets/scard-2.js b/doc/5/core-classes/memory-storage/scard/snippets/scard-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/scard/snippets/scard-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/sdiff/index.md b/doc/5/core-classes/memory-storage/sdiff/index.md new file mode 100644 index 000000000..fdd23d0a3 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sdiff/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: sdiff +description: MemoryStorage:sdiff +--- + +# sdiff + +Returns the difference between the set of unique values stored at `key` and the other provided sets. + +[[_Redis documentation_]](https://redis.io/commands/sdiff) + +--- + +## sdiff(key, keys, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------- | +| `key` | string | Key identifier to compare | +| `keys` | array | list of set keys to compare with the set stored at `key` | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of differences. + +## Usage + +<<< ./snippets/sdiff-1.js + +> Callback response: + +```json +["diff value1", "diff value2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js b/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js new file mode 100644 index 000000000..c822d0c2b --- /dev/null +++ b/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sdiff('key', ['key1', 'key2', '...'], function (err, diff) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sdiffPromise('key', ['key1', 'key2', '...']) + .then(diff => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js b/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js new file mode 100644 index 000000000..79759d7ea --- /dev/null +++ b/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js @@ -0,0 +1,6 @@ +on +[ + "diff value1", + "diff value2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/sdiffstore/index.md b/doc/5/core-classes/memory-storage/sdiffstore/index.md new file mode 100644 index 000000000..1c720b8e4 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sdiffstore/index.md @@ -0,0 +1,56 @@ +--- +code: false +type: page +title: sdiffstore +description: MemoryStorage:sdiffstore +--- + +# sdiffstore + +Computes the difference between the set of unique values stored at `key` and the other provided sets, and stores the result in the key stored at `destination`. + +If the `destination` key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sdiffstore) + +--- + +## sdiffstore(key, keys, destination, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | -------------------------------------------------------- | +| `key` | string | Key identifier to compare | +| `keys` | array | list of set keys to compare with the set stored at `key` | +| `destination` | string | Destination key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of stored elements. + +## Usage + +<<< ./snippets/sdiffstore-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js b/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js new file mode 100644 index 000000000..9bb9345be --- /dev/null +++ b/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sdiffstore('key', ['key1', 'key2', '...'], 'destination', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sdiffstorePromise('key', ['key1', 'key2', '...'], 'destination') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js b/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/set/index.md b/doc/5/core-classes/memory-storage/set/index.md new file mode 100644 index 000000000..8815f244a --- /dev/null +++ b/doc/5/core-classes/memory-storage/set/index.md @@ -0,0 +1,51 @@ +--- +code: false +type: page +title: set +description: MemoryStorage:set +--- + +# set + +Creates a key holding the provided value, or overwrites it if it already exists. + +[[_Redis documentation_]](https://redis.io/commands/set) + +--- + +## set(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `value` | string | Value to store | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------------------- | ------- | +| `ex` | int | Time to live of the key, in seconds | `0` | +| `nx` | boolean | Set the key only if it does not already exist | `false` | +| `px` | int | Time to live of the key, in milliseconds | `0` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `xx` | boolean | Set the key only if it already exists | `false` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/set-1.js diff --git a/doc/5/core-classes/memory-storage/set/snippets/set-1.js b/doc/5/core-classes/memory-storage/set/snippets/set-1.js new file mode 100644 index 000000000..77e4992ad --- /dev/null +++ b/doc/5/core-classes/memory-storage/set/snippets/set-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.set('key', 'value', function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.setPromise('key', 'value') + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/setex/index.md b/doc/5/core-classes/memory-storage/setex/index.md new file mode 100644 index 000000000..57147ef96 --- /dev/null +++ b/doc/5/core-classes/memory-storage/setex/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: setex +description: MemoryStorage:setex +--- + +# setex + +Sets a key with the provided value, and an expiration delay expressed in seconds. If the key does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/setex) + +--- + +## setex(key, value, ttl, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------- | +| `key` | string | Key identifier | +| `value` | string | Value to set | +| `ttl` | int | Time to live of the key, in seconds | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns null if successful. + +## Usage + +<<< ./snippets/setex-1.js diff --git a/doc/5/core-classes/memory-storage/setex/snippets/setex-1.js b/doc/5/core-classes/memory-storage/setex/snippets/setex-1.js new file mode 100644 index 000000000..a30ffec20 --- /dev/null +++ b/doc/5/core-classes/memory-storage/setex/snippets/setex-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.setex('key', 'value', 42, function (err) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.setexPromise('key', 'value', 42) + .then(() => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/setnx/index.md b/doc/5/core-classes/memory-storage/setnx/index.md new file mode 100644 index 000000000..91be4558d --- /dev/null +++ b/doc/5/core-classes/memory-storage/setnx/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: setnx +description: MemoryStorage:setnx +--- + +# setnx + +Sets a value on a key, only if it does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/setnx) + +--- + +## setnx(key, value, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `value` | string | Value to store | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/setnx-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js b/doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js new file mode 100644 index 000000000..fa3b0ee98 --- /dev/null +++ b/doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.setnx('key', 'value', function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.setnxPromise('key', 'value') + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js b/doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/sinter/index.md b/doc/5/core-classes/memory-storage/sinter/index.md new file mode 100644 index 000000000..90ceee157 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sinter/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: sinter +description: MemoryStorage:sinter +--- + +# sinter + +Returns the intersection of the provided sets of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sinter) + +--- + +## sinter(keys, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------ | +| `keys` | string | List of sets of unique values to intersect | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of values in the computed intersection. + +## Usage + +<<< ./snippets/sinter-1.js + +> Callback response: + +```json +["intersection value1", "intersection value2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js b/doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js new file mode 100644 index 000000000..4830f1e50 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sinter(['key1', 'key2', '...'], function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sinterPromise(['key1', 'key2', '...']) + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js b/doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js new file mode 100644 index 000000000..f05b38176 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js @@ -0,0 +1,6 @@ +on +[ + "intersection value1", + "intersection value2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/sinterstore/index.md b/doc/5/core-classes/memory-storage/sinterstore/index.md new file mode 100644 index 000000000..6b7242a96 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sinterstore/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: sinterstore +description: MemoryStorage:sinterstore +--- + +# sinterstore + +Computes the intersection of the provided sets of unique values and stores the result in the `destination` key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sinterstore) + +--- + +## sinterstore(destination, keys, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `destination` | string | Destination key identifier | +| `keys` | array | List of sets of unique values to intersect | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of elements in the stored intersection. + +## Usage + +<<< ./snippets/sinterstore-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js b/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js new file mode 100644 index 000000000..ade6374b4 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sinterstore('destination', ['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sinterstorePromise('destination', ['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js b/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/sismember/index.md b/doc/5/core-classes/memory-storage/sismember/index.md new file mode 100644 index 000000000..3141f1ac9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sismember/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: sismember +description: MemoryStorage:sismember +--- + +# sismember + +Checks if `member` is a member of the set of unique values stored at `key`. + +[[_Redis documentation_]](https://redis.io/commands/sismember) + +--- + +## sismember(key, member, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------- | +| `key` | string | Key identifier | +| `member` | string | Value tested against the set of unique values | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a boolean specifying if `member` is a member of the set or not. + +## Usage + +<<< ./snippets/sismember-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js b/doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js new file mode 100644 index 000000000..ba27cd1d0 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sismember('key', 'member', function (err, isMember) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sismemberPromise('key', 'member') + .then(isMember => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js b/doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/smembers/index.md b/doc/5/core-classes/memory-storage/smembers/index.md new file mode 100644 index 000000000..8f9c77d38 --- /dev/null +++ b/doc/5/core-classes/memory-storage/smembers/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: smembers +description: MemoryStorage:smembers +--- + +# smembers + +Returns the members of a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/smembers) + +--- + +## smembers(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of values held by the provided set. + +## Usage + +<<< ./snippets/smembers-1.js + +> Callback response: + +```json +["member1", "member2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js b/doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js new file mode 100644 index 000000000..62c102e80 --- /dev/null +++ b/doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.smembers('key', function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.smembersPromise('key') + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js b/doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js new file mode 100644 index 000000000..395de0670 --- /dev/null +++ b/doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js @@ -0,0 +1,6 @@ +on +[ + "member1", + "member2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/smove/index.md b/doc/5/core-classes/memory-storage/smove/index.md new file mode 100644 index 000000000..33f2b7b34 --- /dev/null +++ b/doc/5/core-classes/memory-storage/smove/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: smove +description: MemoryStorage:smove +--- + +# smove + +Moves a member from a set of unique values to another. + +[[_Redis documentation_]](https://redis.io/commands/smove) + +--- + +## smove(key, destination, member, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | -------------------------- | +| `key` | string | Source key identifier | +| `destination` | string | Destination key identifier | +| `member` | string | Member to be moved | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a boolean specifying if the operation was successful or not. + +## Usage + +<<< ./snippets/smove-1.js + +> Callback response: + +```json +true +``` diff --git a/doc/5/core-classes/memory-storage/smove/snippets/smove-1.js b/doc/5/core-classes/memory-storage/smove/snippets/smove-1.js new file mode 100644 index 000000000..e3f85e36c --- /dev/null +++ b/doc/5/core-classes/memory-storage/smove/snippets/smove-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.smove('key', 'destination', 'member', function (err, status) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.smovePromise('key', 'destination', 'member') + .then(status => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/smove/snippets/smove-2.js b/doc/5/core-classes/memory-storage/smove/snippets/smove-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/memory-storage/smove/snippets/smove-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/memory-storage/sort/index.md b/doc/5/core-classes/memory-storage/sort/index.md new file mode 100644 index 000000000..afec34dbc --- /dev/null +++ b/doc/5/core-classes/memory-storage/sort/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: sort +description: MemoryStorage:sort +--- + +# sort + +Sorts and returns elements contained in a list, a set of unique values or a sorted set. +By default, sorting is numeric and elements are compared by their value interpreted as double precision floating point number. + +
+While Kuzzle's API supports the "store" option for this command, Kuzzle SDK methods do not. To sort and store in the same process, use the [query method](/sdk/js/5/core-classes/kuzzle/query) +
+ +[[_Redis documentation_]](https://redis.io/commands/sort) + +### sort(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `alpha` | boolean | Perform an alphanumerical sort instead of a numeric one | `false` | +| `by` | string | Instead of sorting the values stored at `key`, use them to complete the provided key pattern, and return the sorted list of values stored in those keys. | `null` | +| `direction` | string | Sort in ascendant (`ASC`) or descendant (`DESC`) order | `ASC` | +| `get` | array | Sort the values stored at `key` but, instead of returning these directly, return the values contained in external keys, using the provided array of patterns completed by the sorted values | `null` | +| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +### Callback Response + +Returns an array of sorted values. + +## Usage + +<<< ./snippets/sort-1.js + +> Callback response: + +```json +["sorted element1", "sorted element2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/sort/snippets/sort-1.js b/doc/5/core-classes/memory-storage/sort/snippets/sort-1.js new file mode 100644 index 000000000..61c4b1ce9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sort/snippets/sort-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sort('key', function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sortPromise('key') + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sort/snippets/sort-2.js b/doc/5/core-classes/memory-storage/sort/snippets/sort-2.js new file mode 100644 index 000000000..c864c8a17 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sort/snippets/sort-2.js @@ -0,0 +1,6 @@ +on +[ + "sorted element1", + "sorted element2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/spop/index.md b/doc/5/core-classes/memory-storage/spop/index.md new file mode 100644 index 000000000..a2a8687e9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/spop/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: spop +description: MemoryStorage:spop +--- + +# spop + +Removes and returns one or more elements at random from a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/spop) + +--- + +## spop(key, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `count` | int | Number of elements to remove | `1` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of removed elements. + +## Usage + +<<< ./snippets/spop-1.js + +> Callback response: + +```json +["removed element"] +``` diff --git a/doc/5/core-classes/memory-storage/spop/snippets/spop-1.js b/doc/5/core-classes/memory-storage/spop/snippets/spop-1.js new file mode 100644 index 000000000..95bf62c3a --- /dev/null +++ b/doc/5/core-classes/memory-storage/spop/snippets/spop-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.spop('key', function (err, elements) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.spopPromise('key') + .then(elements => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/spop/snippets/spop-2.js b/doc/5/core-classes/memory-storage/spop/snippets/spop-2.js new file mode 100644 index 000000000..781ac6cc2 --- /dev/null +++ b/doc/5/core-classes/memory-storage/spop/snippets/spop-2.js @@ -0,0 +1,2 @@ +on +[ "removed element" ] diff --git a/doc/5/core-classes/memory-storage/srandmember/index.md b/doc/5/core-classes/memory-storage/srandmember/index.md new file mode 100644 index 000000000..e4dc0efb1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/srandmember/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: srandmember +description: MemoryStorage:srandmember +--- + +# srandmember + +Returns one or more members of a set of unique values, at random. +If `count` is provided and is positive, the returned values are unique. If `count` is negative, a set member can be returned multiple times. + +[[_Redis documentation_]](https://redis.io/commands/srandmember) + +--- + +## srandmember(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `count` | int | Number of members to return. If set with a positive value, the returned values are unique. If `count` is negative, a set member can be returned multiple times | `1` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of members of a set of unique values. + +## Usage + +<<< ./snippets/srandmember-1.js + +> Callback response: + +```json +["member1", "member2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js b/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js new file mode 100644 index 000000000..0f798f5cc --- /dev/null +++ b/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.srandmember('key', function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.srandmemberPromise('key') + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js b/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js new file mode 100644 index 000000000..395de0670 --- /dev/null +++ b/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js @@ -0,0 +1,6 @@ +on +[ + "member1", + "member2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/srem/index.md b/doc/5/core-classes/memory-storage/srem/index.md new file mode 100644 index 000000000..f99083caf --- /dev/null +++ b/doc/5/core-classes/memory-storage/srem/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: srem +description: MemoryStorage:srem +--- + +# srem + +Removes members from a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/srem) + +--- + +## srem(key, members, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------- | +| `key` | string | Key identifier | +| `members` | array | List of members to remove from the set | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of removed elements. + +## Usage + +<<< ./snippets/srem-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/srem/snippets/srem-1.js b/doc/5/core-classes/memory-storage/srem/snippets/srem-1.js new file mode 100644 index 000000000..26c454584 --- /dev/null +++ b/doc/5/core-classes/memory-storage/srem/snippets/srem-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.srem('key', ['member1', 'member2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sremPromise('key', ['member1', 'member2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/srem/snippets/srem-2.js b/doc/5/core-classes/memory-storage/srem/snippets/srem-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/srem/snippets/srem-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/sscan/index.md b/doc/5/core-classes/memory-storage/sscan/index.md new file mode 100644 index 000000000..e10263a64 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sscan/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: sscan +description: MemoryStorage:sscan +--- + +# sscan + +Identical to [scan](/sdk/js/5/core-classes/memory-storage/scan), except that `sscan` iterates the members held by a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sscan) + +--- + +## sscan(key, cursor, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | +| `key` | string | Key identifier | +| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------- | ------- | +| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | +| `match` | string | Search only for member values matching the provided pattern | `*` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a JSON array containing 2 entries: + +- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) +- an array of members + +## Usage + +<<< ./snippets/sscan-1.js + +> Callback response: + +```json +{ + "cursor": 18, + "values": ["member1", "member2", "..."] +} +``` diff --git a/doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js b/doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js new file mode 100644 index 000000000..e547fda85 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sscan('key', 0, function (err, page) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sscanPromise('key', 0) + .then(page => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js b/doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js new file mode 100644 index 000000000..6cefe3d94 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js @@ -0,0 +1,9 @@ +on +{ + "cursor": 18, + "values": [ + "member1", + "member2", + "..." + ] +} diff --git a/doc/5/core-classes/memory-storage/strlen/index.md b/doc/5/core-classes/memory-storage/strlen/index.md new file mode 100644 index 000000000..4613199fc --- /dev/null +++ b/doc/5/core-classes/memory-storage/strlen/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: strlen +description: MemoryStorage:strlen +--- + +# strlen + +Returns the length of a value stored at `key`. + +[[_Redis documentation_]](https://redis.io/commands/strlen) + +--- + +## strlen(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the length of a value. + +## Usage + +<<< ./snippets/strlen-1.js + +> Callback response: + +```json +13 +``` diff --git a/doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js b/doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js new file mode 100644 index 000000000..758284a04 --- /dev/null +++ b/doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.strlen('key', function (err, length) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.strlenPromise('key') + .then(length => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js b/doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js new file mode 100644 index 000000000..f1b8f19fe --- /dev/null +++ b/doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js @@ -0,0 +1,2 @@ +on +13 diff --git a/doc/5/core-classes/memory-storage/sunion/index.md b/doc/5/core-classes/memory-storage/sunion/index.md new file mode 100644 index 000000000..49300d91c --- /dev/null +++ b/doc/5/core-classes/memory-storage/sunion/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: sunion +description: MemoryStorage:sunion +--- + +# sunion + +Returns the union of the provided sets of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sunion) + +--- + +## sunion(keys, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------- | +| `keys` | string | List of sets of unique values | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of values in the computed union. + +## Usage + +<<< ./snippets/sunion-1.js + +> Callback response: + +```json +["union value1", "union value2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js b/doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js new file mode 100644 index 000000000..07c13c595 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sunion(['key1', 'key2', '...'], function (err, values) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sunionPromise(['key1', 'key2', '...']) + .then(values => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js b/doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js new file mode 100644 index 000000000..193bfbf2a --- /dev/null +++ b/doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js @@ -0,0 +1,6 @@ +on +[ + "union value1", + "union value2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/sunionstore/index.md b/doc/5/core-classes/memory-storage/sunionstore/index.md new file mode 100644 index 000000000..2eb6ace32 --- /dev/null +++ b/doc/5/core-classes/memory-storage/sunionstore/index.md @@ -0,0 +1,49 @@ +--- +code: false +type: page +title: sunionstore +description: MemoryStorage:sunionstore +--- + +# sunionstore + +Computes the union of the provided sets of unique values and stores the result in the `destination` key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sunionstore) + +--- + +## sunionstore(destination, keys, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `destination` | string | Destination key identifier | +| `keys` | string | List of sets of unique values to intersect | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of elements in the stored union. + +## Usage + +<<< ./snippets/sunionstore-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js b/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js new file mode 100644 index 000000000..9a392200b --- /dev/null +++ b/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.sunionstore('destination', ['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.sunionstorePromise('destination', ['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js b/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/time/index.md b/doc/5/core-classes/memory-storage/time/index.md new file mode 100644 index 000000000..c314b07b1 --- /dev/null +++ b/doc/5/core-classes/memory-storage/time/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: time +description: MemoryStorage:time +--- + +# time + +Returns the current server time. + +[[_Redis documentation_]](https://redis.io/commands/time) + +--- + +## time([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array containing the following two items, in this order: + +- a timestamp in [Epoch time](https://en.wikipedia.org/wiki/Unix_time) +- the number of microseconds already elapsed in the current second + +## Usage + +<<< ./snippets/time-1.js + +> Callback response: + +```json +[1488791347, 494938] +``` diff --git a/doc/5/core-classes/memory-storage/time/snippets/time-1.js b/doc/5/core-classes/memory-storage/time/snippets/time-1.js new file mode 100644 index 000000000..8a99b5f70 --- /dev/null +++ b/doc/5/core-classes/memory-storage/time/snippets/time-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.time(function (err, result) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.timePromise() + .then(result => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/time/snippets/time-2.js b/doc/5/core-classes/memory-storage/time/snippets/time-2.js new file mode 100644 index 000000000..dcfc96b5c --- /dev/null +++ b/doc/5/core-classes/memory-storage/time/snippets/time-2.js @@ -0,0 +1,5 @@ +on +[ + 1488791347, + 494938 +] diff --git a/doc/5/core-classes/memory-storage/touch/index.md b/doc/5/core-classes/memory-storage/touch/index.md new file mode 100644 index 000000000..84394ff64 --- /dev/null +++ b/doc/5/core-classes/memory-storage/touch/index.md @@ -0,0 +1,52 @@ +--- +code: false +type: page +title: touch +description: MemoryStorage:touch +--- + +# touch + +Alters the last access time of one or multiple keys. A key is ignored if it does not exist. + +[[_Redis documentation_]](https://redis.io/commands/touch) + +--- + +## touch(keys, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------- | +| `keys` | array | List of keys to alter | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of altered keys. + +## Usage + +<<< ./snippets/touch-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/touch/snippets/touch-1.js b/doc/5/core-classes/memory-storage/touch/snippets/touch-1.js new file mode 100644 index 000000000..d88a95c02 --- /dev/null +++ b/doc/5/core-classes/memory-storage/touch/snippets/touch-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.touch(['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.touchPromise(['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/touch/snippets/touch-2.js b/doc/5/core-classes/memory-storage/touch/snippets/touch-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/touch/snippets/touch-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/ttl/index.md b/doc/5/core-classes/memory-storage/ttl/index.md new file mode 100644 index 000000000..6f5fd3aeb --- /dev/null +++ b/doc/5/core-classes/memory-storage/ttl/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: ttl +description: MemoryStorage:ttl +--- + +# ttl + +Returns the remaining time to live of a key, in seconds, or a negative value if the key does not exist or if it is persistent. + +[[_Redis documentation_]](https://redis.io/commands/ttl) + +--- + +## ttl(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the remaining time to live of the key, in seconds. + +## Usage + +<<< ./snippets/ttl-1.js + +> Callback response: + +```json +42 +``` diff --git a/doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js b/doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js new file mode 100644 index 000000000..c6b300fd5 --- /dev/null +++ b/doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.ttl('key', function (err, ttl) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.ttlPromise('key') + .then(ttl => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js b/doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js new file mode 100644 index 000000000..37c3eb98c --- /dev/null +++ b/doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js @@ -0,0 +1,2 @@ +on +42 diff --git a/doc/5/core-classes/memory-storage/type/index.md b/doc/5/core-classes/memory-storage/type/index.md new file mode 100644 index 000000000..08bdfdf23 --- /dev/null +++ b/doc/5/core-classes/memory-storage/type/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: type +description: MemoryStorage:type +--- + +# type + +Returns the type of the value held by a key. + +[[_Redis documentation_]](https://redis.io/commands/type) + +--- + +## type(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns one of the following values: `hash`, `list`, `set`, `string`, `zset`. + +## Usage + +<<< ./snippets/type-1.js + +> Callback response: + +```json +"zset" +``` diff --git a/doc/5/core-classes/memory-storage/type/snippets/type-1.js b/doc/5/core-classes/memory-storage/type/snippets/type-1.js new file mode 100644 index 000000000..eba024d6f --- /dev/null +++ b/doc/5/core-classes/memory-storage/type/snippets/type-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.type('key', function (err, type) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.typePromise('key') + .then(type => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/type/snippets/type-2.js b/doc/5/core-classes/memory-storage/type/snippets/type-2.js new file mode 100644 index 000000000..31d71e164 --- /dev/null +++ b/doc/5/core-classes/memory-storage/type/snippets/type-2.js @@ -0,0 +1,2 @@ +on +"zset" diff --git a/doc/5/core-classes/memory-storage/zadd/index.md b/doc/5/core-classes/memory-storage/zadd/index.md new file mode 100644 index 000000000..6cc639388 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zadd/index.md @@ -0,0 +1,61 @@ +--- +code: false +type: page +title: zadd +description: MemoryStorage:zadd +--- + +# zadd + +Adds the specified elements to the sorted set stored at `key`. If the key does not exist, it is created, holding an empty sorted set. If it already exists and does not hold a sorted set, an error is returned. + +Scores are expressed as floating point numbers. + +If a member to insert is already in the sorted set, its score is updated and the member is reinserted at the right position in the set. + +[[_Redis documentation_]](https://redis.io/commands/zadd) + +--- + +## zadd(key, elements, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `key` | string | Key identifier | +| `elements` | array | List of JSON objects detailing the element to add to the sorted set.
Properties: `score` (element's score, `double`), `member` (element's value, `string`) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `ch` | boolean | Instead of returning the number of added allements, return the total number of changes performed (including updates) | `false` | +| `incr` | boolean | Instead of adding elements, increment the existing member with the provided `score` value. Only one score+element pair can be specified if this option is set | `false` | +| `nx` | boolean | Only add new elements, do not update existing ones | `false` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `xx` | boolean | Never add new elements, update only exiting ones | `false` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of elements added to the sorted set. + +## Usage + +<<< ./snippets/zadd-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js b/doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js new file mode 100644 index 000000000..664f564ed --- /dev/null +++ b/doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js @@ -0,0 +1,16 @@ +var elements = [ + {'score': 1, 'member': 'foo'}, + {'score': 2, 'member': 'bar'}, + {'score': 3, 'member': 'baz'} +]; + +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zadd('key', elements, function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zaddPromise('key', elements) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js b/doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/zcard/index.md b/doc/5/core-classes/memory-storage/zcard/index.md new file mode 100644 index 000000000..47621abac --- /dev/null +++ b/doc/5/core-classes/memory-storage/zcard/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: zcard +description: MemoryStorage:zcard +--- + +# zcard + +Returns the number of elements held by a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zcard) + +--- + +## zcard(key, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of elements in a sorted set. + +## Usage + +<<< ./snippets/zcard-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js b/doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js new file mode 100644 index 000000000..c899ebc01 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zcard('key', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zcardPromise('key') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js b/doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/zcount/index.md b/doc/5/core-classes/memory-storage/zcount/index.md new file mode 100644 index 000000000..8d591f9af --- /dev/null +++ b/doc/5/core-classes/memory-storage/zcount/index.md @@ -0,0 +1,50 @@ +--- +code: false +type: page +title: zcount +description: MemoryStorage:zcount +--- + +# zcount + +Returns the number of elements held by a sorted set with a score between the provided `min` and `max` values. + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYSCORE](https://redis.io/commands/zrangebyscore) documentation. + +[[_Redis documentation_]](https://redis.io/commands/zcount) + +--- + +## zcount(key, min, max, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------ | +| `key` | string | Key identifier | +| `min` | int | Minimum score (inclusive by default) | +| `max` | int | Maximum score (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of elements in the provided score range. + +## Usage + +<<< ./snippets/zcount-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js b/doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js new file mode 100644 index 000000000..bf8f41c1e --- /dev/null +++ b/doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zcount('key', 2, 3, function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zcountPromise('key', 2, 3) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js b/doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/zincrby/index.md b/doc/5/core-classes/memory-storage/zincrby/index.md new file mode 100644 index 000000000..f53708851 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zincrby/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: zincrby +description: MemoryStorage:zincrby +--- + +# zincrby + +Increments the score of a `member` in a sorted set by the provided `value`. + +[[_Redis documentation_]](https://redis.io/commands/zincrby) + +--- + +## zincrby(key, member, increment, [options], [callback]) + +| Arguments | Type | Description | +| ----------- | ----------- | --------------------------- | +| `key` | string | Key identifier | +| `member` | string | Member element to increment | +| `increment` | double | Increment value | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns a double containing the updated member's score in the sorted set. + +## Usage + +<<< ./snippets/zincrby-1.js + +> Callback response: + +```json +4.14159 +``` diff --git a/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js b/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js new file mode 100644 index 000000000..692cec1fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zincrby('key', 'foo', 3.14159, function (err, value) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zincrbyPromise('key', 'foo', 3.14159) + .then(value => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js b/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js new file mode 100644 index 000000000..fa1491d6b --- /dev/null +++ b/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js @@ -0,0 +1,2 @@ +on +4.14159 diff --git a/doc/5/core-classes/memory-storage/zinterstore/index.md b/doc/5/core-classes/memory-storage/zinterstore/index.md new file mode 100644 index 000000000..3fa1f0673 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zinterstore/index.md @@ -0,0 +1,51 @@ +--- +code: false +type: page +title: zinterstore +description: MemoryStorage:zinterstore +--- + +# zinterstore + +Computes the intersection of the provided sorted sets and stores the result in the `destination` key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/zinterstore) + +--- + +## zinterstore(destination, keys, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | -------------------------------- | +| `destination` | string | Destination key identifier | +| `keys` | string | List of sorted sets to intersect | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------- | ------- | ----------------------------------------------------------------------------------------------------------- | ------- | +| `aggregate` | string | Specify how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | `sum` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `weights` | array | Specify a multiplication factor for each input sorted set | `[1]` | + +--- + +## Callback Response + +Returns an integer containing the number of members in the stored intersection. + +## Usage + +<<< ./snippets/zinterstore-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js b/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js new file mode 100644 index 000000000..66c56622f --- /dev/null +++ b/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zinterstore('destination', ['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zinterstorePromise('destination', ['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js b/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/memory-storage/zlexcount/index.md b/doc/5/core-classes/memory-storage/zlexcount/index.md new file mode 100644 index 000000000..c4e514aef --- /dev/null +++ b/doc/5/core-classes/memory-storage/zlexcount/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: zlexcount +description: MemoryStorage:zlexcount +--- + +# zlexcount + +Counts elements in a sorted set where all members have equal score, using lexicographical ordering. The `min` and `max` values are inclusive by default. To change this behavior, please check the syntax detailed in the [Redis documentation](https://redis.io/commands/zrangebylex). + +[[_Redis documentation_]](https://redis.io/commands/zlexcount) + +--- + +## zlexcount(key, min, max, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `min` | string | Minimum member value (inclusive by default) | +| `max` | string | Maximum member value (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the number of elements in the provided lexicographical value range. + +## Usage + +<<< ./snippets/zlexcount-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js b/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js new file mode 100644 index 000000000..ddefd255e --- /dev/null +++ b/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zlexcount('key', '[b', '[f' function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zlexcountPromise('key', '[b', '[f') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js b/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/zrange/index.md b/doc/5/core-classes/memory-storage/zrange/index.md new file mode 100644 index 000000000..c773a4128 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrange/index.md @@ -0,0 +1,62 @@ +--- +code: false +type: page +title: zrange +description: MemoryStorage:zrange +--- + +# zrange + +Returns elements from a sorted set depending on their position in the set, from a `start` position index to a `stop` position index (inclusives). +First position starts at `0`. + +[[_Redis documentation_]](https://redis.io/commands/zrange) + +--- + +## zrange(key, start, stop, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------- | +| `key` | string | Key identifier | +| `start` | int | Start position in the set (index starts at position `0`) | +| `stop` | int | End position in the set | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of objects, each containing the following properties: + +- `member`: member value in the sorted set +- `score`: member associated score + +## Usage + +<<< ./snippets/zrange-1.js + +> Callback response: + +```json +[ + { "member": "foo", "score": 1 }, + { "member": "bar", "score": 2 }, + { "member": "baz", "score": 3 } +] +``` diff --git a/doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js b/doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js new file mode 100644 index 000000000..935941814 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrange('key', 0, -1, function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrangePromise('key', 0, -1) + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js b/doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js new file mode 100644 index 000000000..08faf171a --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js @@ -0,0 +1,6 @@ +on +[ + { "member": "foo", "score": 1 }, + { "member": "bar", "score": 2 }, + { "member": "baz", "score": 3 } +] diff --git a/doc/5/core-classes/memory-storage/zrangebylex/index.md b/doc/5/core-classes/memory-storage/zrangebylex/index.md new file mode 100644 index 000000000..3fadf336c --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrangebylex/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: zrangebylex +description: MemoryStorage:zrangebylex +--- + +# zrangebylex + +Returns elements in a sorted set where all members have equal score, using lexicographical ordering. The `min` and `max` values are inclusive by default. To change this behavior, please check the full documentation. + +[[_Redis documentation_]](https://redis.io/commands/zrangebylex) + +--- + +## zrangebylex(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `min` | string | Minimum member value (inclusive by default) | +| `max` | string | Maximum member value (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of matching members. + +## Usage + +<<< ./snippets/zrangebylex-1.js + +> Callback response: + +```json +["member1", "member2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js b/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js new file mode 100644 index 000000000..c2c909aca --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrangebylex('key', '-', '(g', function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrangebylexPromise('key', '-', '(g') + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js b/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js new file mode 100644 index 000000000..395de0670 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js @@ -0,0 +1,6 @@ +on +[ + "member1", + "member2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/zrangebyscore/index.md b/doc/5/core-classes/memory-storage/zrangebyscore/index.md new file mode 100644 index 000000000..5d8000759 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrangebyscore/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: zrangebyscore +description: MemoryStorage:zrangebyscore +--- + +# zrangebyscore + +Returns all the elements in the sorted set at key with a score between `min` and `max` (inclusive). The elements are considered to be ordered from low to high scores. + +[[_Redis documentation_]](https://redis.io/commands/zrangebyscore) + +--- + +## zrangebyscore(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------ | +| `key` | string | Key identifier | +| `min` | double | Minimum score value (inclusive by default) | +| `max` | double | Maximum score value (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of matching members. + +## Usage + +<<< ./snippets/zrangebyscore-1.js + +> Callback response: + +```json +[ + { "member": "foo", "score": 1 }, + { "member": "bar", "score": 2 }, + { "member": "baz", "score": 3 } +] +``` diff --git a/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js b/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js new file mode 100644 index 000000000..ed837921d --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrangebyscore('key', 2, 3, function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrangebyscorePromise('key', 2, 3) + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js b/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js new file mode 100644 index 000000000..08faf171a --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js @@ -0,0 +1,6 @@ +on +[ + { "member": "foo", "score": 1 }, + { "member": "bar", "score": 2 }, + { "member": "baz", "score": 3 } +] diff --git a/doc/5/core-classes/memory-storage/zrank/index.md b/doc/5/core-classes/memory-storage/zrank/index.md new file mode 100644 index 000000000..ce1078102 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrank/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: zrank +description: MemoryStorage:zrank +--- + +# zrank + +Returns the position of an element in a sorted set, with scores in ascending order. The index returned is 0-based (the lowest score member has an index of 0). + +[[_Redis documentation_]](https://redis.io/commands/zrank) + +--- + +## zrank(key, member, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------ | +| `key` | string | Key identifier | +| `member` | string | Member of the sorted set | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the member's position in the sorted set. + +## Usage + +<<< ./snippets/zrank-1.js + +> Callback response: + +```json +0 +``` diff --git a/doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js b/doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js new file mode 100644 index 000000000..2e4ac99e4 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrank('key', 'foo', function (err, position) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrankPromise('key', 'foo') + .then(position => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js b/doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js new file mode 100644 index 000000000..41199acf8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js @@ -0,0 +1,2 @@ +on +0 diff --git a/doc/5/core-classes/memory-storage/zrem/index.md b/doc/5/core-classes/memory-storage/zrem/index.md new file mode 100644 index 000000000..bc7d356c9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrem/index.md @@ -0,0 +1,53 @@ +--- +code: false +type: page +title: zrem +description: MemoryStorage:zrem +--- + +# zrem + +Removes members from a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zrem) + +--- + +## zrem(key, members, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------- | +| `key` | string | Key identifier | +| `members` | array | List of members to remove | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of members removed from the sorted set. + +## Usage + +<<< ./snippets/zrem-1.js + +> Callback response: + +```json +3 +``` diff --git a/doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js b/doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js new file mode 100644 index 000000000..a4aa48ce2 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrem('key', ['foo', 'bar', 'baz'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zremPromise('key', ['foo', 'bar', 'baz']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js b/doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js new file mode 100644 index 000000000..de250b6fb --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js @@ -0,0 +1,2 @@ +on +3 diff --git a/doc/5/core-classes/memory-storage/zremrangebylex/index.md b/doc/5/core-classes/memory-storage/zremrangebylex/index.md new file mode 100644 index 000000000..e234fd01a --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebylex/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: zremrangebylex +description: MemoryStorage:zremrangebylex +--- + +# zremrangebylex + +Removes members from a sorted set where all elements have the same score, using lexicographical ordering. The `min` and `max` interval are inclusive, see the [Redis documentation](https://redis.io/commands/zrangebylex) to change this behavior. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebylex) + +--- + +## zremrangebylex(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `min` | string | Minimum member value (inclusive by default) | +| `max` | string | Maximum member value (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of removed members from the sorted set. + +## Usage + +<<< ./snippets/zremrangebylex-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js b/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js new file mode 100644 index 000000000..db4af6a12 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zremrangebylex('key', '[b', '(f', function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zremrangebylexPromise('key', '[b', '(f') + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js b/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/zremrangebyrank/index.md b/doc/5/core-classes/memory-storage/zremrangebyrank/index.md new file mode 100644 index 000000000..12a0a9f18 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebyrank/index.md @@ -0,0 +1,56 @@ +--- +code: false +type: page +title: zremrangebyrank +description: MemoryStorage:zremrangebyrank +--- + +# zremrangebyrank + +Removes members from a sorted set with their position in the set between `start` and `stop` (inclusive). + +Positions are 0-based, meaning the first member of the set has a position of 0. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebyrank) + +--- + +## zremrangebyrank(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------------- | +| `key` | string | Key identifier | +| `min` | int | Minimum position index (inclusive by default) | +| `max` | int | Maximum position index (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of removed members from the sorted set. + +## Usage + +<<< ./snippets/zremrangebyrank-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js b/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js new file mode 100644 index 000000000..5df66b95f --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zremrangebyrank('key', 1, 2, function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zremrangebyrankPromise('key', 1, 2) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js b/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/zremrangebyscore/index.md b/doc/5/core-classes/memory-storage/zremrangebyscore/index.md new file mode 100644 index 000000000..91a285e25 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebyscore/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: zremrangebyscore +description: MemoryStorage:zremrangebyscore +--- + +# zremrangebyscore + +Removes members from a sorted set with a score between `min` and `max` (inclusive by default). + +[[_Redis documentation_]](https://redis.io/commands/zremrangebyscore) + +--- + +## zremrangebyscore(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------ | +| `key` | string | Key identifier | +| `min` | double | Minimum score (inclusive by default) | +| `max` | double | Maximum score (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an integer containing the number of removed members from the sorted set. + +## Usage + +<<< ./snippets/zremrangebyscore-1.js + +> Callback response: + +```json +2 +``` diff --git a/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js b/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js new file mode 100644 index 000000000..0e895e264 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zremrangebyscore('key', 1, 2, function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zremrangebyscorePromise('key', 1, 2) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js b/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js new file mode 100644 index 000000000..056219890 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js @@ -0,0 +1,2 @@ +on +2 diff --git a/doc/5/core-classes/memory-storage/zrevrange/index.md b/doc/5/core-classes/memory-storage/zrevrange/index.md new file mode 100644 index 000000000..70babe86c --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrange/index.md @@ -0,0 +1,61 @@ +--- +code: false +type: page +title: zrevrange +description: MemoryStorage:zrevrange +--- + +# zrevrange + +Identical to [zrange](/sdk/js/5/core-classes/memory-storage/zrange), except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrange) + +--- + +## zrevrange(key, start, stop, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------- | +| `key` | string | Key identifier | +| `start` | int | Start position in the set (index starts at position `0`) | +| `stop` | int | End position in the set | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of objects, each containing the following properties: + +- `member`: member value in the sorted set +- `score`: member associated score + +## Usage + +<<< ./snippets/zrevrange-1.js + +> Callback response: + +```json +[ + { "member": "baz", "score": 3 }, + { "member": "bar", "score": 2 }, + { "member": "foo", "score": 1 } +] +``` diff --git a/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js b/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js new file mode 100644 index 000000000..ff66e90a5 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrevrange('key', 0, -1, function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrevrangePromise('key', 0, -1) + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js b/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js new file mode 100644 index 000000000..ed901f110 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js @@ -0,0 +1,6 @@ +on +[ + { "member": "baz", "score": 3 }, + { "member": "bar", "score": 2 }, + { "member": "foo", "score": 1 } +] diff --git a/doc/5/core-classes/memory-storage/zrevrangebylex/index.md b/doc/5/core-classes/memory-storage/zrevrangebylex/index.md new file mode 100644 index 000000000..2c6b5f3ec --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrangebylex/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: zrevrangebylex +description: MemoryStorage:zrevrangebylex +--- + +# zrevrangebylex + +Identical to [zrangebylex](/sdk/js/5/core-classes/memory-storage/zrangebylex) except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrangebylex) + +--- + +## zrevrangebylex(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------- | +| `key` | string | Key identifier | +| `min` | string | Minimum member value (inclusive by default) | +| `max` | string | Maximum member value (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of matching members. + +## Usage + +<<< ./snippets/zrevrangebylex-1.js + +> Callback response: + +```json +["member1", "member2", "..."] +``` diff --git a/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js b/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js new file mode 100644 index 000000000..d9cf3c70f --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrevrangebylex('key', '-', '(g', function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrevrangebylexPromise('key', '-', '(g') + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js b/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js new file mode 100644 index 000000000..395de0670 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js @@ -0,0 +1,6 @@ +on +[ + "member1", + "member2", + "..." +] diff --git a/doc/5/core-classes/memory-storage/zrevrangebyscore/index.md b/doc/5/core-classes/memory-storage/zrevrangebyscore/index.md new file mode 100644 index 000000000..c65f767c6 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrangebyscore/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: zrevrangebyscore +description: MemoryStorage:zrevrangebyscore +--- + +# zrevrangebyscore + +Identical to [zrangebyscore](/sdk/js/5/core-classes/memory-storage/zrangebyscore) except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrangebyscore) + +--- + +## zrevrangebyscore(key, min, max, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------ | +| `key` | string | Key identifier | +| `min` | double | Minimum score value (inclusive by default) | +| `max` | double | Maximum score value (inclusive by default) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return value + +Returns the `MemoryStorage` object to allow chaining. + +--- + +## Callback Response + +Returns an array of matching members. + +## Usage + +<<< ./snippets/zrevrangebyscore-1.js + +> Callback response: + +```json +[ + { "member": "baz", "score": 3 }, + { "member": "bar", "score": 2 }, + { "member": "foo", "score": 1 } +] +``` diff --git a/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js b/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js new file mode 100644 index 000000000..916424993 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrevrangebyscore('key', 2, 3, function (err, members) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrevrangebyscorePromise('key', 2, 3) + .then(members => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js b/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js new file mode 100644 index 000000000..ed901f110 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js @@ -0,0 +1,6 @@ +on +[ + { "member": "baz", "score": 3 }, + { "member": "bar", "score": 2 }, + { "member": "foo", "score": 1 } +] diff --git a/doc/5/core-classes/memory-storage/zrevrank/index.md b/doc/5/core-classes/memory-storage/zrevrank/index.md new file mode 100644 index 000000000..587e91946 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrank/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: zrevrank +description: MemoryStorage:zrevrank +--- + +# zrevrank + +Returns the position of an element in a sorted set, with scores in descending order. The index returned is 0-based (the lowest score member has an index of 0). + +[[_Redis documentation_]](https://redis.io/commands/zrevrank) + +--- + +## zrevrank(key, member, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------ | +| `key` | string | Key identifier | +| `member` | string | Member of the sorted set | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an integer containing the member's position in the sorted set. + +## Usage + +<<< ./snippets/zrevrank-1.js + +> Callback response: + +```json +0 +``` diff --git a/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js b/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js new file mode 100644 index 000000000..5bf19eff0 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zrevrank('key', 'foo', function (err, position) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zrevrankPromise('key', 'foo') + .then(position => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js b/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js new file mode 100644 index 000000000..41199acf8 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js @@ -0,0 +1,2 @@ +on +0 diff --git a/doc/5/core-classes/memory-storage/zscan/index.md b/doc/5/core-classes/memory-storage/zscan/index.md new file mode 100644 index 000000000..5155f1212 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zscan/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: zscan +description: MemoryStorage:zscan +--- + +# zscan + +Identical to [scan](/sdk/js/5/core-classes/memory-storage/scan), except that `zscan` iterates the members held by a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zscan) + +--- + +## zscan(key, cursor, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | +| `key` | string | Key identifier | +| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------- | ------- | +| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | +| `match` | string | Search only for member values matching the provided pattern | `*` | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a JSON array containing 2 entries: + +- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) +- an array of sorted set members and their associated scores + +## Usage + +<<< ./snippets/zscan-1.js + +> Callback response: + +```json +{ + "cursor": 18, + "values": ["member1", "member1's score", "member2", "member2's score", "..."] +} +``` diff --git a/doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js b/doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js new file mode 100644 index 000000000..b0c839d3b --- /dev/null +++ b/doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zscan('key', 0, function (err, page) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zscanPromise('key', 0) + .then(page => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js b/doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js new file mode 100644 index 000000000..740f694e0 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js @@ -0,0 +1,11 @@ +on +{ + "cursor": 18, + "values": [ + "member1", + "member1's score", + "member2", + "member2's score", + "..." + ] +} diff --git a/doc/5/core-classes/memory-storage/zscore/index.md b/doc/5/core-classes/memory-storage/zscore/index.md new file mode 100644 index 000000000..8f6e6e691 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zscore/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: zscore +description: MemoryStorage:zscore +--- + +# zscore + +Returns the score of a member in a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zscore) + +--- + +## zscore(key, member, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------- | +| `key` | string | Key identifier | +| `member` | string | Sorted set member | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a floating point number containing the searched member's score. + +## Usage + +<<< ./snippets/zscore-1.js + +> Callback response: + +```json +1 +``` diff --git a/doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js b/doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js new file mode 100644 index 000000000..d596b397b --- /dev/null +++ b/doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zscore('key', 'bar', function (err, score) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zscorePromise('key', 'bar') + .then(score => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js b/doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js new file mode 100644 index 000000000..b52a3a5b9 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js @@ -0,0 +1,2 @@ +on +1 diff --git a/doc/5/core-classes/memory-storage/zunionstore/index.md b/doc/5/core-classes/memory-storage/zunionstore/index.md new file mode 100644 index 000000000..f519990cc --- /dev/null +++ b/doc/5/core-classes/memory-storage/zunionstore/index.md @@ -0,0 +1,51 @@ +--- +code: false +type: page +title: zunionstore +description: MemoryStorage:zunionstore +--- + +# zunionstore + +Computes the union of the provided sorted sets and stores the result in the `destination` key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/zunionstore) + +--- + +## zunionstore(destination, keys, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | -------------------------------- | +| `destination` | string | Destination key identifier | +| `keys` | string | List of sorted sets to intersect | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------- | ------- | ----------------------------------------------------------------------------------------------------------- | ------- | +| `aggregate` | string | Specify how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | `sum` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `weights` | array | Specify a multiplication factor for each input sorted set | `[1]` | + +--- + +## Callback Response + +Returns an integer containing the number of members in the stored union. + +## Usage + +<<< ./snippets/zunionstore-1.js + +> Callback response: + +```json +4 +``` diff --git a/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js b/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js new file mode 100644 index 000000000..b330b9639 --- /dev/null +++ b/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle.memoryStorage.zunionstore('destination', ['key1', 'key2', '...'], function (err, count) { + // callback called once the action has completed +}); + +// Using promises (NodeJS only) +kuzzle.memoryStorage.zunionstorePromise('destination', ['key1', 'key2', '...']) + .then(count => { + // resolved once the action has completed + }); diff --git a/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js b/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js new file mode 100644 index 000000000..e3cd69f7e --- /dev/null +++ b/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js @@ -0,0 +1,2 @@ +on +4 diff --git a/doc/5/core-classes/profile/add-policy/index.md b/doc/5/core-classes/profile/add-policy/index.md new file mode 100644 index 000000000..9af94b2ed --- /dev/null +++ b/doc/5/core-classes/profile/add-policy/index.md @@ -0,0 +1,40 @@ +--- +code: false +type: page +title: addPolicy +description: Profile:addPolicy +--- + +# addPolicy + +Adds a role to the security profile. + +
+Updating a security profile will have no impact until the [save](/sdk/js/5/core-classes/profile/save) method is called +
+ +--- + +## addPolicy(id) + +| Arguments | Type | Description | +| --------- | ------ | -------------------------------------- | +| `id` | string | Unique id of the new role to associate | + +--- + +## addPolicy(policy) + +| Arguments | Type | Description | +| --------- | ----------- | ----------------------------------------------------------------------------- | +| `policy` | JSON Object | policy instance corresponding to the new associated role and its restrictions | + +--- + +## Return Value + +Returns the `Profile` object to allow chaining calls. + +## Usage + +<<< ./snippets/add-policy-1.js diff --git a/doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js b/doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js new file mode 100644 index 000000000..eae8ad5d3 --- /dev/null +++ b/doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js @@ -0,0 +1,4 @@ +profile.addPolicy({ + 'roleId': 'some role id', + 'restrictedTo': [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] +}); diff --git a/doc/5/core-classes/profile/constructor/index.md b/doc/5/core-classes/profile/constructor/index.md new file mode 100644 index 000000000..0d402491f --- /dev/null +++ b/doc/5/core-classes/profile/constructor/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: constructor +description: Profile:constructor +order: 1 +--- + +# Constructors + +Instantiates a new `Profile` object, representing a security [profile](/core/1/guides/essentials/security/#users-profiles-and-roles), which is a set of one or many [Role](/sdk/js/5/core-classes/role) objects. + +--- + +## Profile(Security, id, content, [meta]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------- | +| `Security` | Security | An instantiated [Security](/sdk/js/5/core-classes/security) object | +| `id` | string | Unique profile identifier | +| `content` | JSON Object | Profile content | +| `meta` | JSON Object | Profile metadata | + +**Note:** this constructor won't make any call to Kuzzle. + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ------------- | ----------- | ------------------------- | ------- | +| `content` | JSON object | Raw profile content | get | +| `id` | string | Unique profile identifier | get | +| `meta` | JSON object | Profile metadata | get | + +--- + +## Return Value + +Returns to the `Profile` object. + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/profile/constructor/snippets/constructor-1.js b/doc/5/core-classes/profile/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..0c02c9990 --- /dev/null +++ b/doc/5/core-classes/profile/constructor/snippets/constructor-1.js @@ -0,0 +1,12 @@ +/* + Constructors are not exposed in the JS/Node SDK. + Profile objects are returned by Security.profile method: + */ +var profileDefinition = { + policies: [ + {roleId: 'myrole'}, + {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } + ] +}; + +var profile = kuzzle.security.profile('myprofile', profileDefinition); diff --git a/doc/5/core-classes/profile/delete/index.md b/doc/5/core-classes/profile/delete/index.md new file mode 100644 index 000000000..7b49565b3 --- /dev/null +++ b/doc/5/core-classes/profile/delete/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: delete +description: Profile:delete +--- + +# delete + +Deletes this security profile from Kuzzle. + +--- + +## delete([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the ID of the deleted profile. + +## Usage + +<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/profile/delete/snippets/delete-1.js b/doc/5/core-classes/profile/delete/snippets/delete-1.js new file mode 100644 index 000000000..245b441bb --- /dev/null +++ b/doc/5/core-classes/profile/delete/snippets/delete-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +profile + .delete(function(error, result) { + // result is the id of deleted profile + }); + +// Using promises (NodeJS) +profile + .deletePromise() + .then((result) => { + // result is the id of deleted profile + }); diff --git a/doc/5/core-classes/profile/get-policies/index.md b/doc/5/core-classes/profile/get-policies/index.md new file mode 100644 index 000000000..1912f317b --- /dev/null +++ b/doc/5/core-classes/profile/get-policies/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: getPolicies +description: Profile:getPolicies +--- + +# getPolicies + +Returns roles associated to this security policy. + +--- + +## Return Value + +Returns an array of roles linked to this security policy. + +## Usage + +<<< ./snippets/get-policies-1.js + +> Callback response + +```json +[ + { + "roleId": "", + "restrictedTo": { + "index": "", + "collections": ["", "", "<...>"] + } + }, + { + "roleId": "" + }, + { + "roleId": "", + "restrictedTo": { + "index": "", + "collections": [""] + } + } +] +``` diff --git a/doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js b/doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js new file mode 100644 index 000000000..1886ed970 --- /dev/null +++ b/doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js @@ -0,0 +1,3 @@ +for (policy of profile.getPolicies()) { + // policy is a JSON object +} diff --git a/doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js b/doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js new file mode 100644 index 000000000..e49d1b500 --- /dev/null +++ b/doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js @@ -0,0 +1,20 @@ +on +[ + { + "roleId": "", + "restrictedTo": { + "index": "", + "collections": ["", "", "<...>"] + } + }, + { + "roleId": "" + }, + { + "roleId": "", + "restrictedTo": { + "index": "", + "collections": [""] + } + } +] diff --git a/doc/5/core-classes/profile/index.md b/doc/5/core-classes/profile/index.md new file mode 100644 index 000000000..124efa45f --- /dev/null +++ b/doc/5/core-classes/profile/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: Profile +description: Profile documentation +--- diff --git a/doc/5/core-classes/profile/save/index.md b/doc/5/core-classes/profile/save/index.md new file mode 100644 index 000000000..ee5bfc099 --- /dev/null +++ b/doc/5/core-classes/profile/save/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: save +description: Profile:save +--- + +# save + +Creates or replaces the profile in Kuzzle. + +
+Saving the object will return an error if the linked roles have not been previously created in Kuzzle. +
+ +--- + +## save([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Profile` object to allow chaining. + +--- + +## Callback Response + +Returns a `Profile` object. + +## Usage + +<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/profile/save/snippets/save-1.js b/doc/5/core-classes/profile/save/snippets/save-1.js new file mode 100644 index 000000000..08fa095d0 --- /dev/null +++ b/doc/5/core-classes/profile/save/snippets/save-1.js @@ -0,0 +1,21 @@ +var profileDefinition = { + policies: [ + {roleId: 'myrole'}, + {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } + ] +}; + +var profile = kuzzle.security.profile('myprofile', profileDefinition); + +// Using callbacks (NodeJS or Web Browser) +profile + .save(function(error, result) { + // result is a Profile object + }); + +// Using promises (NodeJS) +profile + .savePromise() + .then(result => { + // result is a Profile object + }); diff --git a/doc/5/core-classes/profile/set-content/index.md b/doc/5/core-classes/profile/set-content/index.md new file mode 100644 index 000000000..6caa5bbed --- /dev/null +++ b/doc/5/core-classes/profile/set-content/index.md @@ -0,0 +1,32 @@ +--- +code: false +type: page +title: setContent +description: Profile:setContent +--- + +# setContent + +Replaces the content of the `Profile` object. + +
+Updating a profile will have no impact until the save method is called +
+ +--- + +## setContent(data) + +| Arguments | Type | Description | +| --------- | ----------- | --------------- | +| `data` | JSON Object | Profile content | + +--- + +## Return Value + +Returns the `Profile` object. + +## Usage + +<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/profile/set-content/snippets/set-content-1.js b/doc/5/core-classes/profile/set-content/snippets/set-content-1.js new file mode 100644 index 000000000..8fdc7e81c --- /dev/null +++ b/doc/5/core-classes/profile/set-content/snippets/set-content-1.js @@ -0,0 +1,9 @@ +var profile = kuzzle.security.fetchProfile('myprofile'); +var profileDefinition = { + policies: [ + {roleId: 'myrole'}, + {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } + ] +}; + +profile = profile.setContent(profileDefinition); diff --git a/doc/5/core-classes/profile/set-policies/index.md b/doc/5/core-classes/profile/set-policies/index.md new file mode 100644 index 000000000..c649e9db5 --- /dev/null +++ b/doc/5/core-classes/profile/set-policies/index.md @@ -0,0 +1,40 @@ +--- +code: false +type: page +title: setPolicies +description: Profile:setPolicies +--- + +# setPolicies + +Replaces the roles associated with this security profile. + +--- + +## `setPolicies(Array policyIDs)` + +| Arguments | Type | Description | +| ----------- | ---------------- | ----------------- | +| `policyIDs` | array of strings | Policy IDs to add | + +--- + +## `setPolicies(Array policyDefinitions)` + +| Arguments | Type | Description | +| ------------------- | --------------------- | ------------------------- | +| `policyDefinitions` | array of JSON objects | Policy definitions to add | + +--- + +## Return Value + +Returns the `Profile` object. + +
+Updating a profile will have no impact until the save method is called +
+ +## Usage + +<<< ./snippets/set-policies-1.js diff --git a/doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js b/doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js new file mode 100644 index 000000000..c96155ce9 --- /dev/null +++ b/doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js @@ -0,0 +1,4 @@ +policy = { "roleId": "roleId" }; + +// Replaces the profile policies set with the given entry. +profile.setPolicies([policy]); diff --git a/doc/5/core-classes/profile/update/index.md b/doc/5/core-classes/profile/update/index.md new file mode 100644 index 000000000..79b8ebb53 --- /dev/null +++ b/doc/5/core-classes/profile/update/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: update +description: Profile:update +--- + +# update + +Performs a partial content update on this object. + +--- + +## update(content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------- | +| `content` | JSON Object | Profile content | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Profile` object to allow chaining. + +--- + +## Callback Response + +Returns the updated version of this object. + +## Usage + +<<< ./snippets/update-1.js diff --git a/doc/5/core-classes/profile/update/snippets/update-1.js b/doc/5/core-classes/profile/update/snippets/update-1.js new file mode 100644 index 000000000..07efac4ef --- /dev/null +++ b/doc/5/core-classes/profile/update/snippets/update-1.js @@ -0,0 +1,17 @@ +var updateContent = { + policies: [ + {roleId: 'myrole'}, + ] +}; + +// Using callbacks (NodeJS or Web Browser) +profile.update(updateContent, function(err, updatedProfile) { + // the updatedProfile variable is the updated Profile object +}) + +// Using promises (NodeJS) +profile + .updatePromise(updateContent) + .then(updatedProfile => { + // the updatedProfile variable is the updated Profile object + }); diff --git a/doc/5/core-classes/role/constructor/index.md b/doc/5/core-classes/role/constructor/index.md new file mode 100644 index 000000000..4a9122931 --- /dev/null +++ b/doc/5/core-classes/role/constructor/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: constructor +description: Role:constructor +order: 1 +--- + +# Constructors + +Instantiates a new `Role` object, which defines a set of right policies. + +--- + +## Role(Security, id, content, [meta]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------- | +| `Security` | Security | An instantiated [Security](/sdk/js/5/core-classes/security) object | +| `id` | string | Unique role identifier | +| `content` | JSON Object | Role content | +| `meta` | JSON Object | Role metadata | + +**Note:** this constructor won't make any call to Kuzzle. + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ------------- | ----------- | ------------------------- | ------- | +| `content` | JSON object | Raw role content | get | +| `id` | string | Unique profile identifier | get | +| `meta` | JSON object | Role metadata | get | + +--- + +## Return Value + +Returns the `Role` object. + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/role/constructor/snippets/constructor-1.js b/doc/5/core-classes/role/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..07863226c --- /dev/null +++ b/doc/5/core-classes/role/constructor/snippets/constructor-1.js @@ -0,0 +1,15 @@ +/* + Constructors are not exposed in the JS/Node SDK. + Role objects are returned by Security.role method: + */ +var roleDefinition = { + controllers: { + "*": { + actions: { + "*": true + } + } + } +}; + +var role = kuzzle.security.role('myrole', roleDefinition); diff --git a/doc/5/core-classes/role/delete/index.md b/doc/5/core-classes/role/delete/index.md new file mode 100644 index 000000000..69703689c --- /dev/null +++ b/doc/5/core-classes/role/delete/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: delete +description: Role:delete +--- + +# delete + +Deletes the role from Kuzzle. + +--- + +## delete([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the ID of the deleted role. + +## Usage + +<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/role/delete/snippets/delete-1.js b/doc/5/core-classes/role/delete/snippets/delete-1.js new file mode 100644 index 000000000..b0f4e2bb1 --- /dev/null +++ b/doc/5/core-classes/role/delete/snippets/delete-1.js @@ -0,0 +1,10 @@ +// Using callbacks (NodeJS or Web Browser) +role.delete(function(error, deletedId) { + // ... +}); + +// Using promises (NodeJS) +role.deletePromise() + .then(deletedId => { + // ... + }); diff --git a/doc/5/core-classes/role/index.md b/doc/5/core-classes/role/index.md new file mode 100644 index 000000000..72aa06500 --- /dev/null +++ b/doc/5/core-classes/role/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: Role +description: Role documentation +--- diff --git a/doc/5/core-classes/role/save/index.md b/doc/5/core-classes/role/save/index.md new file mode 100644 index 000000000..8acf77aa5 --- /dev/null +++ b/doc/5/core-classes/role/save/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: save +description: Role:save +--- + +# save + +Creates or replaces the role in Kuzzle's database layer. + +--- + +## save([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Role` object to allow chaining. + +--- + +## Callback Response + +Returns a `Role` object. + +## Usage + +<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/role/save/snippets/save-1.js b/doc/5/core-classes/role/save/snippets/save-1.js new file mode 100644 index 000000000..0a8dded98 --- /dev/null +++ b/doc/5/core-classes/role/save/snippets/save-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +role + .save(function(error, result) { + // result is a Role object + }); + +// Using promises (NodeJS) +role + .savePromise() + .then((result) => { + // result is a Role object + }); diff --git a/doc/5/core-classes/role/set-content/index.md b/doc/5/core-classes/role/set-content/index.md new file mode 100644 index 000000000..44d05dd69 --- /dev/null +++ b/doc/5/core-classes/role/set-content/index.md @@ -0,0 +1,32 @@ +--- +code: false +type: page +title: setContent +description: Role:setContent +--- + +# setContent + +Replaces the content of the `Role` object. + +
+Updating a role content will have no impact until the [save](/sdk/js/5/core-classes/role/save) method is called +
+ +--- + +## setContent(data) + +| Arguments | Type | Description | +| --------- | ----------- | ------------ | +| `data` | JSON Object | Role content | + +--- + +## Return Value + +Returns the `Role` object. + +## Usage + +<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/role/set-content/snippets/set-content-1.js b/doc/5/core-classes/role/set-content/snippets/set-content-1.js new file mode 100644 index 000000000..349d4c954 --- /dev/null +++ b/doc/5/core-classes/role/set-content/snippets/set-content-1.js @@ -0,0 +1,11 @@ +var roleDefinition = { + controllers: { + "*": { + actions: { + "*": true + } + } + } +}; + +role = role.setContent(roleDefinition); diff --git a/doc/5/core-classes/role/update/index.md b/doc/5/core-classes/role/update/index.md new file mode 100644 index 000000000..f7f422ff0 --- /dev/null +++ b/doc/5/core-classes/role/update/index.md @@ -0,0 +1,56 @@ +--- +code: false +type: page +title: update +description: Role:update +--- + +# update + +Updates the role object in Kuzzle. + +
+

+ Unlike a regular document update, this method will replace the whole role definition under the indexes node with the updateContent parameter.
+ In other words, you always need to provide the complete role definition in the updateContent object. +

+

+ This method has the same effect as calling [`setContent`](/sdk/js/5/core-classes/role/set-content) followed by the [`save`](/sdk/js/5/core-classes/role/save) method. +

+
+ +To get more information about Kuzzle permissions, please refer to our [permissions guide](/core/1/guides/essentials/security/#user-permissions). + +--- + +## update(content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------- | +| `content` | JSON Object | New role content | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `Role` object to allow chaining. + +--- + +## Callback Response + +Returns the updated version of this object. + +## Usage + +<<< ./snippets/update-1.js diff --git a/doc/5/core-classes/role/update/snippets/update-1.js b/doc/5/core-classes/role/update/snippets/update-1.js new file mode 100644 index 000000000..e166c0a6a --- /dev/null +++ b/doc/5/core-classes/role/update/snippets/update-1.js @@ -0,0 +1,21 @@ +var updateContent = { + controllers: { + "document": { + actions: { + "get": true + } + } + } +}; + +// Using callbacks (NodeJS or Web Browser) +role.update(updateContent, function(err, updatedRole) { + // the updatedRole variable is the updated Role object +}) + +// Using promises (NodeJS) +role + .updatePromise(updateContent) + .then(updatedRole => { + // the updatedRole variable is the updated Role object + }); diff --git a/doc/5/core-classes/room/constructor/index.md b/doc/5/core-classes/room/constructor/index.md new file mode 100644 index 000000000..d8d783a57 --- /dev/null +++ b/doc/5/core-classes/room/constructor/index.md @@ -0,0 +1,55 @@ +--- +code: false +type: page +title: constructor +description: Room:constructor +order: 1 +--- + +# Constructors + +The `Room` object is the result of a subscription request, allowing you to manipulate the subscription itself. + +--- + +## Room(Collection, [options]) + +| Arguments | Type | Description | +| ------------ | ------ | ---------------------------------------- | +| `Collection` | object | an instantiated Kuzzle Collection object | +| `options` | object | Optional subscription configuration | + +--- + +## Options + +| Option | Type | Description | Default | +| ----------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | +| `scope` | string | Filter [document notifications](/sdk/js/5/essentials/realtime-notifications/#document-notification) depending on their scope status. You may receive entering documents (scope: `in`), leaving documents (scope: `out`), all documents changes (scope: `all`) or filter these notifications completely (scope: `none`). This filter does not affect pub/sub messages or user events. | `all` | +| `state` | string | Filter [document notifications](/sdk/js/5/essentials/realtime-notifications/#document-notification) depending on the state of the modifying request. You may receive real-time notifications when a document is about to be changed (state: `pending`), or be notified when the change has been fully written in the database (state: `done`), or both (state: `all`). This filter does not affect pub/sub messages or user events. | `done` | +| `subscribeToSelf` | boolean | (Don't) subscribe to notifications fired as a consequence of our own queries | `true` | +| `users` | string | Filter [user notifications](/sdk/js/5/essentials/realtime-notifications/#user-notification) triggered upon a user entering the room (user: `in`), leaving the room (user: `out`), or both (user: `all`). Setting this variable to `none` prevents receiving these notifications | `none` | + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ----------------- | ----------- | ---------------------------------------------------------------------------- | ------- | +| `collection` | string | The subscribed collection | get | +| `filters` | JSON object | The current set of filters of this room | get/set | +| `headers` | JSON Object | Common headers for all sent documents. | get/set | +| `volatile` | JSON Object | Additional information passed to notifications to other users | get/set | +| `subscribeToSelf` | boolean | (Don't) subscribe to notifications fired as a consequence of our own queries | get/set | +| `roomId` | string | Unique room identifier | get | + +**Notes:** + +- the `headers` property is inherited from the provided `Collection` object and can be overridden +- updating the `volatile` property takes effect only after the subscription is renewed +- by default, the global `volatile` properties are sent along with the subscription request. If a `volatile` option is provided during subscription, it will be merged with the global `volatile` for the subscription only. In case of conflicts, subscription `volatile` data takes priority over the global `volatile` ones. + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/room/constructor/snippets/constructor-1.js b/doc/5/core-classes/room/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..54f4b6c10 --- /dev/null +++ b/doc/5/core-classes/room/constructor/snippets/constructor-1.js @@ -0,0 +1,12 @@ +/* + Constructors are not exposed in the JS/Node SDK. + Room objects are returned by Collection.subscribe and + Document.subscribe methods. + + You may also use the Collection.room() method: + */ +var room = kuzzle.collection('collection', 'index').room(); + +room = kuzzle + .collection('collection', 'index') + .room({subscribeToSelf: false}); diff --git a/doc/5/core-classes/room/count/index.md b/doc/5/core-classes/room/count/index.md new file mode 100644 index 000000000..f1c4bf8c2 --- /dev/null +++ b/doc/5/core-classes/room/count/index.md @@ -0,0 +1,34 @@ +--- +code: false +type: page +title: count +description: Room:count +--- + +# count + +Returns the number of subscribers in the room. + +--- + +## count(callback) + +| Arguments | Type | Description | +| ---------- | -------- | ------------------------------ | +| `callback` | function | Callback handling the response | + +--- + +## Callback Response + +Returns an `integer` containing the number of users subscribing to this room. + +## Usage + +<<< ./snippets/count-1.js + +> Callback response + +```json +1 +``` diff --git a/doc/5/core-classes/room/count/snippets/count-1.js b/doc/5/core-classes/room/count/snippets/count-1.js new file mode 100644 index 000000000..ceef59935 --- /dev/null +++ b/doc/5/core-classes/room/count/snippets/count-1.js @@ -0,0 +1,9 @@ +// Using callbacks (NodeJS or Web Browser) +room.count(function (error, result) { + // ... +}); + +// Using promises (NodeJS) +room.countPromise().then(result => { + // ... +}); diff --git a/doc/5/core-classes/room/count/snippets/count-2.js b/doc/5/core-classes/room/count/snippets/count-2.js new file mode 100644 index 000000000..b52a3a5b9 --- /dev/null +++ b/doc/5/core-classes/room/count/snippets/count-2.js @@ -0,0 +1,2 @@ +on +1 diff --git a/doc/5/core-classes/room/index.md b/doc/5/core-classes/room/index.md new file mode 100644 index 000000000..c450019a9 --- /dev/null +++ b/doc/5/core-classes/room/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: Room +description: Room documentation +--- diff --git a/doc/5/core-classes/room/renew/index.md b/doc/5/core-classes/room/renew/index.md new file mode 100644 index 000000000..ed9752c51 --- /dev/null +++ b/doc/5/core-classes/room/renew/index.md @@ -0,0 +1,26 @@ +--- +code: false +type: page +title: renew +description: Room:renew +--- + +# renew + +Renew the subscription. Force a new subscription using the same filters if no new ones are provided. + +Unsubscribes first if this `Room` object was already listening to events. + +--- + +## renew([filters], notificationCallback, subscriptionCallback) + +| Arguments | Type | Description | +| ---------------------- | ----------- | ------------------------------------------------------------------------------- | +| `filters` | JSON Object | [Filters](/core/1/koncorde) | +| `notificationCallback` | function | Function called each time a [notification](/sdk/js/5/essentials/realtime-notifications) is received | +| `subscriptionCallback` | function | Function called with the subscription result | + +## Usage + +<<< ./snippets/renew-1.js diff --git a/doc/5/core-classes/room/renew/snippets/renew-1.js b/doc/5/core-classes/room/renew/snippets/renew-1.js new file mode 100644 index 000000000..739d0f7f2 --- /dev/null +++ b/doc/5/core-classes/room/renew/snippets/renew-1.js @@ -0,0 +1,8 @@ +room.renew({in: {field: ['some', 'new', 'filter']}}, function (err, res) { + // called each time a change is detected on documents matching this filter + + // check the Room/Notifications section of this documentation + // to get notification examples +}, function (err, res) { + // handles the subscription result +}); diff --git a/doc/5/core-classes/room/set-headers/index.md b/doc/5/core-classes/room/set-headers/index.md new file mode 100644 index 000000000..d3a7e1577 --- /dev/null +++ b/doc/5/core-classes/room/set-headers/index.md @@ -0,0 +1,33 @@ +--- +code: false +type: page +title: setHeaders +description: Room:setHeaders +--- + +# setHeaders + +> Returns itself + +This is a helper function returning itself, allowing to easily chain calls. + +--- + +## setHeaders(content, [replace]) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------------------------------------------------------- | +| `content` | JSON Object | New content | +| `replace` | boolean | true: replace the current content with the provided data, false: merge it | + +**Note:** by default, the `replace` argument is set to `false` + +--- + +## Return value + +Returns this `Room` object to allow chaining. + +## Usage + +<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/room/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/room/set-headers/snippets/set-headers-1.js new file mode 100644 index 000000000..967926079 --- /dev/null +++ b/doc/5/core-classes/room/set-headers/snippets/set-headers-1.js @@ -0,0 +1 @@ +room.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/room/unsubscribe/index.md b/doc/5/core-classes/room/unsubscribe/index.md new file mode 100644 index 000000000..9babd9141 --- /dev/null +++ b/doc/5/core-classes/room/unsubscribe/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: unsubscribe +description: Room:unsubscribe +--- + +# unsubscribe + +Cancels the current subscription. + +--- + +## Return value + +Returns this `Room` object to allow chaining. + +## Usage + +<<< ./snippets/unsubscribe-1.js diff --git a/doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js b/doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js new file mode 100644 index 000000000..94f6dddfe --- /dev/null +++ b/doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js @@ -0,0 +1 @@ +room.unsubscribe(); diff --git a/doc/5/core-classes/search-result/constructor/index.md b/doc/5/core-classes/search-result/constructor/index.md new file mode 100644 index 000000000..e62662d70 --- /dev/null +++ b/doc/5/core-classes/search-result/constructor/index.md @@ -0,0 +1,27 @@ +--- +code: false +type: page +title: constructor +description: SearchResult:constructor +order: 1 +--- + +# Constructor + +This object can only be instantiated internally by this SDK, and is an easy-to-use representation of a paginated result from a [search](/sdk/js/5/core-classes/collection/search) or a [scroll](/sdk/js/5/core-classes/collection/scroll) request. + +--- + +## Properties + +| Property name | Type | Description | get/set | +| -------------- | ---------- | --------------------------------------------------------- | ------- | +| `aggregations` | object | The result of an aggregation produced by a search request | get | +| `collection` | Collection | The collection associated to this document | get | +| `documents` | Document[] | An array of instantiated Document objects | get | +| `fetched` | number | The number of fetched documents so far | get/set | +| `options` | object | The arguments of the search/scroll request | get | +| `filters` | object | The filters of the search request | get | +| `total` | integer | The total number of results that can be fetched | get | + +--- diff --git a/doc/5/core-classes/search-result/fetch-next/index.md b/doc/5/core-classes/search-result/fetch-next/index.md new file mode 100644 index 000000000..9af55f41c --- /dev/null +++ b/doc/5/core-classes/search-result/fetch-next/index.md @@ -0,0 +1,36 @@ +--- +code: false +type: page +title: fetchNext +description: SearchResult:fetchNext +--- + +# fetchNext + +Fetches the next SearchResult, by triggering a new search/scroll request depending on the options and filters of the SearchResult. + +If the previous request was a search or a scroll action which provided a `scroll` argument, +`fetchNext` will use the `scrollId` retrieved from the current result to make a new scroll request. + +If the previous request was a search action which provided `size` argument and `sort` filtering, +`fetchNext` will use Elasticsearch's [`search_after`](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-search-after.html) mechanism, which can efficiently search through a large volume of documents, bypassing internal hard limits\[1\], +but at the cost of reflecting the latest changes of the index, as opposed to using scroll. + +If the previous request was a search action which provided `from` and `size` arguments, +`fetchNext` will add `size` to `from` and make a new search request. + +--- + +## How to process every document of a collection + +The safest way to process all documents in a collection is to fetch them as a batch in order to avoid memory exhaustion and possibly hitting some hard limits\[1\] on the database layer. + +
Make sure your first search request includes size and scroll parameters
+ +
\[1\] Elasticsearch limits the number of documents inside a single page to [10,000 by default](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/index-modules.html#dynamic-index-settings).
+ +## Usage + +<<< ./snippets/fetch-next-1.js + +<<< ./snippets/fetch-next-2.js diff --git a/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js b/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js new file mode 100644 index 000000000..d7a6fcf01 --- /dev/null +++ b/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +searchResult.fetchNext(function (error, nextSearchResult) { + // called once the fetchNext action has been completed + // nextSearchResult is an instantiated SearchResult object +}); + +// Using promises (NodeJS) +searchResult.fetchNextPromise() + .then(nextSearchResult => { + // called once the fetchNext action has been completed + // nextSearchResult is an instantiated SearchResult object + }); diff --git a/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js b/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js new file mode 100644 index 000000000..4efe620de --- /dev/null +++ b/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js @@ -0,0 +1,22 @@ +var processDocument = function (document) { + // do something with the document +}; + +kuzzle + .collection('collection', 'index') + .search({ + from: 0, + size: 1000, + scroll: '30s', + query: {} + }, function getMoreUntilDone (error, searchResult) { + if (searchResult === null) { + return; + } + + searchResult.documents.forEach(function (document) { + processDocument(document); + }); + + searchResult.fetchNext(getMoreUntilDone); + }); diff --git a/doc/5/core-classes/search-result/index.md b/doc/5/core-classes/search-result/index.md new file mode 100644 index 000000000..11ca3f724 --- /dev/null +++ b/doc/5/core-classes/search-result/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: SearchResult +description: SearchResult documentation +--- diff --git a/doc/5/core-classes/security/constructor/index.md b/doc/5/core-classes/security/constructor/index.md new file mode 100644 index 000000000..e455d5e6d --- /dev/null +++ b/doc/5/core-classes/security/constructor/index.md @@ -0,0 +1,25 @@ +--- +code: false +type: page +title: constructor +description: Security:constructor +order: 1 +--- + +# Constructor + +The Security component lets you handle user permissions in Kuzzle. + +Please refer to our [permissions guide](/core/1/guides/essentials/security/#user-permissions) for more information. + +--- + +## Security + +| Arguments | Type | Description | +| --------- | ------ | ------------------------------------------------- | +| `Kuzzle` | object | An instantiated [Kuzzle](/sdk/js/5/core-classes/kuzzle) object | + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/security/constructor/snippets/constructor-1.js b/doc/5/core-classes/security/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..31cbcbdff --- /dev/null +++ b/doc/5/core-classes/security/constructor/snippets/constructor-1.js @@ -0,0 +1,5 @@ +/* + Constructor is not exposed in the JS/Node SDK. You may get the instantiated + Security object by calling Kuzzle.security + */ +var kuzzleSecurity = kuzzle.security; diff --git a/doc/5/core-classes/security/create-credentials/index.md b/doc/5/core-classes/security/create-credentials/index.md new file mode 100644 index 000000000..5530985c2 --- /dev/null +++ b/doc/5/core-classes/security/create-credentials/index.md @@ -0,0 +1,49 @@ +--- +code: false +type: page +title: createCredentials +description: Security:createCredentials +--- + +# createCredentials + +Create credentials of user with `kuid` for the specified `strategy`. + +--- + +## createCredentials(strategy, kuid, credentials, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `strategy` | string | Strategy you want to create credentials in | +| `kuid` | string | User's kuid | +| `credentials` | JSON object | The credentials | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the created credentials. + +## Usage + +<<< ./snippets/create-credentials-1.js + +> Callback response + +```json +{ + "username": "foo", + "kuid": "" +} +``` diff --git a/doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js b/doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js new file mode 100644 index 000000000..147500fed --- /dev/null +++ b/doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.createCredentials('local', 'kuid', {'username': 'foo'}, function (error, credentials) { + +}); + +// Using promises (node.js) +kuzzle + .security + .createCredentialsPromise('local', 'kuid', {'username': 'foo'}) + .then(credentials => { + + }); diff --git a/doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js b/doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js new file mode 100644 index 000000000..04d9e0fd4 --- /dev/null +++ b/doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js @@ -0,0 +1,5 @@ +on +{ + "username": "foo", + "kuid": "" +} diff --git a/doc/5/core-classes/security/create-profile/index.md b/doc/5/core-classes/security/create-profile/index.md new file mode 100644 index 000000000..633db2ed5 --- /dev/null +++ b/doc/5/core-classes/security/create-profile/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: createProfile +description: Security:createProfile +--- + +# createProfile + +Create a new profile in Kuzzle. + +
+There is a small delay between profile creation and its availability in our search layer (usually a couple of seconds). +That means that a profile that was just created might not be returned by the searchProfiles function at first. +
+ +--- + +## createProfile(id, content, [options], callback) + +| Arguments | Type | Description | +| ---------- | --------------------- | ----------------------------------------- | +| `id` | string | Unique profile identifier | +| `policies` | array of JSON objects | List of policies to apply to this profile | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `replaceIfExist` | boolean | If the same profile already exists: throw an error if sets to false. Replace the existing profile otherwise | `false` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Callback Response + +Returns a security [Profile](/sdk/js/5/core-classes/profile) object. + +## Usage + +<<< ./snippets/create-profile-1.js diff --git a/doc/5/core-classes/security/create-profile/snippets/create-profile-1.js b/doc/5/core-classes/security/create-profile/snippets/create-profile-1.js new file mode 100644 index 000000000..1bdd99904 --- /dev/null +++ b/doc/5/core-classes/security/create-profile/snippets/create-profile-1.js @@ -0,0 +1,30 @@ +var policies = [ + {roleId: 'myrole'}, + { + roleId: 'default', + restrictedTo: [ + {index: 'index1'}, + {index: 'index2', collections: ['foo', 'bar'] } + ] + } +]; + +// You can chose to replace the given profile if already exists +var options = { + replaceIfExist: true +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .createProfile('myprofile', policies, options, function(error, profile) { + + }); + +// Using promises (NodeJS) +kuzzle + .security + .createProfilePromise('myprofile', policies, options) + .then(profile => { + + }); diff --git a/doc/5/core-classes/security/create-restricted-user/index.md b/doc/5/core-classes/security/create-restricted-user/index.md new file mode 100644 index 000000000..236e6f60e --- /dev/null +++ b/doc/5/core-classes/security/create-restricted-user/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: createRestrictedUser +description: Security:createRestrictedUser +--- + +# createRestrictedUser + +Create a new restricted user in Kuzzle. +This function allows anonymous users to create a "restricted" user with predefined rights. + +
+There is a small delay between user creation and its availability in our search layer (usually a couple of seconds). +That means that a user that was just created may not be returned by the searchUsers function at first. +
+ +--- + +## createRestrictedUser(id, content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------ | +| `id` | string | Unique user identifier, will be used as username | +| `content` | JSON Object | A plain JSON object representing the user | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Callback response + +Resolves to a [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/create-restricted-user-1.js diff --git a/doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js b/doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js new file mode 100644 index 000000000..dff21b95c --- /dev/null +++ b/doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js @@ -0,0 +1,27 @@ +var userContent = { + content: { + }, + credentials: { + local: { + // The "local" authentication strategy requires a password + password: 'secretPassword', + lastLoggedIn: 1494411803 + } + } +}; + + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .createRestrictedUser('myuser', userContent, options, function(error, response) { + // result is a User object + }); + +// Using promises (NodeJS) +kuzzle + .security + .createRestrictedUserPromise('myuser', userContent, options) + .then((response) => { + // result is a User object + }); diff --git a/doc/5/core-classes/security/create-role/index.md b/doc/5/core-classes/security/create-role/index.md new file mode 100644 index 000000000..676962a94 --- /dev/null +++ b/doc/5/core-classes/security/create-role/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: createRole +description: Security:createRole +--- + +# createRole + +Create a new role in Kuzzle. + +
+There is a small delay between role creation and its availability in our search layer (usually a couple of seconds). +That means that a role that was just created may not be returned by the searchRole function at first. +
+--- + +## createRole(id, content, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `id` | string | Unique role identifier | +| `content` | JSON Object | A plain JSON object representing the role | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `replaceIfExist` | boolean | If the same role already exists: throw an error if sets to false. Replace the existing role otherwise | `false` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Callback Response + +Returns a [Role](/sdk/js/5/core-classes/role) object. + +## Usage + +<<< ./snippets/create-role-1.js diff --git a/doc/5/core-classes/security/create-role/snippets/create-role-1.js b/doc/5/core-classes/security/create-role/snippets/create-role-1.js new file mode 100644 index 000000000..10a3e13f8 --- /dev/null +++ b/doc/5/core-classes/security/create-role/snippets/create-role-1.js @@ -0,0 +1,29 @@ +var roleDefinition = { + controllers: { + "*": { + actions: { + "*": true + } + } + } +}; + +// You can chose to replace the given role if already exists +var options = { + replaceIfExist: true +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .createRole('myrole', roleDefinition, options, function(error, response) { + // result is a Role object + }); + +// Using promises (NodeJS) +kuzzle + .security + .createRolePromise('myrole', roleDefinition, options) + .then((response) => { + // result is a Role object + }); diff --git a/doc/5/core-classes/security/create-user/index.md b/doc/5/core-classes/security/create-user/index.md new file mode 100644 index 000000000..afdbb46e8 --- /dev/null +++ b/doc/5/core-classes/security/create-user/index.md @@ -0,0 +1,54 @@ +--- +code: false +type: page +title: createUser +description: Security:createUser +--- + +# createUser + +Create a new user in Kuzzle. + +
+There is a small delay between user creation and its availability in our search layer (usually a couple of seconds). +That means that a user that was just created may not be returned by the searchUsers function at first. +
+ +--- + +## createUser(id, user, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | +| `id` | string | [Unique user identifier](/core/1/guides/essentials/user-authentication/#kuzzle-user-identifier-kuid) | +| `user` | JSON Object | A plain JSON object representing the user (see below) | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | Callback handling the response | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +The `user` object to provide must have the following properties: + +- `content` (JSON object): user global properties + - This object must contain a `profileIds` properties, an array of strings listing the security [profiles](/core/1/guides/essentials/security/#users-profiles-and-roles) to be attached to the new user + - Any other property will be copied as additional global user information +- `credentials` (JSON object): a description of how the new user can identify themselves on Kuzzle + - Any number of credentials can be added, each one being an object with name equal to the [authentication strategy](/core/1/plugins/guides/strategies/#exposing-authentication-strategies) used to authenticate the user, and with the login data as content. + - If this object is left empty, the user will be created in Kuzzle but the will not be able to login. + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/create-user-1.js diff --git a/doc/5/core-classes/security/create-user/snippets/create-user-1.js b/doc/5/core-classes/security/create-user/snippets/create-user-1.js new file mode 100644 index 000000000..47f5460f4 --- /dev/null +++ b/doc/5/core-classes/security/create-user/snippets/create-user-1.js @@ -0,0 +1,37 @@ +var user = { + content: { + // A "profileIds" field is required to bind a user to existing profiles + profileIds: ['admin'], + + // Additional information may be provided + firstname: 'John', + lastname: 'Doe' + }, + credentials: { + // Authentication strategy to use + "local": { + // The necessary information to provide vary, + // depending on the chosen authentication strategy + "username": "jdoe", + "password": "secret password" + } + } +}; + +var options = {}; + + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .createUser('myuser', user, options, function(error, response) { + // result is a User object + }); + +// Using promises (NodeJS) +kuzzle + .security + .createUserPromise('myuser', user, options) + .then(response => { + // result is a User object + }); diff --git a/doc/5/core-classes/security/delete-credentials/index.md b/doc/5/core-classes/security/delete-credentials/index.md new file mode 100644 index 000000000..fb309cd5f --- /dev/null +++ b/doc/5/core-classes/security/delete-credentials/index.md @@ -0,0 +1,47 @@ +--- +code: false +type: page +title: deleteCredentials +description: Security:deleteCredentials +--- + +# deleteCredentials + +Delete current user's credentials for the specified `strategy`. + +--- + +## deleteCredentials(strategy, kuid, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | -------------------------------------------- | +| `strategy` | string | Strategy you want to delete credentials from | +| `kuid` | string | User's kuid | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object reflecting the query status. + +## Usage + +<<< ./snippets/delete-credentials-1.js + +> Callback response + +```json +{ + "acknowledged": true +} +``` diff --git a/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js b/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js new file mode 100644 index 000000000..a7a334331 --- /dev/null +++ b/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.deleteCredentials('local', 'kuid', function (error, result) { + +}); + +// Using promises (node.js) +kuzzle + .security + .deleteCredentialsPromise('local', 'kuid') + .then(result => { + + }); diff --git a/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js b/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js new file mode 100644 index 000000000..02d519956 --- /dev/null +++ b/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js @@ -0,0 +1,4 @@ +on +{ + "acknowledged": true +} diff --git a/doc/5/core-classes/security/delete-profile/index.md b/doc/5/core-classes/security/delete-profile/index.md new file mode 100644 index 000000000..3dd29542c --- /dev/null +++ b/doc/5/core-classes/security/delete-profile/index.md @@ -0,0 +1,56 @@ +--- +code: false +type: page +title: deleteProfile +description: Security:deleteProfile +--- + +# deleteProfile + +Delete the provided profile. + +
+There is a small delay between the time a profile is deleted and it being reflected in the search layer (usually a couple of seconds). +That means that a profile that was just deleted may still be returned by the searchProfiles function at first. +
+ +--- + +## deleteProfile(id, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `id` | string | Unique profile identifier to delete | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Returns the ID of the security profile that has been deleted. + +## Usage + +<<< ./snippets/delete-profile-1.js + +> Callback response + +```json +"deleted profile identifier" +``` diff --git a/doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js b/doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js new file mode 100644 index 000000000..6f2131096 --- /dev/null +++ b/doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .deleteProfile('myprofile', function(error, result) { + + }); + +// Using promises (NodeJS) +kuzzle + .security + .deleteProfilePromise('myprofile') + .then((result) => { + + }); diff --git a/doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js b/doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js new file mode 100644 index 000000000..a10da12ab --- /dev/null +++ b/doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js @@ -0,0 +1,2 @@ +on +"deleted profile identifier" diff --git a/doc/5/core-classes/security/delete-role/index.md b/doc/5/core-classes/security/delete-role/index.md new file mode 100644 index 000000000..d9412bfd3 --- /dev/null +++ b/doc/5/core-classes/security/delete-role/index.md @@ -0,0 +1,56 @@ +--- +code: false +type: page +title: deleteRole +description: Security:deleteRole +--- + +# deleteRole + +Delete the provided role. + +
+There is a small delay between the time a role is deleted and it being reflected in the search layer (usually a couple of seconds). +That means that a role that was just deleted may still be returned by the searchRoles function at first. +
+ +--- + +## deleteRole(id, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `id` | string | Unique role identifier to delete | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Returns the id of the rold that has been deleted. + +## Usage + +<<< ./snippets/delete-role-1.js + +> Callback response + +```json +"deleted role identifier" +``` diff --git a/doc/5/core-classes/security/delete-role/snippets/delete-role-1.js b/doc/5/core-classes/security/delete-role/snippets/delete-role-1.js new file mode 100644 index 000000000..fac5e1673 --- /dev/null +++ b/doc/5/core-classes/security/delete-role/snippets/delete-role-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .deleteRole('myrole', function(error, result) { + + }); + +// Using promises (NodeJS) +kuzzle + .security + .deleteRolePromise('myrole') + .then((result) => { + + }); diff --git a/doc/5/core-classes/security/delete-role/snippets/delete-role-2.js b/doc/5/core-classes/security/delete-role/snippets/delete-role-2.js new file mode 100644 index 000000000..5fb1655b2 --- /dev/null +++ b/doc/5/core-classes/security/delete-role/snippets/delete-role-2.js @@ -0,0 +1,2 @@ +on +"deleted role identifier" diff --git a/doc/5/core-classes/security/delete-user/index.md b/doc/5/core-classes/security/delete-user/index.md new file mode 100644 index 000000000..14e4f0f7c --- /dev/null +++ b/doc/5/core-classes/security/delete-user/index.md @@ -0,0 +1,56 @@ +--- +code: false +type: page +title: deleteUser +description: Security:deleteUser +--- + +# deleteUser + +Delete the provided user. + +
+There is a small delay between the time a user is deleted and it being reflected in the search layer (usually a couple of seconds). +That means that a user that has just been deleted may still be returned by the searchUsers function at first. +
+ +--- + +## deleteUser(id, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `id` | string | Unique user identifier to delete | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Return the id of the user that has been deleted. + +## Usage + +<<< ./snippets/delete-user-1.js + +> Callback response + +```json +"deleted user identifier" +``` diff --git a/doc/5/core-classes/security/delete-user/snippets/delete-user-1.js b/doc/5/core-classes/security/delete-user/snippets/delete-user-1.js new file mode 100644 index 000000000..ee5ff4457 --- /dev/null +++ b/doc/5/core-classes/security/delete-user/snippets/delete-user-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .deleteUser('myuser', function(error, result) { + + }); + +// Using promises (NodeJS) +kuzzle + .security + .deleteUserPromise('myuser') + .then((result) => { + + }); diff --git a/doc/5/core-classes/security/delete-user/snippets/delete-user-2.js b/doc/5/core-classes/security/delete-user/snippets/delete-user-2.js new file mode 100644 index 000000000..e99606eb7 --- /dev/null +++ b/doc/5/core-classes/security/delete-user/snippets/delete-user-2.js @@ -0,0 +1,2 @@ +on +"deleted user identifier" diff --git a/doc/5/core-classes/security/fetch-profile/index.md b/doc/5/core-classes/security/fetch-profile/index.md new file mode 100644 index 000000000..10b4fda6c --- /dev/null +++ b/doc/5/core-classes/security/fetch-profile/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: fetchProfile +description: Security:fetchProfile +--- + +# fetchProfile + +Fetches a single stored profile using its unique ID. + +--- + +## fetchProfile(id, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `id` | string | Unique profile identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a security [Profile](/sdk/js/5/core-classes/profile) object. + +## Usage + +<<< ./snippets/fetch-profile-1.js diff --git a/doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js b/doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js new file mode 100644 index 000000000..12fecd744 --- /dev/null +++ b/doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .fetchProfile('myprofile', function(error, result) { + // result is a Profile object + }); + +// Using promises (NodeJS) +kuzzle + .security + .fetchProfilePromise('myprofile') + .then((result) => { + // result is a Profile object + }); diff --git a/doc/5/core-classes/security/fetch-role/index.md b/doc/5/core-classes/security/fetch-role/index.md new file mode 100644 index 000000000..20f9f08ba --- /dev/null +++ b/doc/5/core-classes/security/fetch-role/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: fetchRole +description: Security:fetchRole +--- + +# fetchRole + +Fetches a single stored role using its unique ID. + +--- + +## fetchRole(id, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `id` | string | Unique role identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a [Role](/sdk/js/5/core-classes/role) object. + +## Usage + +<<< ./snippets/fetch-role-1.js diff --git a/doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js b/doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js new file mode 100644 index 000000000..da2ccb699 --- /dev/null +++ b/doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .fetchRole('myrole', function(error, result) { + // result is a Role object + }); + +// Using promises (NodeJS) +kuzzle + .security + .fetchRolePromise('myrole') + .then((result) => { + // result is a Role object + }); diff --git a/doc/5/core-classes/security/fetch-user/index.md b/doc/5/core-classes/security/fetch-user/index.md new file mode 100644 index 000000000..41d59fdba --- /dev/null +++ b/doc/5/core-classes/security/fetch-user/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: fetchUser +description: Security:fetchUser +--- + +# fetchUser + +Fetches a single stored user using its unique ID. + +--- + +## fetchUser(id, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `id` | string | Unique user identifier | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/fetch-user-1.js diff --git a/doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js b/doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js new file mode 100644 index 000000000..9399bad96 --- /dev/null +++ b/doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .fetchUser('myuser', function(error, result) { + // result is a User object + }) + +// Using promises (NodeJS) +kuzzle + .security + .fetchUserPromise('myuser') + .then((result) => { + // result is a User object + }) diff --git a/doc/5/core-classes/security/get-all-credential-fields/index.md b/doc/5/core-classes/security/get-all-credential-fields/index.md new file mode 100644 index 000000000..8a5a2ec4e --- /dev/null +++ b/doc/5/core-classes/security/get-all-credential-fields/index.md @@ -0,0 +1,45 @@ +--- +code: false +type: page +title: getAllCredentialFields +description: Security:getAllCredentialFields +--- + +# getAllCredentialFields + +Fetches a list of accepted fields per authentication strategy. + +--- + +## getAllCredentialFields([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the credential fields. + +## Usage + +<<< ./snippets/get-all-credential-fields-1.js + +> Callback response: + +```json +{ + "local": ["kuid", "username"] +} +``` diff --git a/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js b/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js new file mode 100644 index 000000000..f08182ca5 --- /dev/null +++ b/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.getAllCredentialFields(function (error, strategies) { + +}); + +// Using promises (node.js) +kuzzle + .security + .getAllCredentialFieldsPromise() + .then(strategies => { + + }); diff --git a/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js b/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js new file mode 100644 index 000000000..f50f02528 --- /dev/null +++ b/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js @@ -0,0 +1,7 @@ +on +{ + "local": [ + "kuid", + "username" + ] +} diff --git a/doc/5/core-classes/security/get-credentials-fields/index.md b/doc/5/core-classes/security/get-credentials-fields/index.md new file mode 100644 index 000000000..9453ea1c1 --- /dev/null +++ b/doc/5/core-classes/security/get-credentials-fields/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: getCredentialsFields +description: Security:getCredentialsFields +--- + +# getCredentialFields + +Get credential information for the specified `strategy`. + +--- + +## getCredentialFields(strategy, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `strategy` | string | Strategy you want to get credentials from | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +The result is a an array of credential fields. + +## Usage + +<<< ./snippets/get-credentials-fields-1.js + +> Callback response: + +```json +["kuid", "username"] +``` diff --git a/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js b/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js new file mode 100644 index 000000000..7d667d282 --- /dev/null +++ b/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.getCredentialFields('local', function (error, fields) { + +}); + +// Using promises (node.js) +kuzzle + .security + .getCredentialFieldsPromise('local') + .then(fields => { + + }); diff --git a/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js b/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js new file mode 100644 index 000000000..516f634a5 --- /dev/null +++ b/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js @@ -0,0 +1,5 @@ +on +[ + "kuid", + "username" +] diff --git a/doc/5/core-classes/security/get-credentials/index.md b/doc/5/core-classes/security/get-credentials/index.md new file mode 100644 index 000000000..06aaa9141 --- /dev/null +++ b/doc/5/core-classes/security/get-credentials/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: getCredentials +description: Security:getCredentials +--- + +# getCredentials + +Get credential information of user with `kuid` for the specified `strategy`. + +--- + +## getCredentials(strategy, kuid, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `strategy` | string | Strategy you want to get credentials from | +| `kuid` | string | User's kuid | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +The result is a an object with the credentials. + +## Usage + +<<< ./snippets/get-credentials-1.js + +> Callback response + +```json +{ + "username": "foo", + "kuid": "" +} +``` diff --git a/doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js b/doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js new file mode 100644 index 000000000..8d9970493 --- /dev/null +++ b/doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.getCredentials('local', 'kuid', function (error, credentials) { + +}); + +// Using promises (node.js) +kuzzle + .security + .getCredentialsPromise('local', 'kuid') + .then(credentials => { + + }); diff --git a/doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js b/doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js new file mode 100644 index 000000000..c7a4a27bf --- /dev/null +++ b/doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js @@ -0,0 +1,5 @@ +on +{ + "username": "foo", + "kuid": "" +} diff --git a/doc/5/core-classes/security/get-user-rights/index.md b/doc/5/core-classes/security/get-user-rights/index.md new file mode 100644 index 000000000..3c8ad7764 --- /dev/null +++ b/doc/5/core-classes/security/get-user-rights/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: getUserRights +description: Security:getUserRights +--- + +# getUserRights + +> Callback response example + +```json +[ + { + "controller": "my-controller", + "action": "my-action", + "index": "*", + "collection": "*", + "value": "allowed" + }, + { + "controller": "another-controller", + "action": "*", + "index": "my-index", + "collection": "*", + "value": "conditional" + } +] +``` + +Given a Kuzzle user id (`kuid`), retrieves the list of permissions granted to that user. + +--- + +### getUserRights(id, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------- | +| `kuid` | String | [Kuzzle User Unique Identifier](/core/1/guides/essentials/user-authentication/#kuzzle-user-identifier-kuid) | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +### Callback Response + +Returns an array of objects. + +## Usage + +<<< ./snippets/get-user-rights-1.js diff --git a/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js b/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js new file mode 100644 index 000000000..9df2ba532 --- /dev/null +++ b/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js @@ -0,0 +1,14 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .getUserRights('kuid', function(error, rights) { + + });reflecting + +// Using promises (NodeJS) +kuzzle + .security + .getUserRightsPromise('kuid') + .then(rights => { + + }); diff --git a/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js b/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js new file mode 100644 index 000000000..8e46b95c0 --- /dev/null +++ b/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js @@ -0,0 +1,17 @@ +on +[ + { + "controller": "my-controller", + "action": "my-action", + "index": "*", + "collection": "*", + "value": "allowed" + }, + { + "controller": "another-controller", + "action": "*", + "index": "my-index", + "collection": "*", + "value": "conditional" + } +] diff --git a/doc/5/core-classes/security/has-credentials/index.md b/doc/5/core-classes/security/has-credentials/index.md new file mode 100644 index 000000000..71d2c114b --- /dev/null +++ b/doc/5/core-classes/security/has-credentials/index.md @@ -0,0 +1,39 @@ +--- +code: false +type: page +title: hasCredentials +description: Security:hasCredentials +--- + +# hasCredentials + +Checks if a user has credentials for the provided strategy. + +--- + +## hasCredentials(strategy, kuid, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------- | +| `strategy` | string | Strategy to check for credentials | +| `kuid` | JSON object | User's kuid | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a boolean value. + +## Usage + +<<< ./snippets/has-credentials-1.js diff --git a/doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js b/doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js new file mode 100644 index 000000000..966d18d94 --- /dev/null +++ b/doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.hasCredentials('local', 'kuid', function (error, result) { + +}); + +// Using promises (node.js) +kuzzle + .security + .hasCredentialsPromise('local', 'kuid') + .then(result => { + + }); diff --git a/doc/5/core-classes/security/index.md b/doc/5/core-classes/security/index.md new file mode 100644 index 000000000..ba1823f24 --- /dev/null +++ b/doc/5/core-classes/security/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: Security +description: Security documentation +--- diff --git a/doc/5/core-classes/security/is-action-allowed/index.md b/doc/5/core-classes/security/is-action-allowed/index.md new file mode 100644 index 000000000..9cc5fb963 --- /dev/null +++ b/doc/5/core-classes/security/is-action-allowed/index.md @@ -0,0 +1,42 @@ +--- +code: false +type: page +title: isActionAllowed +description: Security:isActionAllowed +--- + +# isActionAllowed + +Specifies if an action is allowed, denied or conditional based on the rights provided as the first argument: + +- `allowed` is returned when an action is authorized without condition +- `conditional` is returned when the authorization depends on a closure +- `denied` is returned when the action is forbidden + +An action is defined as a pair of action and controller (mandatory), plus an index and a collection(optional). + +
+You can get the rights from Kuzzle by using [`Security.getUserRights`](/sdk/js/5/core-classes/security/get-user-rights) and [`Kuzzle.getMyRights`](/sdk/js/5/core-classes/kuzzle/get-my-rights). +
+ +--- + +## isActionAllowed(rights, controller, action, index, collection) + +| Arguments | Type | Description | +| ------------ | ---------- | -------------- | +| `rights` | JSON array | Rights list | +| `controller` | String | The controller | +| `action` | String | The action | +| `index` | String | The index | +| `collection` | String | The collection | + +--- + +## Return Value + +Returns either `allowed`, `denied` or `conditional`. + +## Usage + +<<< ./snippets/is-action-allowed-1.js diff --git a/doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js b/doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js new file mode 100644 index 000000000..ee672cb13 --- /dev/null +++ b/doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js @@ -0,0 +1,6 @@ +kuzzle.security.getMyRights((err, rights) => { + if (!err) { + // returns either "allowed", "denied" or "conditional" + var allowed = kuzzle.security.isActionAllowed(rights, 'read', 'get', 'index1', 'collection1'); + } +}); diff --git a/doc/5/core-classes/security/profile/index.md b/doc/5/core-classes/security/profile/index.md new file mode 100644 index 000000000..cdf331731 --- /dev/null +++ b/doc/5/core-classes/security/profile/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: profile +description: Security:profile +--- + +# profile + +Instantiate a new security [Profile](/sdk/js/5/core-classes/profile) object. + +--- + +## profile(id, content) + +| Arguments | Type | Description | +| --------- | ----------- | ------------------------- | +| `id` | string | Unique profile identifier | +| `content` | JSON Object | Profile content | + +--- + +## Return Value + +Returns the new security [Profile](/sdk/js/5/core-classes/profile) object. + +## Usage + +<<< ./snippets/profile-1.js diff --git a/doc/5/core-classes/security/profile/snippets/profile-1.js b/doc/5/core-classes/security/profile/snippets/profile-1.js new file mode 100644 index 000000000..9852833cf --- /dev/null +++ b/doc/5/core-classes/security/profile/snippets/profile-1.js @@ -0,0 +1,8 @@ +var profileDefinition = { + policies: [ + {roleId: 'myrole'}, + {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } + ] +}; + +var profile = kuzzle.security.profile('myprofile', profileDefinition); diff --git a/doc/5/core-classes/security/replace-user/index.md b/doc/5/core-classes/security/replace-user/index.md new file mode 100644 index 000000000..acc6a38dc --- /dev/null +++ b/doc/5/core-classes/security/replace-user/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: replaceUser +description: Security:replaceUser +--- + +# replaceUser + +Replaces an existing user. + +--- + +## replaceUser(id, content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------------------------------------------------------------------ | +| `id` | string | Unique user identifier | +| `content` | JSON Object | A plain JSON object representing the user, should contain the mandatory `profileIds` field | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Returns a [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/replace-user-1.js diff --git a/doc/5/core-classes/security/replace-user/snippets/replace-user-1.js b/doc/5/core-classes/security/replace-user/snippets/replace-user-1.js new file mode 100644 index 000000000..0f886ac3c --- /dev/null +++ b/doc/5/core-classes/security/replace-user/snippets/replace-user-1.js @@ -0,0 +1,13 @@ +var newContent = { + profileIds: ['admin'], + firstname: 'My Name Is', + lastname: 'Jonas' +}; + + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .replaceUser("User ID", newContent, function (err, replacedUser) { + // "replacedUser" is an instance of a User object + }); diff --git a/doc/5/core-classes/security/role/index.md b/doc/5/core-classes/security/role/index.md new file mode 100644 index 000000000..2f4f08715 --- /dev/null +++ b/doc/5/core-classes/security/role/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: role +description: Security:role +--- + +# role + +Instantiate a new [Role](/sdk/js/5/core-classes/role) object. + +--- + +## role(id, content) + +| Arguments | Type | Description | +| --------- | ----------- | ---------------------- | +| `id` | string | Unique role identifier | +| `content` | JSON Object | Role content | + +--- + +## Return Value + +Returns the new [Role](/sdk/js/5/core-classes/role) object. + +## Usage + +<<< ./snippets/role-1.js diff --git a/doc/5/core-classes/security/role/snippets/role-1.js b/doc/5/core-classes/security/role/snippets/role-1.js new file mode 100644 index 000000000..6255003d8 --- /dev/null +++ b/doc/5/core-classes/security/role/snippets/role-1.js @@ -0,0 +1,11 @@ +var roleDefinition = { + controllers: { + "*": { + actions: { + "*": true + } + } + } +}; + +var role = kuzzle.security.role('role', roleDefinition); diff --git a/doc/5/core-classes/security/scroll-profiles/index.md b/doc/5/core-classes/security/scroll-profiles/index.md new file mode 100644 index 000000000..7ed5b64ed --- /dev/null +++ b/doc/5/core-classes/security/scroll-profiles/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: scrollProfiles +description: Security:scrollProfiles +--- + +# scrollProfiles + +Scrolls on stored profiles using the provided scroll ID. + +--- + +## scrollProfiles(scrollId, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------- | +| `scrollId` | string | Scroll identifier retrieved from a search query | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the list of fetched security profiles according to the scroll parameters (offset, limit etc.). + +## Usage + +<<< ./snippets/scroll-profiles-1.js diff --git a/doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js b/doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js new file mode 100644 index 000000000..3994748cf --- /dev/null +++ b/doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js @@ -0,0 +1,6 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .scrollProfiles(scrollId, options, function(error, result) { + // called once the scroll action has been completed + }); diff --git a/doc/5/core-classes/security/scroll-users/index.md b/doc/5/core-classes/security/scroll-users/index.md new file mode 100644 index 000000000..530b6ed8b --- /dev/null +++ b/doc/5/core-classes/security/scroll-users/index.md @@ -0,0 +1,38 @@ +--- +code: false +type: page +title: scrollUsers +description: Security:scrollUsers +--- + +# scrollUsers + +Scrolls on stored users using the provided scroll ID. + +--- + +## scrollUsers(scrollId, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------- | +| `scrollId` | string | Scroll identifier retrieved from a search query | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns the list of fetched users according to the scroll parameters (offset, limit etc.). + +## Usage + +<<< ./snippets/scroll-users-1.js diff --git a/doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js b/doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js new file mode 100644 index 000000000..35e47bf69 --- /dev/null +++ b/doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js @@ -0,0 +1,6 @@ +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .scrollUsers(scrollId, options, function(error, result) { + // called once the scroll action has been completed + }); diff --git a/doc/5/core-classes/security/search-profiles/index.md b/doc/5/core-classes/security/search-profiles/index.md new file mode 100644 index 000000000..d6442499f --- /dev/null +++ b/doc/5/core-classes/security/search-profiles/index.md @@ -0,0 +1,62 @@ +--- +code: false +type: page +title: searchProfiles +description: Security:searchProfiles +--- + +# searchProfiles + +Search for security profiles, optionally returning only those linked to the provided list of security roles. + +--- + +## searchProfiles(filters, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `filters` | JSON Object | Search query | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `from` | number | Starting offset | `0` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | +| `size` | integer | Number of hits to return per page | `10` | + +--- + +## Filters + +| Filter | Type | Description | Default | +| ------- | ----- | ------------------------------------------------ | ------- | +| `roles` | array | Contains an array `roles` with a list of role id | `[]` | + +--- + +## Callback Response + +Returns a JSON Object + +## Usage + +<<< ./snippets/search-profiles-1.js + +> Callback response: + +```json +{ + "total": 124, + "profiles": [ + // array of Profile objects + ], + // only if a scroll parameter has been provided + "scrollId": "" +} +``` diff --git a/doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js b/doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js new file mode 100644 index 000000000..cb3ab7690 --- /dev/null +++ b/doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js @@ -0,0 +1,36 @@ +// optional: search only for profiles referring the listed roles +const filters = { + roles: ['myrole', 'admin'] +}; + +// optional: result pagination configuration +const options = { + from: 0, + size: 10, + scroll: '1m' +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .searchProfiles(filters, options, function (error, result) { + // result is a JSON Object with the following properties: + // { + // total: , + // profiles: [, , ...], + // scrollId: "" + // } + }); + +// Using promises (NodeJS) +kuzzle + .security + .searchProfilesPromise(filters, options) + .then(result => { + // result is a JSON Object with the following properties: + // { + // total: , + // profiles: [, , ...], + // scrollId: "" + // } + }); diff --git a/doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js b/doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js new file mode 100644 index 000000000..a5ae820a7 --- /dev/null +++ b/doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js @@ -0,0 +1,9 @@ +on +{ + "total": 124, + "profiles": [ + // array of Profile objects + ], + // only if a scroll parameter has been provided + "scrollId": "" +} diff --git a/doc/5/core-classes/security/search-roles/index.md b/doc/5/core-classes/security/search-roles/index.md new file mode 100644 index 000000000..dcba26240 --- /dev/null +++ b/doc/5/core-classes/security/search-roles/index.md @@ -0,0 +1,59 @@ +--- +code: false +type: page +title: searchRoles +description: Security:searchRoles +--- + +# searchRoles + +Search for security roles, optionally returning only the roles giving access to the provided controller names. + +--- + +## searchRoles(filters, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ---------------------------------------------------------------------------------------------------- | +| `filters` | JSON Object | Optionally contains a "controllers" array listing the controller names used to filter searched roles | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Filters + +| Filter | Type | Description | Default | +| ------------- | ----- | --------------------------------------------------------- | ------- | +| `controllers` | array | retrieve only roles allowing access to the provided names | `[]` | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ---------------------------------- | ------- | +| `from` | number | Starting offset | `0` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `size` | number |  Number of hits to return per page | `10` | + +--- + +## Callback Response + +Return a JSON Object + +## Usage + +<<< ./snippets/search-roles-1.js + +> Callback response: + +```json +{ + "total": 124, + "roles": [ + // array of Role + ] +} +``` diff --git a/doc/5/core-classes/security/search-roles/snippets/search-roles-1.js b/doc/5/core-classes/security/search-roles/snippets/search-roles-1.js new file mode 100644 index 000000000..d162b8c5d --- /dev/null +++ b/doc/5/core-classes/security/search-roles/snippets/search-roles-1.js @@ -0,0 +1,34 @@ +// optional: retrieve only roles allowing access to the +// provided controller names +const filters = { + controllers: ['document'] +}; + +// optional result pagination configuration +const options = { + from: 0, + size: 10 +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .searchRoles(filters, options, function(error, result) { + // result is a JSON Object with the following properties: + // { + // total: , + // roles: [, , ...] + // } + }); + +// Using promises (NodeJS) +kuzzle + .security + .searchRolesPromise(filters, options) + .then(result => { + // result is a JSON Object with the following properties: + // { + // total: , + // roles: [, , ...] + // } + }); diff --git a/doc/5/core-classes/security/search-roles/snippets/search-roles-2.js b/doc/5/core-classes/security/search-roles/snippets/search-roles-2.js new file mode 100644 index 000000000..9d306fa04 --- /dev/null +++ b/doc/5/core-classes/security/search-roles/snippets/search-roles-2.js @@ -0,0 +1,7 @@ +on +{ + "total": 124, + "roles": [ + // array of Role + ] +} diff --git a/doc/5/core-classes/security/search-users/index.md b/doc/5/core-classes/security/search-users/index.md new file mode 100644 index 000000000..75d9fa02a --- /dev/null +++ b/doc/5/core-classes/security/search-users/index.md @@ -0,0 +1,58 @@ +--- +code: false +type: page +title: searchUsers +description: Security:searchUsers +--- + +# searchUsers + +Return users matching the given filter. + +--- + +## searchUsers(filters, [options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| `filters` | JSON Object | Filter in [Elasticsearch's Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-filter-context.html) format | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `from` | number | Starting offset | `0` | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | +| `size` | number |  Number of hits to return per result page | `10` | + +
+ To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search/). +
+ +--- + +## Callback Response + +Return a JSON Object + +## Usage + +<<< ./snippets/search-users-1.js + +> Callback response: + +```json +{ + "total": 124, + "users": [ + // array of User objects + ], + // only if a scroll parameter has been provided + "scrollId": "" +} +``` diff --git a/doc/5/core-classes/security/search-users/snippets/search-users-1.js b/doc/5/core-classes/security/search-users/snippets/search-users-1.js new file mode 100644 index 000000000..73da2aa12 --- /dev/null +++ b/doc/5/core-classes/security/search-users/snippets/search-users-1.js @@ -0,0 +1,52 @@ +const filter = { + bool: { + must: [ + { + terms: { + profileIds: ['anonymous', 'default'] + } + }, + { + geo_distance: { + distance: '10km', + pos: { + lat: 48.8566140, + lon: 2.352222 + } + } + } + ] + } +}; + +// optional: result pagination configuration +const options = { + from: 0, + size: 10, + scroll: '1m' +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .searchUsers(filters, options, function(error, result) { + // result is a JSON Object with the following properties: + // { + // total: , + // users: [, , ...], + // scrollId: "" + // } + }); + +// Using promises (NodeJS) +kuzzle + .security + .searchUsersPromise(filters, options) + .then(result => { + // result is a JSON Object with the following properties: + // { + // total: , + // users: [, , ...], + // scrollId: "" + // } + }); diff --git a/doc/5/core-classes/security/search-users/snippets/search-users-2.js b/doc/5/core-classes/security/search-users/snippets/search-users-2.js new file mode 100644 index 000000000..11c0790f8 --- /dev/null +++ b/doc/5/core-classes/security/search-users/snippets/search-users-2.js @@ -0,0 +1,9 @@ +on +{ + "total": 124, + "users": [ + // array of User objects + ], + // only if a scroll parameter has been provided + "scrollId": "" +} diff --git a/doc/5/core-classes/security/update-credentials/index.md b/doc/5/core-classes/security/update-credentials/index.md new file mode 100644 index 000000000..947b42ed8 --- /dev/null +++ b/doc/5/core-classes/security/update-credentials/index.md @@ -0,0 +1,49 @@ +--- +code: false +type: page +title: updateCredentials +description: Security:updateCredentials +--- + +# updateCredentials + +Update the current user's credentials for the specified ``. The credentials to send depend on the authentication plugin and the strategy. + +--- + +## updateCredentials(strategy, kuid, credentials, [options], [callback]) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `strategy` | string | Strategy you want to create credentials in | +| `kuid` | JSON object | User's kuid | +| `credentials` | JSON object | The credentials | +| `options` | JSON object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an object with the updated credentials. + +## Usage + +<<< ./snippets/update-credentials-1.js + +> Callback response + +```json +{ + "username": "foo", + "kuid": "" +} +``` diff --git a/doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js b/doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js new file mode 100644 index 000000000..07899e16a --- /dev/null +++ b/doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.updateCredentials('local', 'kuid', {'username': 'foo'}, function (error, updatedCredentials) { + +}); + +// Using promises (node.js) +kuzzle + .security + .updateCredentialsPromise('local', 'kuid', {'username': 'foo'}) + .then(updatedCredentials => { + + }); diff --git a/doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js b/doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js new file mode 100644 index 000000000..6e7d085e7 --- /dev/null +++ b/doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js @@ -0,0 +1,5 @@ +on +{ + "username": "foo", + "kuid": "" +} diff --git a/doc/5/core-classes/security/update-profile/index.md b/doc/5/core-classes/security/update-profile/index.md new file mode 100644 index 000000000..81591ce56 --- /dev/null +++ b/doc/5/core-classes/security/update-profile/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: updateProfile +description: Security:updateProfile +--- + +# updateProfile + +Performs a partial update on an existing profile. + +--- + +## updateProfile(id, content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ---------------- | ----------------------------------------- | +| `id` | string | Unique role identifier | +| `policies` | array of objects | List of policies to apply to this profile | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Return an updated [Profile](/sdk/js/5/core-classes/profile) object. + +## Usage + +<<< ./snippets/update-profile-1.js diff --git a/doc/5/core-classes/security/update-profile/snippets/update-profile-1.js b/doc/5/core-classes/security/update-profile/snippets/update-profile-1.js new file mode 100644 index 000000000..331df7889 --- /dev/null +++ b/doc/5/core-classes/security/update-profile/snippets/update-profile-1.js @@ -0,0 +1,25 @@ +var policies = [ + {roleId: 'myrole'}, + { + roleId: 'default', + restrictedTo: [ + {index: 'index1'}, + {index: 'index2', collections: ['foo', 'bar'] } + ] + } +]; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .updateProfile("profile ID", policies, function (err, updatedProfile) { + + }); + +// Using promises (NodeJS) +kuzzle + .security + .updateProfilePromise("profile ID", policies) + .then(updatedProfile => { + + }); diff --git a/doc/5/core-classes/security/update-role/index.md b/doc/5/core-classes/security/update-role/index.md new file mode 100644 index 000000000..db58fb15e --- /dev/null +++ b/doc/5/core-classes/security/update-role/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: updateRole +description: Security:updateRole +--- + +# updateRole + +Performs a partial update on an existing role. + +--- + +## updateRole(id, content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `id` | string | Unique role identifier | +| `content` | JSON Object | A plain JSON object representing the role | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Returns an updated [Role](/sdk/js/5/core-classes/role) object. + +## Usage + +<<< ./snippets/update-role-1.js diff --git a/doc/5/core-classes/security/update-role/snippets/update-role-1.js b/doc/5/core-classes/security/update-role/snippets/update-role-1.js new file mode 100644 index 000000000..c6ef25ca1 --- /dev/null +++ b/doc/5/core-classes/security/update-role/snippets/update-role-1.js @@ -0,0 +1,24 @@ +var roleDefinition = { + controllers: { + "read": { + actions: { + "get": true + } + } + } +}; + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .updateRole("role ID", roleDefinition, function (err, updatedRole) { + // "updatedRole" is an instance of a Role object + }); + +// Using promises (NodeJS) +kuzzle + .security + .updateRolePromise("profile ID", roleDefinition) + .then(updatedRole => { + // "updatedRole" is an instance of a Role object + }); diff --git a/doc/5/core-classes/security/update-user/index.md b/doc/5/core-classes/security/update-user/index.md new file mode 100644 index 000000000..87f691dbb --- /dev/null +++ b/doc/5/core-classes/security/update-user/index.md @@ -0,0 +1,46 @@ +--- +code: false +type: page +title: updateUser +description: Security:updateUser +--- + +# updateUser + +Performs a partial update on an existing user. + +--- + +## updateUser(id, content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `id` | string | Unique user identifier | +| `content` | JSON Object | A plain JSON object representing the user | +| `options` | string | (Optional) Optional arguments | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Filter | Type | Description | Default | +| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| `queuable` | boolean | Make this request queuable or not | `true` | +| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | + +--- + +## Return Value + +Returns the `Security` object to allow chaining. + +--- + +## Callback Response + +Returns an updated [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/update-user-1.js diff --git a/doc/5/core-classes/security/update-user/snippets/update-user-1.js b/doc/5/core-classes/security/update-user/snippets/update-user-1.js new file mode 100644 index 000000000..0c2acd841 --- /dev/null +++ b/doc/5/core-classes/security/update-user/snippets/update-user-1.js @@ -0,0 +1,20 @@ +var newContent = { + firstname: 'My Name Is', + lastname: 'Jonas' +}; + + +// Using callbacks (NodeJS or Web Browser) +kuzzle + .security + .updateUser("User ID", newContent, function (err, updatedUser) { + // "updatedUser" is an instance of a User object + }); + +// Using promises (NodeJS) +kuzzle + .security + .updateUserPromise("User ID", newContent) + .then(updatedUser => { + // "updatedUser" is an instance of a User object + }); diff --git a/doc/5/core-classes/security/user/index.md b/doc/5/core-classes/security/user/index.md new file mode 100644 index 000000000..b11e78b08 --- /dev/null +++ b/doc/5/core-classes/security/user/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: user +description: Security:user +--- + +# user + +Instantiates a new [User](/sdk/js/5/core-classes/user) object. + +--- + +## user(id, content) + +| Arguments | Type | Description | +| --------- | ----------- | ---------------------- | +| `id` | string | Unique user identifier | +| `content` | JSON Object | User content | + +--- + +## Return value + +Returns the new [User](/sdk/js/5/core-classes/user) object. + +## Usage + +<<< ./snippets/user-1.js diff --git a/doc/5/core-classes/security/user/snippets/user-1.js b/doc/5/core-classes/security/user/snippets/user-1.js new file mode 100644 index 000000000..8b12c15c6 --- /dev/null +++ b/doc/5/core-classes/security/user/snippets/user-1.js @@ -0,0 +1,13 @@ +var userContent = { + // A "profileIds" field is required to bind a user to an existing profile + profileIds: ['some profile'], + + // The "local" authentication strategy requires a password + password: 'secretPassword', + + // You can also set custom fields to your user + firstname: 'John', + lastname: 'Doe' +}; + +var user = kuzzle.security.user('myuser', userContent); diff --git a/doc/5/core-classes/security/validate-credentials/index.md b/doc/5/core-classes/security/validate-credentials/index.md new file mode 100644 index 000000000..9f320c68b --- /dev/null +++ b/doc/5/core-classes/security/validate-credentials/index.md @@ -0,0 +1,48 @@ +--- +code: false +type: page +title: validateCredentials +description: Security:validateCredentials +--- + +# validateCredentials + +> + +Validate credentials of user with `kuid` for the specified `strategy`. Resolves to an error if the credentials are invalid. + +--- + +## validateCredentials(strategy, credentials, [options], callback) + +| Arguments | Type | Description | +| ------------- | ----------- | ------------------------------------------ | +| `strategy` | string | Strategy you want to create credentials in | +| `kuid` | JSON object | User's kuid | +| `credentials` | JSON object | The credentials | +| `options` | JSON object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a boolean value if the credentials are valid, otherwise returns an error. + +## Usage + +<<< ./snippets/validate-credentials-1.js + +> Callback response + +```json +true +``` diff --git a/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js b/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js new file mode 100644 index 000000000..509cb2cec --- /dev/null +++ b/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js @@ -0,0 +1,12 @@ +// Using callbacks (node.js or browser) +kuzzle.security.validateCredentials('local', 'kuid', {'username': 'foo'}, function (error, result) { + +}); + +// Using promises (node.js) +kuzzle + .security + .validateCredentialsPromise('local', 'kuid', {'username': 'foo'}) + .then(() => { + + }); diff --git a/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js b/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js new file mode 100644 index 000000000..eeb544a8d --- /dev/null +++ b/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js @@ -0,0 +1,2 @@ +on +true diff --git a/doc/5/core-classes/user/add-profile/index.md b/doc/5/core-classes/user/add-profile/index.md new file mode 100644 index 000000000..ff3eaf5c6 --- /dev/null +++ b/doc/5/core-classes/user/add-profile/index.md @@ -0,0 +1,40 @@ +--- +code: false +type: page +title: addProfile +description: User:addProfile +--- + +# addProfile + +Replaces the security profile associated with the user. + +
+Updating a user will have no impact until the [`create`](/sdk/js/5/core-classes/user/create) or [`replace`](/sdk/js/5/core-classes/user/replace) method is called +
+ +--- + +## addProfile(profileId) + +| Arguments | Type | Description | +| ----------- | ------ | ----------- | +| `profileId` | string | Profile ID | + +--- + +## addProfile(profile) + +| Arguments | Type | Description | +| --------- | ------- | --------------------------------------------------- | +| `profile` | Profile | An instantiated [Profile](/sdk/js/5/core-classes/profile) object | + +--- + +## Return Value + +Returns the `User` object. + +## Usage + +<<< ./snippets/add-profile-1.js diff --git a/doc/5/core-classes/user/add-profile/snippets/add-profile-1.js b/doc/5/core-classes/user/add-profile/snippets/add-profile-1.js new file mode 100644 index 000000000..f882abcf3 --- /dev/null +++ b/doc/5/core-classes/user/add-profile/snippets/add-profile-1.js @@ -0,0 +1,7 @@ +var profile = kuzzle.security.fetchProfile('myprofile', function(error, profile) { + // Can add a profile directly with a Profile object + user.addProfile(profile); +}); + +// Or by passing an id +user.addProfile('myprofile'); diff --git a/doc/5/core-classes/user/constructor/index.md b/doc/5/core-classes/user/constructor/index.md new file mode 100644 index 000000000..cd365054b --- /dev/null +++ b/doc/5/core-classes/user/constructor/index.md @@ -0,0 +1,42 @@ +--- +code: false +type: page +title: constructor +description: User:constructor +order: 1 +--- + +# Constructors + +## Instantiates a new User object, which is a representation of a Kuzzle user and is linked to a security [Profile](/sdk/js/5/core-classes/profile). + +## User(Security, id, content, [meta]) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------- | +| `Security` | Security | An instantiated Security object | +| `id` | string | Unique user identifier | +| `content` | JSON Object | User content | +| `meta` | JSON Object | User metadata | + +**Note:** this constructor won't make any call to Kuzzle. + +--- + +## Properties + +| Property name | Type | Description | get/set | +| ------------- | ----------- | ------------------------- | ------- | +| `content` | JSON object | Raw user content | get | +| `id` | string | Unique profile identifier | get | +| `meta` | JSON object | User metadata | get | + +--- + +## Return Value + +Returns the `User` object. + +## Usage + +<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/user/constructor/snippets/constructor-1.js b/doc/5/core-classes/user/constructor/snippets/constructor-1.js new file mode 100644 index 000000000..f0b675942 --- /dev/null +++ b/doc/5/core-classes/user/constructor/snippets/constructor-1.js @@ -0,0 +1,17 @@ +/* + Constructors are not exposed in the JS/Node SDK. + User objects are returned by Security.user method: + */ + var userContent = { + // A "profile" field is required to bind a user to an existing profile + profileIds: ['admin'], + + // The "local" authentication strategy requires a password + password: 'secretPassword', + + // You can also set custom fields to your user + firstname: 'John', + lastname: 'Doe' + }; + +var user = kuzzle.security.user('myuser', userContent); diff --git a/doc/5/core-classes/user/create/index.md b/doc/5/core-classes/user/create/index.md new file mode 100644 index 000000000..c519b8f60 --- /dev/null +++ b/doc/5/core-classes/user/create/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: create +description: User:create +--- + +# create + +Create the user in Kuzzle. Credentials can be created during the process by using [setCredentials](/sdk/js/5/core-classes/user/set-credentials) beforehand. + +--- + +## create([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `User` object to allow chaining. + +--- + +## Callback Response + +Returns a `User` object. + +## Usage + +<<< ./snippets/create-1.js diff --git a/doc/5/core-classes/user/create/snippets/create-1.js b/doc/5/core-classes/user/create/snippets/create-1.js new file mode 100644 index 000000000..474e9dfa8 --- /dev/null +++ b/doc/5/core-classes/user/create/snippets/create-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +user + .create(function(error, result) { + // result is a User object + }); + +// Using promises (NodeJS) +user + .createPromise() + .then(result => { + // result is a User object + }); diff --git a/doc/5/core-classes/user/delete/index.md b/doc/5/core-classes/user/delete/index.md new file mode 100644 index 000000000..56d932ef7 --- /dev/null +++ b/doc/5/core-classes/user/delete/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: delete +description: User:delete +--- + +# delete + +Deletes the user in Kuzzle. + +--- + +## delete([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns a `String` containing the id of the deleted user. + +## Usage + +<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/user/delete/snippets/delete-1.js b/doc/5/core-classes/user/delete/snippets/delete-1.js new file mode 100644 index 000000000..bc17cc541 --- /dev/null +++ b/doc/5/core-classes/user/delete/snippets/delete-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +user + .delete(function(error, result) { + // result is the id of deleted user + }); + +// Using promises (NodeJS) +user + .deletePromise() + .then(result => { + // result is the id of deleted user + }); diff --git a/doc/5/core-classes/user/get-profileids/index.md b/doc/5/core-classes/user/get-profileids/index.md new file mode 100644 index 000000000..23e4e8644 --- /dev/null +++ b/doc/5/core-classes/user/get-profileids/index.md @@ -0,0 +1,20 @@ +--- +code: false +type: page +title: getProfileids +description: User:getProfileids +--- + +# getProfileIds + +Returns the list of profile identifiers associated with this user. + +--- + +## Return Value + +Returns an array of strings, each a profile identifier associated with this user. + +## Usage + +<<< ./snippets/get-profileids-1.js diff --git a/doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js b/doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js new file mode 100644 index 000000000..187c61b47 --- /dev/null +++ b/doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js @@ -0,0 +1,3 @@ +for (profileId of user.getProfileIds()) { + +} diff --git a/doc/5/core-classes/user/get-profiles/index.md b/doc/5/core-classes/user/get-profiles/index.md new file mode 100644 index 000000000..750056293 --- /dev/null +++ b/doc/5/core-classes/user/get-profiles/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: getProfiles +description: User:getProfiles +--- + +# getProfiles + +Gets the security [Profile](/sdk/js/5/core-classes/profile) instances linked to the user from Kuzzle's API. + +--- + +## getProfiles([options], callback) + +| Arguments | Type | Description | +| ---------- | ----------- | ------------------------------ | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Callback Response + +Returns an array of security [Profile](/sdk/js/5/core-classes/profile) objects. + +## Usage + +<<< ./snippets/get-profiles-1.js diff --git a/doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js b/doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js new file mode 100644 index 000000000..fa6e3679a --- /dev/null +++ b/doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +user + .getProfiles(function(error, profiles) { + // result is an array of Profile objects + }); + +// Using promises (NodeJS) +user + .getProfilesPromise() + .then(profiles => { + // profiles is an array of Profile objects + }); diff --git a/doc/5/core-classes/user/index.md b/doc/5/core-classes/user/index.md new file mode 100644 index 000000000..f06de06f3 --- /dev/null +++ b/doc/5/core-classes/user/index.md @@ -0,0 +1,6 @@ +--- +code: false +type: branch +title: User +description: User documentation +--- diff --git a/doc/5/core-classes/user/replace/index.md b/doc/5/core-classes/user/replace/index.md new file mode 100644 index 000000000..bfbcc38f8 --- /dev/null +++ b/doc/5/core-classes/user/replace/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: replace +description: User:replace +--- + +# replace + +Replaces the user in Kuzzle. + +--- + +## replace([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `User` object to allow chaining. + +--- + +## Callback Response + +Returns a `User` object. + +## Usage + +<<< ./snippets/replace-1.js diff --git a/doc/5/core-classes/user/replace/snippets/replace-1.js b/doc/5/core-classes/user/replace/snippets/replace-1.js new file mode 100644 index 000000000..4093bb6c7 --- /dev/null +++ b/doc/5/core-classes/user/replace/snippets/replace-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +user + .replace(function(error, result) { + // result is a User object + }); + +// Using promises (NodeJS) +user + .replacePromise() + .then(result => { + // result is a User object + }); diff --git a/doc/5/core-classes/user/save-restricted/index.md b/doc/5/core-classes/user/save-restricted/index.md new file mode 100644 index 000000000..d4953f7ac --- /dev/null +++ b/doc/5/core-classes/user/save-restricted/index.md @@ -0,0 +1,41 @@ +--- +code: false +type: page +title: saveRestricted +description: User:saveRestricted +--- + +# saveRestricted + +## Saves this user as restricted in Kuzzle. + +## saveRestricted([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `User` object to allow chaining. + +--- + +## Callback Response + +Returns a `User` object. + +## Usage + +<<< ./snippets/save-restricted-1.js diff --git a/doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js b/doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js new file mode 100644 index 000000000..93207cd65 --- /dev/null +++ b/doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +user + .saveRestricted(function(error, result) { + // result is a User object + }); + +// Using promises (NodeJS) +user + .saveRestrictedPromise() + .then(result => { + // result is a User object + }); diff --git a/doc/5/core-classes/user/save/index.md b/doc/5/core-classes/user/save/index.md new file mode 100644 index 000000000..02c865bff --- /dev/null +++ b/doc/5/core-classes/user/save/index.md @@ -0,0 +1,43 @@ +--- +code: false +type: page +title: save +description: User:save +--- + +# save + +Creates or replaces this user in Kuzzle. + +--- + +## save([options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | ----------------------------------------- | +| `options` | JSON Object | Optional parameters | +| `callback` | function | (Optional) Callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `User` object to allow chaining. + +--- + +## Callback Response + +Returns a `User` object. + +## Usage + +<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/user/save/snippets/save-1.js b/doc/5/core-classes/user/save/snippets/save-1.js new file mode 100644 index 000000000..b70ec6709 --- /dev/null +++ b/doc/5/core-classes/user/save/snippets/save-1.js @@ -0,0 +1,12 @@ +// Using callbacks (NodeJS or Web Browser) +user + .save(function(error, result) { + // result is a User object + }); + +// Using promises (NodeJS) +user + .savePromise() + .then((result) => { + // result is a User object + }); diff --git a/doc/5/core-classes/user/set-content/index.md b/doc/5/core-classes/user/set-content/index.md new file mode 100644 index 000000000..474cefb4e --- /dev/null +++ b/doc/5/core-classes/user/set-content/index.md @@ -0,0 +1,32 @@ +--- +code: false +type: page +title: setContent +description: User:setContent +--- + +# setContent + +Replaces the content of User. + +
+Updating a user will have no impact until the [`create`](/sdk/js/5/core-classes/user/create) or [`replace`](/sdk/js/5/core-classes/user/replace) method is called +
+ +--- + +## setContent(data) + +| Arguments | Type | Description | +| --------- | ----------- | ------------ | +| `data` | JSON Object | User content | + +--- + +## Return Value + +Returns the `User` object. + +## Usage + +<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/user/set-content/snippets/set-content-1.js b/doc/5/core-classes/user/set-content/snippets/set-content-1.js new file mode 100644 index 000000000..94d9af616 --- /dev/null +++ b/doc/5/core-classes/user/set-content/snippets/set-content-1.js @@ -0,0 +1,6 @@ +var user = kuzzle.security.fetchUser('myuser'); +var userContent = { + profileIds: ['profileId'] +}; + +user = user.setContent(userContent); diff --git a/doc/5/core-classes/user/set-credentials/index.md b/doc/5/core-classes/user/set-credentials/index.md new file mode 100644 index 000000000..682d40af1 --- /dev/null +++ b/doc/5/core-classes/user/set-credentials/index.md @@ -0,0 +1,32 @@ +--- +code: false +type: page +title: setCredentials +description: User:setCredentials +--- + +# setCredentials + +Sets the user's credentials. + +
+ Updating user credentials will have no impact until the [`create`](/sdk/js/5/core-classes/user/create) method is called.
+ The credentials to send depend on the authentication plugin and the strategy you want to create credentials for. +
+--- + +## setCredentials(credentials) + +| Arguments | Type | Description | +| ------------- | ------ | --------------------------------------------------------------------------------- | +| `credentials` | object | An object containing an attribute for each strategy you want to link the user to. | + +--- + +## Return Value + +Returns the `User` object. + +## Usage + +<<< ./snippets/set-credentials-1.js diff --git a/doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js b/doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js new file mode 100644 index 000000000..648f18a50 --- /dev/null +++ b/doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js @@ -0,0 +1,5 @@ +user.setCredentials({ + '': { + some: 'credentials' + } +}); diff --git a/doc/5/core-classes/user/set-profiles/index.md b/doc/5/core-classes/user/set-profiles/index.md new file mode 100644 index 000000000..fad58dd12 --- /dev/null +++ b/doc/5/core-classes/user/set-profiles/index.md @@ -0,0 +1,39 @@ +--- +code: false +type: page +title: setProfiles +description: User:setProfiles +--- + +# setProfiles + +Replaces the security profiles linked to the user. + +
+Updating a user will have no impact until the create or replace method is called +
+--- + +## setProfiles(profileIds) + +| Arguments | Type | Description | +| ------------ | ---------------- | ------------------- | +| `profileIds` | array of strings | List of profile IDs | + +--- + +## setProfiles(profiles) + +| Arguments | Type | Description | +| ---------- | ------------------------ | ------------------------------------------------------------- | +| `profiles` | array of Profile objects | An array of instantiated [Profile](/sdk/js/5/core-classes/profile) objects | + +--- + +## Return Value + +Returns the `User` object. + +## Usage + +<<< ./snippets/set-profiles-1.js diff --git a/doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js b/doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js new file mode 100644 index 000000000..7e5610396 --- /dev/null +++ b/doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js @@ -0,0 +1,7 @@ +var profile = kuzzle.security.fetchProfile('myprofile', function(error, profile) { + // Can set the profiles directly with a Profile object + user.setProfiles([profile]); +}); + +// Or by passing their ids +user.setProfiles(['myprofile']); diff --git a/doc/5/core-classes/user/update/index.md b/doc/5/core-classes/user/update/index.md new file mode 100644 index 000000000..b062488d8 --- /dev/null +++ b/doc/5/core-classes/user/update/index.md @@ -0,0 +1,44 @@ +--- +code: false +type: page +title: update +description: User:update +--- + +# update + +Performs a partial content update on this object. + +--- + +## update(content, [options], [callback]) + +| Arguments | Type | Description | +| ---------- | ----------- | --------------------------------------- | +| `content` | JSON Object | User content | +| `options` | JSON Object | Optional parameters | +| `callback` | function | Optional callback handling the response | + +--- + +## Options + +| Option | Type | Description | Default | +| ---------- | ------- | --------------------------------- | ------- | +| `queuable` | boolean | Make this request queuable or not | `true` | + +--- + +## Return Value + +Returns the `User` object to allow chaining. + +--- + +## Callback Response + +Returns the updated version of this object. + +## Usage + +<<< ./snippets/update-1.js diff --git a/doc/5/core-classes/user/update/snippets/update-1.js b/doc/5/core-classes/user/update/snippets/update-1.js new file mode 100644 index 000000000..ff26c05cd --- /dev/null +++ b/doc/5/core-classes/user/update/snippets/update-1.js @@ -0,0 +1,16 @@ +var updateContent = { + firstname: 'My Name Is', + lastname: 'Jonas' +}; + +// Using callbacks (NodeJS or Web Browser) +user.update(updateContent, function(err, updatedUser) { + // the updatedUser variable is the updated User object +}); + +// Using promises (NodeJS) +role + .updatePromise(updateContent) + .then(updatedUser => { + // the updatedUser variable is the updated User object + }); diff --git a/doc/5/essentials/error-handling/index.md b/doc/5/essentials/error-handling/index.md new file mode 100644 index 000000000..efbe6e24c --- /dev/null +++ b/doc/5/essentials/error-handling/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: Error Handling +order: 100 +--- + +# Error Handling + +<<< ./snippets/handling-errors-1.js +All methods that accept a callback as an argument can return an error. The error can be generated directly by the SDK, or by Kuzzle and included in the response to a request. + +All errors generated by Kuzzle contain the following properties: + +- `message`: the error message +- `status`: an error code following the [HTTP standard](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) diff --git a/doc/5/essentials/error-handling/snippets/handling-errors-1.js b/doc/5/essentials/error-handling/snippets/handling-errors-1.js new file mode 100644 index 000000000..a73b9b8e7 --- /dev/null +++ b/doc/5/essentials/error-handling/snippets/handling-errors-1.js @@ -0,0 +1,19 @@ +// Any API request method behave the same way + +// Using callbacks (NodeJS or Web Browser) +kuzzle.checkToken(token, function (err, res) { + if (err) { + console.error(err.status, ': ', err.message); + return; + } +}); + +// Using promises (NodeJS only) +kuzzle.checkTokenPromise(token) + .then(res => { + // ... + }) + .catch(err => { + console.error(err.status, ': ', err.message); + return Promise.reject(err); + }); diff --git a/doc/5/essentials/events/index.md b/doc/5/essentials/events/index.md new file mode 100644 index 000000000..9f90667a3 --- /dev/null +++ b/doc/5/essentials/events/index.md @@ -0,0 +1,29 @@ +--- +code: false +type: page +title: Events +order: 200 +--- + +# Events + +The [Kuzzle instance](/sdk/js/5/core-classes/kuzzle/) periodically emits named events that provide useful updates about the state of the Kuzzle client. To subscribe to these events, use the [addListener](/sdk/js/5/core-classes/kuzzle/add-listener) function and specify the event name and the callback function that will be executed when the event is emitted. To unsubscribe to an event, use the [removeListener](/sdk/js/5/core-classes/kuzzle/remove-listener) function, specifying the name of the event to remove. + +--- + +## Emitted Events + +| Event Name | Callback arguments | Description | +| ------------------ | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | +| `connected` | _(none)_ | Triggered when the SDK has successfully connected to Kuzzle | +| `discarded` | `error` (object) | Triggered when Kuzzle rejects a request (e.g. request can't be parsed, request too large, ...) | +| `disconnected` | _(none)_ | Triggered when the current session has been unexpectedly disconnected | +| `loginAttempt` | `{ "success": , "error": "" }` | Triggered when a login attempt completes, either with a success or a failure result | +| `networkError` | `error` (object) | Triggered when the SDK has failed to connect to Kuzzle. Does not trigger offline mode. | +| `offlineQueuePop` | `query` (object) | Triggered whenever a request is removed from the offline queue. | +| `offlineQueuePush` | `{ "query": , "cb": }` | Triggered whenever a request is added to the offline queue | +| `queryError` | `error` (object), `query` (object) | Triggered whenever Kuzzle responds with an error | +| `reconnected` | _(none)_ | Triggered when the current session has reconnected to Kuzzle after a disconnection, and only if `autoReconnect` is set to `true` | +| `tokenExpired` | _(none)_ | Triggered when Kuzzle rejected a request because the authentication token expired | + +**Note:** listeners are called in the order of their insertion. diff --git a/doc/5/essentials/index.md b/doc/5/essentials/index.md new file mode 100644 index 000000000..20d0cd882 --- /dev/null +++ b/doc/5/essentials/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 0 +title: Essentials +description: Javascript SDK v5.x essential notions +--- diff --git a/doc/5/essentials/offline-tools/index.md b/doc/5/essentials/offline-tools/index.md new file mode 100644 index 000000000..d43066a1e --- /dev/null +++ b/doc/5/essentials/offline-tools/index.md @@ -0,0 +1,96 @@ +--- +code: false +type: page +title: Offline Tools +order: 400 +--- + +# Offline Tools + +When using an unstable network connection, an application must maintain a normal behavior when it is disconnected. Our goal is to provide the right toolkit to handle such situations. + +--- + +## Handling a Network Disconnect + +There are two ways to handle a network disconnect: + +- Automatically reconnect to Kuzzle when possible, and enter _offline mode_ in the meantime. This is the default behavior. +- Stop all further communication with Kuzzle and invalidate the current instance and all its children. The application will have to manually reconnect once the network is available. To do so, simply set the `autoReconnect` option to `false` when creating the SDK instance. + +_Offline mode_ refers to the time between a `disconnected` and a `reconnected` event (see [Events](/sdk/js/5/essentials/events)). + +--- + +## Subscriptions + +A subscription opens a permanent pipe between the client and Kuzzle. Whenever a real-time message or a modified document matches a subscription filter, a notification is sent by Kuzzle to the client (for instance, see the [Collection.subscribe](/sdk/js/5/core-classes/collection/subscribe) method). + +While in offline mode, the Kuzzle SDK client maintains all subscriptions configurations and, by default, when Kuzzle SDK client reconnects, all subscriptions are renewed. This behavior can be changed by setting the `autoResubscribe` to `false`, in which case, each subscription will have to be renewed manually using the `Room.renew` method. + +--- + +## API Requests + +While in offline mode, API requests can be queued, and then executed once the network connection has been reestablished. +By default, there is no request queuing. + +- Queue all requests automatically when going offline by setting the `autoQueue` option to `true` (see [Kuzzle SDK constructor](/sdk/js/5/core-classes/kuzzle)) +- Start and stop queuing manually, by using the [startQueuing](/sdk/js/5/core-classes/kuzzle/start-queuing) and [stopQueuing](/sdk/js/5/core-classes/kuzzle/stop-queuing) methods + +The queue itself can be configured using the `queueTTL` and `queueMaxSize` options. + +--- + +## Filtering Requests to be Queued + +By default, when queuing is first activated, all requests are queued. + +However, you can choose to omit certain request by using the [`queueFilter`](/sdk/js/5/core-classes/kuzzle#properties) property. This property can be set to a function that accepts the request as an input value and returns a boolean result which indicates whether or not the request should be queud. + +Additionally, almost all request methods accept a `queuable` option, which when set to `false`, will cause the request to be discarded if the Kuzzle SDK is disconnected. This option overrides the `queueFilter` property. + +--- + +## Handling Network Reconnect + +
+Setting autoReplay to true when using user authentication should generally be avoided.
+When leaving offline-mode, the JWT validity is verified. If it has expired, the token will be removed and a tokenExpired event will be triggered.
+If autoReplay is set, then all pending requests will be automatically played as an anonymous user. +
+ +Once a `reconnected` event is fired, you may replay the content of the queue with the `playQueue` method. Or you can let the Kuzzle SDK replay it automatically upon reconnection by setting the `autoReplay` option to `true`. + +Requests are sent to Kuzzle with a `replayInterval` delay between each call. + +Any request made while the client is processing the queue will be delayed until the queue is empty. This ensures that all requests are played in the right order. + +--- + +## Taking Control of the Offline Queue + +You can be notified about what's going on in the offline queue, by using the [`offlineQueuePush`](/sdk/js/5/essentials/events) and the [`offlineQueuePop`](/sdk/js/5/essentials/events) events. + +The `offlineQueuePush` event is fired whenever a request is queued. It will emit an object containing a `query` property, describing the queued request, and an optional `cb` property containing the corresponding callback, if any. + +The `offlineQueuePop` event is fired whenever a request has been removed from the queue, either because the queue limits have been reached, or because the request has been replayed. It provides the removed request to its listeners. + +The `offlineQueueLoader` property of the Kuzzle SDK instance loads requests to the queue, **before any previously queued request**. It is invoked every time the Kuzzle SDK starts dequeuing requests. +This property must be set with a function that returns an array of objects with the following accessible properties: + +- a `query` property, containing the request to be replayed +- an optional `cb` property pointing to the callback to invoke after the completion of the request + +Finally, if the provided methods don't give you enough control over the offline queue, you can access and edit the queue directly using the `offlineQueue` property. + +--- + +## Automatic Offline-Mode + +You can set the `offlineMode` option to `auto` when instantiating the [Kuzzle SDK instance](/sdk/js/5/core-classes/kuzzle). This sets the offline mode configuration to the following presets: + +- `autoReconnect` = `true` +- `autoQueue` = `true` +- `autoReplay` = `true` +- `autoResubscribe` = `true` diff --git a/doc/5/essentials/realtime-notifications/index.md b/doc/5/essentials/realtime-notifications/index.md new file mode 100644 index 000000000..88c80c90f --- /dev/null +++ b/doc/5/essentials/realtime-notifications/index.md @@ -0,0 +1,96 @@ +--- +code: false +type: page +title: Realtime Notifications +order: 300 +--- + +# Realtime Notifications + +With Kuzzle, you don't [subscribe](/sdk/js/5/core-classes/collection/subscribe) to a room or a topic but, instead, you subscribe to documents. +This means, that when you want to subscribe you must provide a set of filter definitions, using [Koncorde](/core/1/koncorde), that tell Kuzzle what documents should trigger a notification. Then, any time a document matches the defined filters, Kuzzle will send a notification to the subscriber. + +You can also provide an empty set of filters, which will tell Kuzzle that you want to listen to any change occurring on a collection, emulating the behavior of a traditional topic. + +To subscribe, you must provide a callback that will be called each time a new notification is received. + +Once you have subscribed, depending on the subscription configuration you provided, you may receive a notification when: + +- a pub/sub message matches your criteria (real-time) +- a matching document is about to be created or deleted in real-time (deactivated by default) +- a matching document is created, updated or deleted (once the change is effective in the database) +- a user enters or leaves the room (deactivated by default) + +You may subscribe multiple times to the same room, with identical or different subscription parameters, and with different callbacks. This allows you to dispatch notifications to dedicated processes of your application, instead of maintaining a single all-purpose notification consumer (but you can do that too I you want). + +--- + +<<< ./snippets/notifications-1.js + +<<< ./snippets/notifications-2.js + +<<< ./snippets/notifications-3.js + +## Document Notification + +| Notification field | Type | Description | Possible values | +| ------------------ | ------------------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------- | +| `document` | [Document](/sdk/js/5/core-classes/document/) | Content of the document or real-time message that generated the notification | | +| `scope` | string | Indicates if the document enters or exits the subscription scope | `in`, `out` | +| `state` | string | Shows if the document is about to be changed, or if the change is done | `pending`, `done` | +| `type` | string | Notification type | `document` | + +#### Example + +```json +{ + "status": 200, + "requestId": "bc41ced6-38fc-42b9-8fd5-22ae0774aac2", + "controller": "name of the controller that generated the notification", + "action": "name of the action that generated the notification", + "collection": "collection name", + "index": "index name", + "volatile": {}, + "state": "done", + "scope": "in", + "type": "document", + "document": { + "content": { + "content": "document content example" + }, + "id": "" + } +} +``` + +--- + +## User notification + +| Notification field | Type | Description | Possible values | +| ------------------ | ----------- | -------------------------------------------------------------------------- | --------------- | +| `user` | string | Indicates if the user enters or leaves the subscribed room | `in`, `out` | +| `volatile` | JSON object | If provided during subscription, contains application specific information | | +| `result.count` | integer | Updated number of users subscribing to this room | | +| `type` | string | Notification type | `user` | + +#### Example + +```json +{ + "status": 200, + "roomId": "ID of the room concerned by this notification", + "requestId": "5897cd2f-a8a2-40b2-aa43-b31898172008", + "controller": "subscribe", + "user": "in", + "protocol": "protocol used by the notifying user", + "timestamp": 1453193069592, + "volatile": { + "optional": "user information" + }, + "type": "user", + "result": { + "count": 42 + } +} +``` diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-1.js b/doc/5/essentials/realtime-notifications/snippets/notifications-1.js new file mode 100644 index 000000000..2147d5612 --- /dev/null +++ b/doc/5/essentials/realtime-notifications/snippets/notifications-1.js @@ -0,0 +1,21 @@ +var2 + collection = kuzzle.collection('foo', 'bar'), + filters = {equals: {foo: 'bar'}}, + room; + +/* +* Use case 1 : Simple subscription to document changes with default scope/state options +*/ +room = collection.subscribe(filters, function(data) { + if (data.scope === 'in') { + console.log('New document within the scope: ', data.document); + } else if (data.scope === 'out') { + console.log('Document moved from the scope: ', data.document); + } +}).onDone(function(err, res) { + if (err) { + console.error('Error while subscribing to the room: ', err); + } else { + console.log('Subscription ready'); + } +}); diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-2.js b/doc/5/essentials/realtime-notifications/snippets/notifications-2.js new file mode 100644 index 000000000..8e24cefb7 --- /dev/null +++ b/doc/5/essentials/realtime-notifications/snippets/notifications-2.js @@ -0,0 +1,17 @@ +var + collection = kuzzle.collection('foo', 'bar'), + filters = {equals: {foo: 'bar'}}, + room; + +/* +* Use case 2 : Subscribe only to documents leaving the scope +*/ +room = collection.subscribe(filters, {scope: 'out'}, function(data) { + console.log('Document moved from the scope: ', data.document); +}).onDone(function(err, res) { + if (err) { + console.error('Error while subscribing to the room: ', err); + } else { + console.log('Subscription ready'); + } +}); diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-3.js b/doc/5/essentials/realtime-notifications/snippets/notifications-3.js new file mode 100644 index 000000000..79d582071 --- /dev/null +++ b/doc/5/essentials/realtime-notifications/snippets/notifications-3.js @@ -0,0 +1,46 @@ +var + collection = kuzzle.collection('foo', 'bar'), + filters = {equals: {foo: 'bar'}}, + room; + +/* +* Use case 3 : Create a Room with custom options and add some listeners to it +*/ + +// create the room: +room = collection.room( + filters, + {state: 'all', scope: 'in', users: 'all', subscribeToSelf: false} +); + +// listen to notifications about new documents: +room.on('document', function(data) { + if (data.state === 'done') { + console.log('New document within the scope: ', data.document); + } +}); + +// listen to notifications about other users subscribing to the same room: +room.on('user', function(data) { + if (data.user === 'in') { + console.log('A user has joigned the room', data.volatile); + console.log('Number of listening users: ', data.result.count); + } +}); + +// listen to notifications about other users leaving the same room: +room.on('user', function(data) { + if (data.user == 'out') { + console.log('A user has leaved the room', data.volatile); + console.log('Number of listening users: ', data.result.count); + } +}); + +// subscribe to the room: +room.subscribe(function(err, res) { + if (err) { + console.error('Error while subscribing to the room: ', err); + } else { + console.log('Subscription ready'); + } +}); diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-4.js b/doc/5/essentials/realtime-notifications/snippets/notifications-4.js new file mode 100644 index 000000000..57b2ac829 --- /dev/null +++ b/doc/5/essentials/realtime-notifications/snippets/notifications-4.js @@ -0,0 +1,19 @@ +on +{ + "status": 200, + "requestId": "bc41ced6-38fc-42b9-8fd5-22ae0774aac2", + "controller": "name of the controller that generated the notification", + "action": "name of the action that generated the notification", + "collection": "collection name", + "index": "index name", + "volatile": {}, + "state": "done", + "scope": "in", + "type": "document", + "document": { + "content": { + "content": "document content example" + }, + "id": "" + } +} diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-5.js b/doc/5/essentials/realtime-notifications/snippets/notifications-5.js new file mode 100644 index 000000000..9724b50e9 --- /dev/null +++ b/doc/5/essentials/realtime-notifications/snippets/notifications-5.js @@ -0,0 +1,17 @@ +on +{ + "status": 200, + "roomId": "ID of the room concerned by this notification", + "requestId": "5897cd2f-a8a2-40b2-aa43-b31898172008", + "controller": "subscribe", + "user": "in", + "protocol": "protocol used by the notifying user", + "timestamp": 1453193069592, + "volatile": { + "optional": "user information" + }, + "type": "user", + "result": { + "count": 42 + } +} diff --git a/doc/5/index.md b/doc/5/index.md new file mode 100644 index 000000000..211b9b7be --- /dev/null +++ b/doc/5/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: root +order: 10 +title: Javascript SDK v5.x +description: Javascript SDK v5.x +--- From 460cc3dc9311cbadb410caa006b6bf7062841a96 Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Thu, 13 Jun 2019 10:55:28 +0200 Subject: [PATCH 10/26] Fixed config --- .ci/doc/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/doc/config.yml b/.ci/doc/config.yml index 7b8025f7d..4dc83e7d8 100644 --- a/.ci/doc/config.yml +++ b/.ci/doc/config.yml @@ -2,7 +2,7 @@ snippets: mount: /mnt - path: doc/src/**/snippets/*.test.yml + path: doc/**/snippets/*.test.yml templates: /mnt/.ci/doc/templates runners: From c45c302e06b1de9516bf00566e2113187ca68767 Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Thu, 13 Jun 2019 17:12:42 +0200 Subject: [PATCH 11/26] [content] move doc V5 to branch 5-dev --- doc/5/.keep | 0 .../collection-mapping/apply/index.md | 43 ------- .../apply/snippets/apply-1.js | 9 -- .../collection-mapping/constructor/index.md | 42 ------ .../constructor/snippets/constructor-1.js | 10 -- .../core-classes/collection-mapping/index.md | 6 - .../collection-mapping/refresh/index.md | 37 ------ .../refresh/snippets/refresh-1.js | 9 -- .../collection-mapping/set-headers/index.md | 31 ----- .../set-headers/snippets/set-headers-1.js | 1 - .../collection-mapping/set/index.md | 33 ----- .../collection-mapping/set/snippets/set-1.js | 1 - .../collection/collection-mapping/index.md | 28 ---- .../snippets/collection-mapping-1.js | 6 - .../collection/constructor/index.md | 42 ------ .../constructor/snippets/constructor-1.js | 1 - doc/5/core-classes/collection/count/index.md | 48 ------- .../collection/count/snippets/count-1.js | 14 -- .../collection/count/snippets/count-2.js | 2 - .../collection/create-document/index.md | 58 --------- .../snippets/create-document-1.js | 16 --- doc/5/core-classes/collection/create/index.md | 69 ---------- .../collection/create/snippets/create-1.js | 35 ----- .../collection/create/snippets/create-2.js | 14 -- .../collection/delete-document/index.md | 66 ---------- .../snippets/delete-document-1.js | 29 ----- .../snippets/delete-document-2.js | 2 - .../collection/delete-specifications/index.md | 46 ------- .../snippets/delete-specifications-1.js | 14 -- .../snippets/delete-specifications-2.js | 4 - .../core-classes/collection/document/index.md | 29 ----- .../document/snippets/document-1.js | 4 - .../collection/fetch-document/index.md | 38 ------ .../snippets/fetch-document-1.js | 14 -- .../collection/get-mapping/index.md | 37 ------ .../get-mapping/snippets/get-mapping-1.js | 14 -- .../collection/get-specifications/index.md | 50 -------- .../snippets/get-specifications-1.js | 14 -- .../snippets/get-specifications-2.js | 15 --- doc/5/core-classes/collection/index.md | 6 - .../collection/mcreate-document/index.md | 54 -------- .../snippets/mcreate-document-1.js | 21 --- .../snippets/mcreate-document-2.js | 8 -- .../mcreate-or-replace-document/index.md | 54 -------- .../snippets/mcreate-or-replace-document-1.js | 21 --- .../snippets/mcreate-or-replace-document-2.js | 8 -- .../collection/mdelete-document/index.md | 45 ------- .../snippets/mdelete-document-1.js | 16 --- .../snippets/mdelete-document-2.js | 2 - .../collection/mget-document/index.md | 50 -------- .../mget-document/snippets/mget-document-1.js | 16 --- .../mget-document/snippets/mget-document-2.js | 8 -- .../collection/mreplace-document/index.md | 54 -------- .../snippets/mreplace-document-1.js | 21 --- .../snippets/mreplace-document-2.js | 8 -- .../collection/mupdate-document/index.md | 54 -------- .../snippets/mupdate-document-1.js | 21 --- .../snippets/mupdate-document-2.js | 8 -- .../collection/publish-message/index.md | 55 -------- .../snippets/publish-message-1.js | 3 - .../collection/replace-document/index.md | 47 ------- .../snippets/replace-document-1.js | 14 -- doc/5/core-classes/collection/room/index.md | 32 ----- .../collection/room/snippets/room-1.js | 6 - .../collection/scroll-specifications/index.md | 43 ------- .../snippets/scroll-specifications-1.js | 22 ---- .../snippets/scroll-specifications-2.js | 8 -- doc/5/core-classes/collection/scroll/index.md | 50 -------- .../collection/scroll/snippets/scroll-1.js | 18 --- .../collection/search-specifications/index.md | 45 ------- .../snippets/search-specifications-1.js | 33 ----- .../snippets/search-specifications-2.js | 9 -- doc/5/core-classes/collection/search/index.md | 59 --------- .../collection/search/snippets/search-1.js | 61 --------- .../collection/set-headers/index.md | 31 ----- .../set-headers/snippets/set-headers-1.js | 6 - .../collection/subscribe/index.md | 50 -------- .../subscribe/snippets/subscribe-1.js | 10 -- .../core-classes/collection/truncate/index.md | 63 --------- .../truncate/snippets/truncate-1.js | 16 --- .../truncate/snippets/truncate-2.js | 13 -- .../collection/update-document/index.md | 49 ------- .../snippets/update-document-1.js | 14 -- .../collection/update-specifications/index.md | 60 --------- .../snippets/update-specifications-1.js | 25 ---- .../snippets/update-specifications-2.js | 15 --- .../validate-specifications/index.md | 38 ------ .../snippets/validate-specifications-1.js | 25 ---- .../document/constructor/index.md | 46 ------- .../constructor/snippets/constructor-1.js | 15 --- doc/5/core-classes/document/delete/index.md | 39 ------ .../document/delete/snippets/delete-1.js | 9 -- doc/5/core-classes/document/exists/index.md | 37 ------ .../document/exists/snippets/exists-1.js | 4 - doc/5/core-classes/document/index.md | 6 - doc/5/core-classes/document/publish/index.md | 37 ------ .../document/publish/snippets/publish-1.js | 1 - doc/5/core-classes/document/refresh/index.md | 37 ------ .../document/refresh/snippets/refresh-1.js | 9 -- doc/5/core-classes/document/save/index.md | 48 ------- .../document/save/snippets/save-1.js | 9 -- .../document/set-content/index.md | 36 ------ .../set-content/snippets/set-content-1.js | 1 - .../document/set-headers/index.md | 31 ----- .../set-headers/snippets/set-headers-1.js | 1 - .../core-classes/document/subscribe/index.md | 41 ------ .../subscribe/snippets/subscribe-1.js | 15 --- doc/5/core-classes/index.md | 7 - .../core-classes/kuzzle/add-listener/index.md | 29 ----- .../add-listener/snippets/add-listener-1.js | 4 - .../core-classes/kuzzle/check-token/index.md | 54 -------- .../check-token/snippets/check-token-1.js | 10 -- .../check-token/snippets/check-token-2.js | 5 - .../check-token/snippets/check-token-3.js | 5 - doc/5/core-classes/kuzzle/collection/index.md | 33 ----- .../collection/snippets/collection-1.js | 7 - doc/5/core-classes/kuzzle/connect/index.md | 27 ---- .../kuzzle/connect/snippets/connect-1.js | 1 - .../core-classes/kuzzle/constructor/index.md | 95 -------------- .../constructor/snippets/constructor-1.js | 11 -- .../core-classes/kuzzle/create-index/index.md | 47 ------- .../create-index/snippets/create-index-1.js | 13 -- .../create-index/snippets/create-index-2.js | 5 - .../kuzzle/create-my-credentials/index.md | 39 ------ .../snippets/create-my-credentials-1.js | 11 -- .../kuzzle/delete-my-credentials/index.md | 38 ------ .../snippets/delete-my-credentials-1.js | 11 -- doc/5/core-classes/kuzzle/disconnect/index.md | 16 --- .../disconnect/snippets/disconnect-1.js | 1 - .../core-classes/kuzzle/flush-queue/index.md | 20 --- .../flush-queue/snippets/flush-queue-1.js | 1 - .../kuzzle/get-all-statistics/index.md | 66 ---------- .../snippets/get-all-statistics-1.js | 15 --- .../snippets/get-all-statistics-2.js | 16 --- .../kuzzle/get-auto-refresh/index.md | 52 -------- .../snippets/get-auto-refresh-1.js | 11 -- .../kuzzle/get-jwt-token/index.md | 20 --- .../get-jwt-token/snippets/get-jwt-token-1.js | 1 - .../kuzzle/get-my-credentials/index.md | 47 ------- .../snippets/get-my-credentials-1.js | 11 -- .../snippets/get-my-credentials-2.js | 5 - .../kuzzle/get-my-rights/index.md | 58 --------- .../get-my-rights/snippets/get-my-rights-1.js | 12 -- .../get-my-rights/snippets/get-my-rights-2.js | 17 --- .../kuzzle/get-server-info/index.md | 120 ------------------ .../snippets/get-server-info-1.js | 10 -- .../snippets/get-server-info-2.js | 79 ------------ .../kuzzle/get-statistics/index.md | 59 --------- .../snippets/get-statistics-1.js | 9 -- .../snippets/get-statistics-2.js | 14 -- .../snippets/get-statistics-3.js | 15 --- .../snippets/get-statistics-4.js | 24 ---- doc/5/core-classes/kuzzle/index.md | 7 - .../kuzzle/list-collections/index.md | 58 --------- .../snippets/list-collections-1.js | 11 -- .../snippets/list-collections-2.js | 11 -- .../core-classes/kuzzle/list-indexes/index.md | 43 ------- .../list-indexes/snippets/list-indexes-1.js | 11 -- .../list-indexes/snippets/list-indexes-2.js | 2 - doc/5/core-classes/kuzzle/login/index.md | 49 ------- .../kuzzle/login/snippets/login-1.js | 14 -- doc/5/core-classes/kuzzle/logout/index.md | 41 ------ .../kuzzle/logout/snippets/logout-1.js | 10 -- .../kuzzle/memory-storage/index.md | 10 -- doc/5/core-classes/kuzzle/now/index.md | 43 ------- .../core-classes/kuzzle/now/snippets/now-1.js | 9 -- .../core-classes/kuzzle/now/snippets/now-2.js | 2 - doc/5/core-classes/kuzzle/query/index.md | 82 ------------ .../kuzzle/query/snippets/query-1.js | 23 ---- .../kuzzle/query/snippets/query-2.js | 9 -- .../kuzzle/refresh-index/index.md | 58 --------- .../refresh-index/snippets/refresh-index-1.js | 1 - .../kuzzle/remove-all-listeners/index.md | 28 ---- .../snippets/remove-all-listeners-1.js | 5 - .../kuzzle/remove-listener/index.md | 29 ----- .../snippets/remove-listener-1.js | 1 - .../core-classes/kuzzle/replay-queue/index.md | 20 --- .../replay-queue/snippets/replay-queue-1.js | 1 - doc/5/core-classes/kuzzle/security/index.md | 10 -- .../kuzzle/set-auto-refresh/index.md | 59 --------- .../snippets/set-auto-refresh-1.js | 1 - .../kuzzle/set-default-index/index.md | 20 --- .../snippets/set-default-index-1.js | 1 - .../core-classes/kuzzle/set-headers/index.md | 31 ----- .../set-headers/snippets/set-headers-1.js | 1 - .../kuzzle/set-jwt-token/index.md | 42 ------ .../set-jwt-token/snippets/set-jwt-token-1.js | 9 -- .../kuzzle/start-queuing/index.md | 20 --- .../start-queuing/snippets/start-queuing-1.js | 1 - .../core-classes/kuzzle/stop-queuing/index.md | 20 --- .../stop-queuing/snippets/stop-queuing-1.js | 1 - .../kuzzle/unset-jwt-token/index.md | 20 --- .../snippets/unset-jwt-token-1.js | 1 - .../kuzzle/update-my-credentials/index.md | 39 ------ .../snippets/update-my-credentials-1.js | 11 -- .../core-classes/kuzzle/update-self/index.md | 44 ------- .../update-self/snippets/update-self-1.js | 18 --- .../kuzzle/validate-my-credentials/index.md | 39 ------ .../snippets/validate-my-credentials-1.js | 11 -- doc/5/core-classes/kuzzle/who-am-i/index.md | 28 ---- .../kuzzle/who-am-i/snippets/who-am-i-1.js | 10 -- .../memory-storage/append/index.md | 53 -------- .../append/snippets/append-1.js | 10 -- .../append/snippets/append-2.js | 2 - .../memory-storage/bitcount/index.md | 48 ------- .../bitcount/snippets/bitcount-1.js | 10 -- .../bitcount/snippets/bitcount-2.js | 2 - .../memory-storage/bitop/index.md | 54 -------- .../memory-storage/bitop/snippets/bitop-1.js | 10 -- .../memory-storage/bitop/snippets/bitop-2.js | 2 - .../memory-storage/bitpos/index.md | 49 ------- .../bitpos/snippets/bitpos-1.js | 10 -- .../bitpos/snippets/bitpos-2.js | 2 - .../memory-storage/constructor/index.md | 24 ---- .../constructor/snippets/constructor-1.js | 5 - .../memory-storage/dbsize/index.md | 45 ------- .../dbsize/snippets/dbsize-1.js | 10 -- .../dbsize/snippets/dbsize-2.js | 2 - .../core-classes/memory-storage/decr/index.md | 52 -------- .../memory-storage/decr/snippets/decr-1.js | 10 -- .../memory-storage/decr/snippets/decr-2.js | 2 - .../memory-storage/decrby/index.md | 53 -------- .../decrby/snippets/decrby-1.js | 10 -- .../decrby/snippets/decrby-2.js | 2 - .../core-classes/memory-storage/del/index.md | 52 -------- .../memory-storage/del/snippets/del-1.js | 10 -- .../memory-storage/del/snippets/del-2.js | 2 - .../memory-storage/exists/index.md | 46 ------- .../exists/snippets/exists-1.js | 10 -- .../exists/snippets/exists-2.js | 2 - .../memory-storage/expire/index.md | 53 -------- .../expire/snippets/expire-1.js | 10 -- .../expire/snippets/expire-2.js | 2 - .../memory-storage/expireat/index.md | 54 -------- .../expireat/snippets/expireat-1.js | 10 -- .../expireat/snippets/expireat-2.js | 2 - .../memory-storage/flushdb/index.md | 45 ------- .../flushdb/snippets/flushdb-1.js | 10 -- .../memory-storage/geoadd/index.md | 53 -------- .../geoadd/snippets/geoadd-1.js | 23 ---- .../geoadd/snippets/geoadd-2.js | 2 - .../memory-storage/geodist/index.md | 50 -------- .../geodist/snippets/geodist-1.js | 10 -- .../geodist/snippets/geodist-2.js | 2 - .../memory-storage/geohash/index.md | 47 ------- .../geohash/snippets/geohash-1.js | 10 -- .../geohash/snippets/geohash-2.js | 2 - .../memory-storage/geopos/index.md | 47 ------- .../geopos/snippets/geopos-1.js | 10 -- .../geopos/snippets/geopos-2.js | 2 - .../memory-storage/georadius/index.md | 72 ----------- .../georadius/snippets/georadius-1.js | 10 -- .../georadius/snippets/georadius-2.js | 5 - .../georadius/snippets/georadius-3.js | 5 - .../georadius/snippets/georadius-4.js | 5 - .../memory-storage/georadiusbymember/index.md | 70 ---------- .../snippets/georadiusbymember-1.js | 10 -- .../snippets/georadiusbymember-2.js | 5 - .../snippets/georadiusbymember-3.js | 5 - .../snippets/georadiusbymember-4.js | 5 - .../core-classes/memory-storage/get/index.md | 46 ------- .../memory-storage/get/snippets/get-1.js | 10 -- .../memory-storage/get/snippets/get-2.js | 2 - .../memory-storage/getbit/index.md | 47 ------- .../getbit/snippets/getbit-1.js | 10 -- .../getbit/snippets/getbit-2.js | 2 - .../memory-storage/getrange/index.md | 48 ------- .../getrange/snippets/getrange-1.js | 10 -- .../getrange/snippets/getrange-2.js | 2 - .../memory-storage/getset/index.md | 53 -------- .../getset/snippets/getset-1.js | 10 -- .../getset/snippets/getset-2.js | 2 - .../core-classes/memory-storage/hdel/index.md | 53 -------- .../memory-storage/hdel/snippets/hdel-1.js | 10 -- .../memory-storage/hdel/snippets/hdel-2.js | 2 - .../memory-storage/hexists/index.md | 47 ------- .../hexists/snippets/hexists-1.js | 10 -- .../hexists/snippets/hexists-2.js | 2 - .../core-classes/memory-storage/hget/index.md | 47 ------- .../memory-storage/hget/snippets/hget-1.js | 10 -- .../memory-storage/hget/snippets/hget-2.js | 2 - .../memory-storage/hgetall/index.md | 50 -------- .../hgetall/snippets/hgetall-1.js | 10 -- .../hgetall/snippets/hgetall-2.js | 6 - .../memory-storage/hincrby/index.md | 54 -------- .../hincrby/snippets/hincrby-1.js | 10 -- .../hincrby/snippets/hincrby-2.js | 2 - .../memory-storage/hincrbyfloat/index.md | 54 -------- .../hincrbyfloat/snippets/hincrbyfloat-1.js | 10 -- .../hincrbyfloat/snippets/hincrbyfloat-2.js | 2 - .../memory-storage/hkeys/index.md | 46 ------- .../memory-storage/hkeys/snippets/hkeys-1.js | 10 -- .../memory-storage/hkeys/snippets/hkeys-2.js | 6 - .../core-classes/memory-storage/hlen/index.md | 46 ------- .../memory-storage/hlen/snippets/hlen-1.js | 10 -- .../memory-storage/hlen/snippets/hlen-2.js | 2 - .../memory-storage/hmget/index.md | 47 ------- .../memory-storage/hmget/snippets/hmget-1.js | 10 -- .../memory-storage/hmget/snippets/hmget-2.js | 6 - .../memory-storage/hmset/index.md | 47 ------- .../memory-storage/hmset/snippets/hmset-1.js | 16 --- .../memory-storage/hscan/index.md | 55 -------- .../memory-storage/hscan/snippets/hscan-1.js | 10 -- .../memory-storage/hscan/snippets/hscan-2.js | 10 -- .../core-classes/memory-storage/hset/index.md | 54 -------- .../memory-storage/hset/snippets/hset-1.js | 10 -- .../memory-storage/hset/snippets/hset-2.js | 2 - .../memory-storage/hsetnx/index.md | 54 -------- .../hsetnx/snippets/hsetnx-1.js | 10 -- .../hsetnx/snippets/hsetnx-2.js | 2 - .../memory-storage/hstrlen/index.md | 47 ------- .../hstrlen/snippets/hstrlen-1.js | 10 -- .../hstrlen/snippets/hstrlen-2.js | 2 - .../memory-storage/hvals/index.md | 46 ------- .../memory-storage/hvals/snippets/hvals-1.js | 10 -- .../memory-storage/hvals/snippets/hvals-2.js | 6 - .../core-classes/memory-storage/incr/index.md | 52 -------- .../memory-storage/incr/snippets/incr-1.js | 10 -- .../memory-storage/incr/snippets/incr-2.js | 2 - .../memory-storage/incrby/index.md | 53 -------- .../incrby/snippets/incrby-1.js | 10 -- .../incrby/snippets/incrby-2.js | 2 - .../memory-storage/incrbyfloat/index.md | 53 -------- .../incrbyfloat/snippets/incrbyfloat-1.js | 10 -- .../incrbyfloat/snippets/incrbyfloat-2.js | 2 - doc/5/core-classes/memory-storage/index.md | 6 - .../core-classes/memory-storage/keys/index.md | 46 ------- .../memory-storage/keys/snippets/keys-1.js | 10 -- .../memory-storage/keys/snippets/keys-2.js | 6 - .../memory-storage/lindex/index.md | 47 ------- .../lindex/snippets/lindex-1.js | 10 -- .../lindex/snippets/lindex-2.js | 2 - .../memory-storage/linsert/index.md | 55 -------- .../linsert/snippets/linsert-1.js | 10 -- .../linsert/snippets/linsert-2.js | 2 - .../core-classes/memory-storage/llen/index.md | 46 ------- .../memory-storage/llen/snippets/llen-1.js | 10 -- .../memory-storage/llen/snippets/llen-2.js | 2 - .../core-classes/memory-storage/lpop/index.md | 52 -------- .../memory-storage/lpop/snippets/lpop-1.js | 10 -- .../memory-storage/lpop/snippets/lpop-2.js | 2 - .../memory-storage/lpush/index.md | 51 -------- .../memory-storage/lpush/snippets/lpush-1.js | 10 -- .../memory-storage/lpush/snippets/lpush-2.js | 2 - .../memory-storage/lpushx/index.md | 53 -------- .../lpushx/snippets/lpushx-1.js | 10 -- .../lpushx/snippets/lpushx-2.js | 2 - .../memory-storage/lrange/index.md | 48 ------- .../lrange/snippets/lrange-1.js | 10 -- .../lrange/snippets/lrange-2.js | 5 - .../core-classes/memory-storage/lrem/index.md | 54 -------- .../memory-storage/lrem/snippets/lrem-1.js | 10 -- .../memory-storage/lrem/snippets/lrem-2.js | 2 - .../core-classes/memory-storage/lset/index.md | 48 ------- .../memory-storage/lset/snippets/lset-1.js | 10 -- .../memory-storage/ltrim/index.md | 48 ------- .../memory-storage/ltrim/snippets/ltrim-1.js | 10 -- .../core-classes/memory-storage/mget/index.md | 46 ------- .../memory-storage/mget/snippets/mget-1.js | 10 -- .../memory-storage/mget/snippets/mget-2.js | 6 - .../core-classes/memory-storage/mset/index.md | 46 ------- .../memory-storage/mset/snippets/mset-1.js | 16 --- .../memory-storage/msetnx/index.md | 52 -------- .../msetnx/snippets/msetnx-1.js | 16 --- .../msetnx/snippets/msetnx-2.js | 2 - .../memory-storage/object/index.md | 47 ------- .../object/snippets/object-1.js | 10 -- .../object/snippets/object-2.js | 2 - .../memory-storage/persist/index.md | 50 -------- .../persist/snippets/persist-1.js | 10 -- .../persist/snippets/persist-2.js | 2 - .../memory-storage/pexpire/index.md | 53 -------- .../pexpire/snippets/pexpire-1.js | 10 -- .../pexpire/snippets/pexpire-2.js | 2 - .../memory-storage/pexpireat/index.md | 54 -------- .../pexpireat/snippets/pexpireat-1.js | 10 -- .../pexpireat/snippets/pexpireat-2.js | 2 - .../memory-storage/pfadd/index.md | 53 -------- .../memory-storage/pfadd/snippets/pfadd-1.js | 10 -- .../memory-storage/pfadd/snippets/pfadd-2.js | 2 - .../memory-storage/pfcount/index.md | 46 ------- .../pfcount/snippets/pfcount-1.js | 10 -- .../pfcount/snippets/pfcount-2.js | 2 - .../memory-storage/pfmerge/index.md | 41 ------ .../pfmerge/snippets/pfmerge-1.js | 10 -- .../core-classes/memory-storage/ping/index.md | 45 ------- .../memory-storage/ping/snippets/ping-1.js | 10 -- .../memory-storage/ping/snippets/ping-2.js | 2 - .../memory-storage/psetex/index.md | 48 ------- .../psetex/snippets/psetex-1.js | 10 -- .../core-classes/memory-storage/pttl/index.md | 46 ------- .../memory-storage/pttl/snippets/pttl-1.js | 10 -- .../memory-storage/pttl/snippets/pttl-2.js | 2 - .../memory-storage/randomkey/index.md | 45 ------- .../randomkey/snippets/randomkey-1.js | 10 -- .../randomkey/snippets/randomkey-2.js | 2 - .../memory-storage/rename/index.md | 47 ------- .../rename/snippets/rename-1.js | 10 -- .../memory-storage/renamenx/index.md | 53 -------- .../renamenx/snippets/renamenx-1.js | 10 -- .../renamenx/snippets/renamenx-2.js | 2 - .../core-classes/memory-storage/rpop/index.md | 50 -------- .../memory-storage/rpop/snippets/rpop-1.js | 10 -- .../memory-storage/rpop/snippets/rpop-2.js | 2 - .../memory-storage/rpoplpush/index.md | 53 -------- .../rpoplpush/snippets/rpoplpush-1.js | 10 -- .../rpoplpush/snippets/rpoplpush-2.js | 2 - .../memory-storage/rpush/index.md | 53 -------- .../memory-storage/rpush/snippets/rpush-1.js | 10 -- .../memory-storage/rpush/snippets/rpush-2.js | 2 - .../memory-storage/rpushx/index.md | 53 -------- .../rpushx/snippets/rpushx-1.js | 10 -- .../rpushx/snippets/rpushx-2.js | 2 - .../core-classes/memory-storage/sadd/index.md | 53 -------- .../memory-storage/sadd/snippets/sadd-1.js | 10 -- .../memory-storage/sadd/snippets/sadd-2.js | 2 - .../core-classes/memory-storage/scan/index.md | 58 --------- .../memory-storage/scan/snippets/scan-1.js | 10 -- .../memory-storage/scan/snippets/scan-2.js | 9 -- .../memory-storage/scard/index.md | 46 ------- .../memory-storage/scard/snippets/scard-1.js | 10 -- .../memory-storage/scard/snippets/scard-2.js | 2 - .../memory-storage/sdiff/index.md | 53 -------- .../memory-storage/sdiff/snippets/sdiff-1.js | 10 -- .../memory-storage/sdiff/snippets/sdiff-2.js | 6 - .../memory-storage/sdiffstore/index.md | 56 -------- .../sdiffstore/snippets/sdiffstore-1.js | 10 -- .../sdiffstore/snippets/sdiffstore-2.js | 2 - .../core-classes/memory-storage/set/index.md | 51 -------- .../memory-storage/set/snippets/set-1.js | 10 -- .../memory-storage/setex/index.md | 48 ------- .../memory-storage/setex/snippets/setex-1.js | 10 -- .../memory-storage/setnx/index.md | 53 -------- .../memory-storage/setnx/snippets/setnx-1.js | 10 -- .../memory-storage/setnx/snippets/setnx-2.js | 2 - .../memory-storage/sinter/index.md | 46 ------- .../sinter/snippets/sinter-1.js | 10 -- .../sinter/snippets/sinter-2.js | 6 - .../memory-storage/sinterstore/index.md | 55 -------- .../sinterstore/snippets/sinterstore-1.js | 10 -- .../sinterstore/snippets/sinterstore-2.js | 2 - .../memory-storage/sismember/index.md | 47 ------- .../sismember/snippets/sismember-1.js | 10 -- .../sismember/snippets/sismember-2.js | 2 - .../memory-storage/smembers/index.md | 52 -------- .../smembers/snippets/smembers-1.js | 10 -- .../smembers/snippets/smembers-2.js | 6 - .../memory-storage/smove/index.md | 54 -------- .../memory-storage/smove/snippets/smove-1.js | 10 -- .../memory-storage/smove/snippets/smove-2.js | 2 - .../core-classes/memory-storage/sort/index.md | 52 -------- .../memory-storage/sort/snippets/sort-1.js | 10 -- .../memory-storage/sort/snippets/sort-2.js | 6 - .../core-classes/memory-storage/spop/index.md | 53 -------- .../memory-storage/spop/snippets/spop-1.js | 10 -- .../memory-storage/spop/snippets/spop-2.js | 2 - .../memory-storage/srandmember/index.md | 48 ------- .../srandmember/snippets/srandmember-1.js | 10 -- .../srandmember/snippets/srandmember-2.js | 6 - .../core-classes/memory-storage/srem/index.md | 53 -------- .../memory-storage/srem/snippets/srem-1.js | 10 -- .../memory-storage/srem/snippets/srem-2.js | 2 - .../memory-storage/sscan/index.md | 55 -------- .../memory-storage/sscan/snippets/sscan-1.js | 10 -- .../memory-storage/sscan/snippets/sscan-2.js | 9 -- .../memory-storage/strlen/index.md | 46 ------- .../strlen/snippets/strlen-1.js | 10 -- .../strlen/snippets/strlen-2.js | 2 - .../memory-storage/sunion/index.md | 46 ------- .../sunion/snippets/sunion-1.js | 10 -- .../sunion/snippets/sunion-2.js | 6 - .../memory-storage/sunionstore/index.md | 49 ------- .../sunionstore/snippets/sunionstore-1.js | 10 -- .../sunionstore/snippets/sunionstore-2.js | 2 - .../core-classes/memory-storage/time/index.md | 48 ------- .../memory-storage/time/snippets/time-1.js | 10 -- .../memory-storage/time/snippets/time-2.js | 5 - .../memory-storage/touch/index.md | 52 -------- .../memory-storage/touch/snippets/touch-1.js | 10 -- .../memory-storage/touch/snippets/touch-2.js | 2 - .../core-classes/memory-storage/ttl/index.md | 46 ------- .../memory-storage/ttl/snippets/ttl-1.js | 10 -- .../memory-storage/ttl/snippets/ttl-2.js | 2 - .../core-classes/memory-storage/type/index.md | 46 ------- .../memory-storage/type/snippets/type-1.js | 10 -- .../memory-storage/type/snippets/type-2.js | 2 - .../core-classes/memory-storage/zadd/index.md | 61 --------- .../memory-storage/zadd/snippets/zadd-1.js | 16 --- .../memory-storage/zadd/snippets/zadd-2.js | 2 - .../memory-storage/zcard/index.md | 46 ------- .../memory-storage/zcard/snippets/zcard-1.js | 10 -- .../memory-storage/zcard/snippets/zcard-2.js | 2 - .../memory-storage/zcount/index.md | 50 -------- .../zcount/snippets/zcount-1.js | 10 -- .../zcount/snippets/zcount-2.js | 2 - .../memory-storage/zincrby/index.md | 54 -------- .../zincrby/snippets/zincrby-1.js | 10 -- .../zincrby/snippets/zincrby-2.js | 2 - .../memory-storage/zinterstore/index.md | 51 -------- .../zinterstore/snippets/zinterstore-1.js | 10 -- .../zinterstore/snippets/zinterstore-2.js | 2 - .../memory-storage/zlexcount/index.md | 48 ------- .../zlexcount/snippets/zlexcount-1.js | 10 -- .../zlexcount/snippets/zlexcount-2.js | 2 - .../memory-storage/zrange/index.md | 62 --------- .../zrange/snippets/zrange-1.js | 10 -- .../zrange/snippets/zrange-2.js | 6 - .../memory-storage/zrangebylex/index.md | 55 -------- .../zrangebylex/snippets/zrangebylex-1.js | 10 -- .../zrangebylex/snippets/zrangebylex-2.js | 6 - .../memory-storage/zrangebyscore/index.md | 59 --------- .../zrangebyscore/snippets/zrangebyscore-1.js | 10 -- .../zrangebyscore/snippets/zrangebyscore-2.js | 6 - .../memory-storage/zrank/index.md | 47 ------- .../memory-storage/zrank/snippets/zrank-1.js | 10 -- .../memory-storage/zrank/snippets/zrank-2.js | 2 - .../core-classes/memory-storage/zrem/index.md | 53 -------- .../memory-storage/zrem/snippets/zrem-1.js | 10 -- .../memory-storage/zrem/snippets/zrem-2.js | 2 - .../memory-storage/zremrangebylex/index.md | 54 -------- .../snippets/zremrangebylex-1.js | 10 -- .../snippets/zremrangebylex-2.js | 2 - .../memory-storage/zremrangebyrank/index.md | 56 -------- .../snippets/zremrangebyrank-1.js | 10 -- .../snippets/zremrangebyrank-2.js | 2 - .../memory-storage/zremrangebyscore/index.md | 54 -------- .../snippets/zremrangebyscore-1.js | 10 -- .../snippets/zremrangebyscore-2.js | 2 - .../memory-storage/zrevrange/index.md | 61 --------- .../zrevrange/snippets/zrevrange-1.js | 10 -- .../zrevrange/snippets/zrevrange-2.js | 6 - .../memory-storage/zrevrangebylex/index.md | 55 -------- .../snippets/zrevrangebylex-1.js | 10 -- .../snippets/zrevrangebylex-2.js | 6 - .../memory-storage/zrevrangebyscore/index.md | 59 --------- .../snippets/zrevrangebyscore-1.js | 10 -- .../snippets/zrevrangebyscore-2.js | 6 - .../memory-storage/zrevrank/index.md | 47 ------- .../zrevrank/snippets/zrevrank-1.js | 10 -- .../zrevrank/snippets/zrevrank-2.js | 2 - .../memory-storage/zscan/index.md | 55 -------- .../memory-storage/zscan/snippets/zscan-1.js | 10 -- .../memory-storage/zscan/snippets/zscan-2.js | 11 -- .../memory-storage/zscore/index.md | 47 ------- .../zscore/snippets/zscore-1.js | 10 -- .../zscore/snippets/zscore-2.js | 2 - .../memory-storage/zunionstore/index.md | 51 -------- .../zunionstore/snippets/zunionstore-1.js | 10 -- .../zunionstore/snippets/zunionstore-2.js | 2 - .../core-classes/profile/add-policy/index.md | 40 ------ .../add-policy/snippets/add-policy-1.js | 4 - .../core-classes/profile/constructor/index.md | 44 ------- .../constructor/snippets/constructor-1.js | 12 -- doc/5/core-classes/profile/delete/index.md | 37 ------ .../profile/delete/snippets/delete-1.js | 12 -- .../profile/get-policies/index.md | 44 ------- .../get-policies/snippets/get-policies-1.js | 3 - .../get-policies/snippets/get-policies-2.js | 20 --- doc/5/core-classes/profile/index.md | 6 - doc/5/core-classes/profile/save/index.md | 47 ------- .../profile/save/snippets/save-1.js | 21 --- .../core-classes/profile/set-content/index.md | 32 ----- .../set-content/snippets/set-content-1.js | 9 -- .../profile/set-policies/index.md | 40 ------ .../set-policies/snippets/set-policies-1.js | 4 - doc/5/core-classes/profile/update/index.md | 44 ------- .../profile/update/snippets/update-1.js | 17 --- doc/5/core-classes/role/constructor/index.md | 44 ------- .../constructor/snippets/constructor-1.js | 15 --- doc/5/core-classes/role/delete/index.md | 37 ------ .../role/delete/snippets/delete-1.js | 10 -- doc/5/core-classes/role/index.md | 6 - doc/5/core-classes/role/save/index.md | 43 ------- .../core-classes/role/save/snippets/save-1.js | 12 -- doc/5/core-classes/role/set-content/index.md | 32 ----- .../set-content/snippets/set-content-1.js | 11 -- doc/5/core-classes/role/update/index.md | 56 -------- .../role/update/snippets/update-1.js | 21 --- doc/5/core-classes/room/constructor/index.md | 55 -------- .../constructor/snippets/constructor-1.js | 12 -- doc/5/core-classes/room/count/index.md | 34 ----- .../room/count/snippets/count-1.js | 9 -- .../room/count/snippets/count-2.js | 2 - doc/5/core-classes/room/index.md | 6 - doc/5/core-classes/room/renew/index.md | 26 ---- .../room/renew/snippets/renew-1.js | 8 -- doc/5/core-classes/room/set-headers/index.md | 33 ----- .../set-headers/snippets/set-headers-1.js | 1 - doc/5/core-classes/room/unsubscribe/index.md | 20 --- .../unsubscribe/snippets/unsubscribe-1.js | 1 - .../search-result/constructor/index.md | 27 ---- .../search-result/fetch-next/index.md | 36 ------ .../fetch-next/snippets/fetch-next-1.js | 12 -- .../fetch-next/snippets/fetch-next-2.js | 22 ---- doc/5/core-classes/search-result/index.md | 6 - .../security/constructor/index.md | 25 ---- .../constructor/snippets/constructor-1.js | 5 - .../security/create-credentials/index.md | 49 ------- .../snippets/create-credentials-1.js | 12 -- .../snippets/create-credentials-2.js | 5 - .../security/create-profile/index.md | 46 ------- .../snippets/create-profile-1.js | 30 ----- .../security/create-restricted-user/index.md | 46 ------- .../snippets/create-restricted-user-1.js | 27 ---- .../security/create-role/index.md | 45 ------- .../create-role/snippets/create-role-1.js | 29 ----- .../security/create-user/index.md | 54 -------- .../create-user/snippets/create-user-1.js | 37 ------ .../security/delete-credentials/index.md | 47 ------- .../snippets/delete-credentials-1.js | 12 -- .../snippets/delete-credentials-2.js | 4 - .../security/delete-profile/index.md | 56 -------- .../snippets/delete-profile-1.js | 14 -- .../snippets/delete-profile-2.js | 2 - .../security/delete-role/index.md | 56 -------- .../delete-role/snippets/delete-role-1.js | 14 -- .../delete-role/snippets/delete-role-2.js | 2 - .../security/delete-user/index.md | 56 -------- .../delete-user/snippets/delete-user-1.js | 14 -- .../delete-user/snippets/delete-user-2.js | 2 - .../security/fetch-profile/index.md | 38 ------ .../fetch-profile/snippets/fetch-profile-1.js | 14 -- .../core-classes/security/fetch-role/index.md | 38 ------ .../fetch-role/snippets/fetch-role-1.js | 14 -- .../core-classes/security/fetch-user/index.md | 38 ------ .../fetch-user/snippets/fetch-user-1.js | 14 -- .../get-all-credential-fields/index.md | 45 ------- .../snippets/get-all-credential-fields-1.js | 12 -- .../snippets/get-all-credential-fields-2.js | 7 - .../security/get-credentials-fields/index.md | 44 ------- .../snippets/get-credentials-fields-1.js | 12 -- .../snippets/get-credentials-fields-2.js | 5 - .../security/get-credentials/index.md | 48 ------- .../snippets/get-credentials-1.js | 12 -- .../snippets/get-credentials-2.js | 5 - .../security/get-user-rights/index.md | 59 --------- .../snippets/get-user-rights-1.js | 14 -- .../snippets/get-user-rights-2.js | 17 --- .../security/has-credentials/index.md | 39 ------ .../snippets/has-credentials-1.js | 12 -- doc/5/core-classes/security/index.md | 6 - .../security/is-action-allowed/index.md | 42 ------ .../snippets/is-action-allowed-1.js | 6 - doc/5/core-classes/security/profile/index.md | 29 ----- .../security/profile/snippets/profile-1.js | 8 -- .../security/replace-user/index.md | 46 ------- .../replace-user/snippets/replace-user-1.js | 13 -- doc/5/core-classes/security/role/index.md | 29 ----- .../security/role/snippets/role-1.js | 11 -- .../security/scroll-profiles/index.md | 38 ------ .../snippets/scroll-profiles-1.js | 6 - .../security/scroll-users/index.md | 38 ------ .../scroll-users/snippets/scroll-users-1.js | 6 - .../security/search-profiles/index.md | 62 --------- .../snippets/search-profiles-1.js | 36 ------ .../snippets/search-profiles-2.js | 9 -- .../security/search-roles/index.md | 59 --------- .../search-roles/snippets/search-roles-1.js | 34 ----- .../search-roles/snippets/search-roles-2.js | 7 - .../security/search-users/index.md | 58 --------- .../search-users/snippets/search-users-1.js | 52 -------- .../search-users/snippets/search-users-2.js | 9 -- .../security/update-credentials/index.md | 49 ------- .../snippets/update-credentials-1.js | 12 -- .../snippets/update-credentials-2.js | 5 - .../security/update-profile/index.md | 46 ------- .../snippets/update-profile-1.js | 25 ---- .../security/update-role/index.md | 46 ------- .../update-role/snippets/update-role-1.js | 24 ---- .../security/update-user/index.md | 46 ------- .../update-user/snippets/update-user-1.js | 20 --- doc/5/core-classes/security/user/index.md | 29 ----- .../security/user/snippets/user-1.js | 13 -- .../security/validate-credentials/index.md | 48 ------- .../snippets/validate-credentials-1.js | 12 -- .../snippets/validate-credentials-2.js | 2 - doc/5/core-classes/user/add-profile/index.md | 40 ------ .../add-profile/snippets/add-profile-1.js | 7 - doc/5/core-classes/user/constructor/index.md | 42 ------ .../constructor/snippets/constructor-1.js | 17 --- doc/5/core-classes/user/create/index.md | 43 ------- .../user/create/snippets/create-1.js | 12 -- doc/5/core-classes/user/delete/index.md | 37 ------ .../user/delete/snippets/delete-1.js | 12 -- .../core-classes/user/get-profileids/index.md | 20 --- .../snippets/get-profileids-1.js | 3 - doc/5/core-classes/user/get-profiles/index.md | 37 ------ .../get-profiles/snippets/get-profiles-1.js | 12 -- doc/5/core-classes/user/index.md | 6 - doc/5/core-classes/user/replace/index.md | 43 ------- .../user/replace/snippets/replace-1.js | 12 -- .../user/save-restricted/index.md | 41 ------ .../snippets/save-restricted-1.js | 12 -- doc/5/core-classes/user/save/index.md | 43 ------- .../core-classes/user/save/snippets/save-1.js | 12 -- doc/5/core-classes/user/set-content/index.md | 32 ----- .../set-content/snippets/set-content-1.js | 6 - .../user/set-credentials/index.md | 32 ----- .../snippets/set-credentials-1.js | 5 - doc/5/core-classes/user/set-profiles/index.md | 39 ------ .../set-profiles/snippets/set-profiles-1.js | 7 - doc/5/core-classes/user/update/index.md | 44 ------- .../user/update/snippets/update-1.js | 16 --- doc/5/essentials/error-handling/index.md | 16 --- .../snippets/handling-errors-1.js | 19 --- doc/5/essentials/events/index.md | 29 ----- doc/5/essentials/index.md | 7 - doc/5/essentials/offline-tools/index.md | 96 -------------- .../realtime-notifications/index.md | 96 -------------- .../snippets/notifications-1.js | 21 --- .../snippets/notifications-2.js | 17 --- .../snippets/notifications-3.js | 46 ------- .../snippets/notifications-4.js | 19 --- .../snippets/notifications-5.js | 17 --- doc/5/index.md | 7 - 715 files changed, 16679 deletions(-) delete mode 100644 doc/5/.keep delete mode 100644 doc/5/core-classes/collection-mapping/apply/index.md delete mode 100644 doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js delete mode 100644 doc/5/core-classes/collection-mapping/constructor/index.md delete mode 100644 doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/collection-mapping/index.md delete mode 100644 doc/5/core-classes/collection-mapping/refresh/index.md delete mode 100644 doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js delete mode 100644 doc/5/core-classes/collection-mapping/set-headers/index.md delete mode 100644 doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js delete mode 100644 doc/5/core-classes/collection-mapping/set/index.md delete mode 100644 doc/5/core-classes/collection-mapping/set/snippets/set-1.js delete mode 100644 doc/5/core-classes/collection/collection-mapping/index.md delete mode 100644 doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js delete mode 100644 doc/5/core-classes/collection/constructor/index.md delete mode 100644 doc/5/core-classes/collection/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/collection/count/index.md delete mode 100644 doc/5/core-classes/collection/count/snippets/count-1.js delete mode 100644 doc/5/core-classes/collection/count/snippets/count-2.js delete mode 100644 doc/5/core-classes/collection/create-document/index.md delete mode 100644 doc/5/core-classes/collection/create-document/snippets/create-document-1.js delete mode 100644 doc/5/core-classes/collection/create/index.md delete mode 100644 doc/5/core-classes/collection/create/snippets/create-1.js delete mode 100644 doc/5/core-classes/collection/create/snippets/create-2.js delete mode 100644 doc/5/core-classes/collection/delete-document/index.md delete mode 100644 doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js delete mode 100644 doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js delete mode 100644 doc/5/core-classes/collection/delete-specifications/index.md delete mode 100644 doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js delete mode 100644 doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js delete mode 100644 doc/5/core-classes/collection/document/index.md delete mode 100644 doc/5/core-classes/collection/document/snippets/document-1.js delete mode 100644 doc/5/core-classes/collection/fetch-document/index.md delete mode 100644 doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js delete mode 100644 doc/5/core-classes/collection/get-mapping/index.md delete mode 100644 doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js delete mode 100644 doc/5/core-classes/collection/get-specifications/index.md delete mode 100644 doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js delete mode 100644 doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js delete mode 100644 doc/5/core-classes/collection/index.md delete mode 100644 doc/5/core-classes/collection/mcreate-document/index.md delete mode 100644 doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js delete mode 100644 doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js delete mode 100644 doc/5/core-classes/collection/mcreate-or-replace-document/index.md delete mode 100644 doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js delete mode 100644 doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js delete mode 100644 doc/5/core-classes/collection/mdelete-document/index.md delete mode 100644 doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js delete mode 100644 doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js delete mode 100644 doc/5/core-classes/collection/mget-document/index.md delete mode 100644 doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js delete mode 100644 doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js delete mode 100644 doc/5/core-classes/collection/mreplace-document/index.md delete mode 100644 doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js delete mode 100644 doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js delete mode 100644 doc/5/core-classes/collection/mupdate-document/index.md delete mode 100644 doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js delete mode 100644 doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js delete mode 100644 doc/5/core-classes/collection/publish-message/index.md delete mode 100644 doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js delete mode 100644 doc/5/core-classes/collection/replace-document/index.md delete mode 100644 doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js delete mode 100644 doc/5/core-classes/collection/room/index.md delete mode 100644 doc/5/core-classes/collection/room/snippets/room-1.js delete mode 100644 doc/5/core-classes/collection/scroll-specifications/index.md delete mode 100644 doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js delete mode 100644 doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js delete mode 100644 doc/5/core-classes/collection/scroll/index.md delete mode 100644 doc/5/core-classes/collection/scroll/snippets/scroll-1.js delete mode 100644 doc/5/core-classes/collection/search-specifications/index.md delete mode 100644 doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js delete mode 100644 doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js delete mode 100644 doc/5/core-classes/collection/search/index.md delete mode 100644 doc/5/core-classes/collection/search/snippets/search-1.js delete mode 100644 doc/5/core-classes/collection/set-headers/index.md delete mode 100644 doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js delete mode 100644 doc/5/core-classes/collection/subscribe/index.md delete mode 100644 doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js delete mode 100644 doc/5/core-classes/collection/truncate/index.md delete mode 100644 doc/5/core-classes/collection/truncate/snippets/truncate-1.js delete mode 100644 doc/5/core-classes/collection/truncate/snippets/truncate-2.js delete mode 100644 doc/5/core-classes/collection/update-document/index.md delete mode 100644 doc/5/core-classes/collection/update-document/snippets/update-document-1.js delete mode 100644 doc/5/core-classes/collection/update-specifications/index.md delete mode 100644 doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js delete mode 100644 doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js delete mode 100644 doc/5/core-classes/collection/validate-specifications/index.md delete mode 100644 doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js delete mode 100644 doc/5/core-classes/document/constructor/index.md delete mode 100644 doc/5/core-classes/document/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/document/delete/index.md delete mode 100644 doc/5/core-classes/document/delete/snippets/delete-1.js delete mode 100644 doc/5/core-classes/document/exists/index.md delete mode 100644 doc/5/core-classes/document/exists/snippets/exists-1.js delete mode 100644 doc/5/core-classes/document/index.md delete mode 100644 doc/5/core-classes/document/publish/index.md delete mode 100644 doc/5/core-classes/document/publish/snippets/publish-1.js delete mode 100644 doc/5/core-classes/document/refresh/index.md delete mode 100644 doc/5/core-classes/document/refresh/snippets/refresh-1.js delete mode 100644 doc/5/core-classes/document/save/index.md delete mode 100644 doc/5/core-classes/document/save/snippets/save-1.js delete mode 100644 doc/5/core-classes/document/set-content/index.md delete mode 100644 doc/5/core-classes/document/set-content/snippets/set-content-1.js delete mode 100644 doc/5/core-classes/document/set-headers/index.md delete mode 100644 doc/5/core-classes/document/set-headers/snippets/set-headers-1.js delete mode 100644 doc/5/core-classes/document/subscribe/index.md delete mode 100644 doc/5/core-classes/document/subscribe/snippets/subscribe-1.js delete mode 100644 doc/5/core-classes/index.md delete mode 100644 doc/5/core-classes/kuzzle/add-listener/index.md delete mode 100644 doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js delete mode 100644 doc/5/core-classes/kuzzle/check-token/index.md delete mode 100644 doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js delete mode 100644 doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js delete mode 100644 doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js delete mode 100644 doc/5/core-classes/kuzzle/collection/index.md delete mode 100644 doc/5/core-classes/kuzzle/collection/snippets/collection-1.js delete mode 100644 doc/5/core-classes/kuzzle/connect/index.md delete mode 100644 doc/5/core-classes/kuzzle/connect/snippets/connect-1.js delete mode 100644 doc/5/core-classes/kuzzle/constructor/index.md delete mode 100644 doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/kuzzle/create-index/index.md delete mode 100644 doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js delete mode 100644 doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js delete mode 100644 doc/5/core-classes/kuzzle/create-my-credentials/index.md delete mode 100644 doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js delete mode 100644 doc/5/core-classes/kuzzle/delete-my-credentials/index.md delete mode 100644 doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js delete mode 100644 doc/5/core-classes/kuzzle/disconnect/index.md delete mode 100644 doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js delete mode 100644 doc/5/core-classes/kuzzle/flush-queue/index.md delete mode 100644 doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-all-statistics/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js delete mode 100644 doc/5/core-classes/kuzzle/get-auto-refresh/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-jwt-token/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-my-credentials/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js delete mode 100644 doc/5/core-classes/kuzzle/get-my-rights/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js delete mode 100644 doc/5/core-classes/kuzzle/get-server-info/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js delete mode 100644 doc/5/core-classes/kuzzle/get-statistics/index.md delete mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js delete mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js delete mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js delete mode 100644 doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js delete mode 100644 doc/5/core-classes/kuzzle/index.md delete mode 100644 doc/5/core-classes/kuzzle/list-collections/index.md delete mode 100644 doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js delete mode 100644 doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js delete mode 100644 doc/5/core-classes/kuzzle/list-indexes/index.md delete mode 100644 doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js delete mode 100644 doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js delete mode 100644 doc/5/core-classes/kuzzle/login/index.md delete mode 100644 doc/5/core-classes/kuzzle/login/snippets/login-1.js delete mode 100644 doc/5/core-classes/kuzzle/logout/index.md delete mode 100644 doc/5/core-classes/kuzzle/logout/snippets/logout-1.js delete mode 100644 doc/5/core-classes/kuzzle/memory-storage/index.md delete mode 100644 doc/5/core-classes/kuzzle/now/index.md delete mode 100644 doc/5/core-classes/kuzzle/now/snippets/now-1.js delete mode 100644 doc/5/core-classes/kuzzle/now/snippets/now-2.js delete mode 100644 doc/5/core-classes/kuzzle/query/index.md delete mode 100644 doc/5/core-classes/kuzzle/query/snippets/query-1.js delete mode 100644 doc/5/core-classes/kuzzle/query/snippets/query-2.js delete mode 100644 doc/5/core-classes/kuzzle/refresh-index/index.md delete mode 100644 doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js delete mode 100644 doc/5/core-classes/kuzzle/remove-all-listeners/index.md delete mode 100644 doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js delete mode 100644 doc/5/core-classes/kuzzle/remove-listener/index.md delete mode 100644 doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js delete mode 100644 doc/5/core-classes/kuzzle/replay-queue/index.md delete mode 100644 doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js delete mode 100644 doc/5/core-classes/kuzzle/security/index.md delete mode 100644 doc/5/core-classes/kuzzle/set-auto-refresh/index.md delete mode 100644 doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js delete mode 100644 doc/5/core-classes/kuzzle/set-default-index/index.md delete mode 100644 doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js delete mode 100644 doc/5/core-classes/kuzzle/set-headers/index.md delete mode 100644 doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js delete mode 100644 doc/5/core-classes/kuzzle/set-jwt-token/index.md delete mode 100644 doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js delete mode 100644 doc/5/core-classes/kuzzle/start-queuing/index.md delete mode 100644 doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js delete mode 100644 doc/5/core-classes/kuzzle/stop-queuing/index.md delete mode 100644 doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js delete mode 100644 doc/5/core-classes/kuzzle/unset-jwt-token/index.md delete mode 100644 doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js delete mode 100644 doc/5/core-classes/kuzzle/update-my-credentials/index.md delete mode 100644 doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js delete mode 100644 doc/5/core-classes/kuzzle/update-self/index.md delete mode 100644 doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js delete mode 100644 doc/5/core-classes/kuzzle/validate-my-credentials/index.md delete mode 100644 doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js delete mode 100644 doc/5/core-classes/kuzzle/who-am-i/index.md delete mode 100644 doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js delete mode 100644 doc/5/core-classes/memory-storage/append/index.md delete mode 100644 doc/5/core-classes/memory-storage/append/snippets/append-1.js delete mode 100644 doc/5/core-classes/memory-storage/append/snippets/append-2.js delete mode 100644 doc/5/core-classes/memory-storage/bitcount/index.md delete mode 100644 doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js delete mode 100644 doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js delete mode 100644 doc/5/core-classes/memory-storage/bitop/index.md delete mode 100644 doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js delete mode 100644 doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js delete mode 100644 doc/5/core-classes/memory-storage/bitpos/index.md delete mode 100644 doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js delete mode 100644 doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js delete mode 100644 doc/5/core-classes/memory-storage/constructor/index.md delete mode 100644 doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/memory-storage/dbsize/index.md delete mode 100644 doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js delete mode 100644 doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js delete mode 100644 doc/5/core-classes/memory-storage/decr/index.md delete mode 100644 doc/5/core-classes/memory-storage/decr/snippets/decr-1.js delete mode 100644 doc/5/core-classes/memory-storage/decr/snippets/decr-2.js delete mode 100644 doc/5/core-classes/memory-storage/decrby/index.md delete mode 100644 doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js delete mode 100644 doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js delete mode 100644 doc/5/core-classes/memory-storage/del/index.md delete mode 100644 doc/5/core-classes/memory-storage/del/snippets/del-1.js delete mode 100644 doc/5/core-classes/memory-storage/del/snippets/del-2.js delete mode 100644 doc/5/core-classes/memory-storage/exists/index.md delete mode 100644 doc/5/core-classes/memory-storage/exists/snippets/exists-1.js delete mode 100644 doc/5/core-classes/memory-storage/exists/snippets/exists-2.js delete mode 100644 doc/5/core-classes/memory-storage/expire/index.md delete mode 100644 doc/5/core-classes/memory-storage/expire/snippets/expire-1.js delete mode 100644 doc/5/core-classes/memory-storage/expire/snippets/expire-2.js delete mode 100644 doc/5/core-classes/memory-storage/expireat/index.md delete mode 100644 doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js delete mode 100644 doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js delete mode 100644 doc/5/core-classes/memory-storage/flushdb/index.md delete mode 100644 doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js delete mode 100644 doc/5/core-classes/memory-storage/geoadd/index.md delete mode 100644 doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js delete mode 100644 doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js delete mode 100644 doc/5/core-classes/memory-storage/geodist/index.md delete mode 100644 doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js delete mode 100644 doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js delete mode 100644 doc/5/core-classes/memory-storage/geohash/index.md delete mode 100644 doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js delete mode 100644 doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js delete mode 100644 doc/5/core-classes/memory-storage/geopos/index.md delete mode 100644 doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js delete mode 100644 doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js delete mode 100644 doc/5/core-classes/memory-storage/georadius/index.md delete mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js delete mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js delete mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js delete mode 100644 doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js delete mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/index.md delete mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js delete mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js delete mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js delete mode 100644 doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js delete mode 100644 doc/5/core-classes/memory-storage/get/index.md delete mode 100644 doc/5/core-classes/memory-storage/get/snippets/get-1.js delete mode 100644 doc/5/core-classes/memory-storage/get/snippets/get-2.js delete mode 100644 doc/5/core-classes/memory-storage/getbit/index.md delete mode 100644 doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js delete mode 100644 doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js delete mode 100644 doc/5/core-classes/memory-storage/getrange/index.md delete mode 100644 doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js delete mode 100644 doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js delete mode 100644 doc/5/core-classes/memory-storage/getset/index.md delete mode 100644 doc/5/core-classes/memory-storage/getset/snippets/getset-1.js delete mode 100644 doc/5/core-classes/memory-storage/getset/snippets/getset-2.js delete mode 100644 doc/5/core-classes/memory-storage/hdel/index.md delete mode 100644 doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js delete mode 100644 doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js delete mode 100644 doc/5/core-classes/memory-storage/hexists/index.md delete mode 100644 doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js delete mode 100644 doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js delete mode 100644 doc/5/core-classes/memory-storage/hget/index.md delete mode 100644 doc/5/core-classes/memory-storage/hget/snippets/hget-1.js delete mode 100644 doc/5/core-classes/memory-storage/hget/snippets/hget-2.js delete mode 100644 doc/5/core-classes/memory-storage/hgetall/index.md delete mode 100644 doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js delete mode 100644 doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js delete mode 100644 doc/5/core-classes/memory-storage/hincrby/index.md delete mode 100644 doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js delete mode 100644 doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js delete mode 100644 doc/5/core-classes/memory-storage/hincrbyfloat/index.md delete mode 100644 doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js delete mode 100644 doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js delete mode 100644 doc/5/core-classes/memory-storage/hkeys/index.md delete mode 100644 doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js delete mode 100644 doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js delete mode 100644 doc/5/core-classes/memory-storage/hlen/index.md delete mode 100644 doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js delete mode 100644 doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js delete mode 100644 doc/5/core-classes/memory-storage/hmget/index.md delete mode 100644 doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js delete mode 100644 doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js delete mode 100644 doc/5/core-classes/memory-storage/hmset/index.md delete mode 100644 doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js delete mode 100644 doc/5/core-classes/memory-storage/hscan/index.md delete mode 100644 doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js delete mode 100644 doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js delete mode 100644 doc/5/core-classes/memory-storage/hset/index.md delete mode 100644 doc/5/core-classes/memory-storage/hset/snippets/hset-1.js delete mode 100644 doc/5/core-classes/memory-storage/hset/snippets/hset-2.js delete mode 100644 doc/5/core-classes/memory-storage/hsetnx/index.md delete mode 100644 doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js delete mode 100644 doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js delete mode 100644 doc/5/core-classes/memory-storage/hstrlen/index.md delete mode 100644 doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js delete mode 100644 doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js delete mode 100644 doc/5/core-classes/memory-storage/hvals/index.md delete mode 100644 doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js delete mode 100644 doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js delete mode 100644 doc/5/core-classes/memory-storage/incr/index.md delete mode 100644 doc/5/core-classes/memory-storage/incr/snippets/incr-1.js delete mode 100644 doc/5/core-classes/memory-storage/incr/snippets/incr-2.js delete mode 100644 doc/5/core-classes/memory-storage/incrby/index.md delete mode 100644 doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js delete mode 100644 doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js delete mode 100644 doc/5/core-classes/memory-storage/incrbyfloat/index.md delete mode 100644 doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js delete mode 100644 doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js delete mode 100644 doc/5/core-classes/memory-storage/index.md delete mode 100644 doc/5/core-classes/memory-storage/keys/index.md delete mode 100644 doc/5/core-classes/memory-storage/keys/snippets/keys-1.js delete mode 100644 doc/5/core-classes/memory-storage/keys/snippets/keys-2.js delete mode 100644 doc/5/core-classes/memory-storage/lindex/index.md delete mode 100644 doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js delete mode 100644 doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js delete mode 100644 doc/5/core-classes/memory-storage/linsert/index.md delete mode 100644 doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js delete mode 100644 doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js delete mode 100644 doc/5/core-classes/memory-storage/llen/index.md delete mode 100644 doc/5/core-classes/memory-storage/llen/snippets/llen-1.js delete mode 100644 doc/5/core-classes/memory-storage/llen/snippets/llen-2.js delete mode 100644 doc/5/core-classes/memory-storage/lpop/index.md delete mode 100644 doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js delete mode 100644 doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js delete mode 100644 doc/5/core-classes/memory-storage/lpush/index.md delete mode 100644 doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js delete mode 100644 doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js delete mode 100644 doc/5/core-classes/memory-storage/lpushx/index.md delete mode 100644 doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js delete mode 100644 doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js delete mode 100644 doc/5/core-classes/memory-storage/lrange/index.md delete mode 100644 doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js delete mode 100644 doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js delete mode 100644 doc/5/core-classes/memory-storage/lrem/index.md delete mode 100644 doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js delete mode 100644 doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js delete mode 100644 doc/5/core-classes/memory-storage/lset/index.md delete mode 100644 doc/5/core-classes/memory-storage/lset/snippets/lset-1.js delete mode 100644 doc/5/core-classes/memory-storage/ltrim/index.md delete mode 100644 doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js delete mode 100644 doc/5/core-classes/memory-storage/mget/index.md delete mode 100644 doc/5/core-classes/memory-storage/mget/snippets/mget-1.js delete mode 100644 doc/5/core-classes/memory-storage/mget/snippets/mget-2.js delete mode 100644 doc/5/core-classes/memory-storage/mset/index.md delete mode 100644 doc/5/core-classes/memory-storage/mset/snippets/mset-1.js delete mode 100644 doc/5/core-classes/memory-storage/msetnx/index.md delete mode 100644 doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js delete mode 100644 doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js delete mode 100644 doc/5/core-classes/memory-storage/object/index.md delete mode 100644 doc/5/core-classes/memory-storage/object/snippets/object-1.js delete mode 100644 doc/5/core-classes/memory-storage/object/snippets/object-2.js delete mode 100644 doc/5/core-classes/memory-storage/persist/index.md delete mode 100644 doc/5/core-classes/memory-storage/persist/snippets/persist-1.js delete mode 100644 doc/5/core-classes/memory-storage/persist/snippets/persist-2.js delete mode 100644 doc/5/core-classes/memory-storage/pexpire/index.md delete mode 100644 doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js delete mode 100644 doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js delete mode 100644 doc/5/core-classes/memory-storage/pexpireat/index.md delete mode 100644 doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js delete mode 100644 doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js delete mode 100644 doc/5/core-classes/memory-storage/pfadd/index.md delete mode 100644 doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js delete mode 100644 doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js delete mode 100644 doc/5/core-classes/memory-storage/pfcount/index.md delete mode 100644 doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js delete mode 100644 doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js delete mode 100644 doc/5/core-classes/memory-storage/pfmerge/index.md delete mode 100644 doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js delete mode 100644 doc/5/core-classes/memory-storage/ping/index.md delete mode 100644 doc/5/core-classes/memory-storage/ping/snippets/ping-1.js delete mode 100644 doc/5/core-classes/memory-storage/ping/snippets/ping-2.js delete mode 100644 doc/5/core-classes/memory-storage/psetex/index.md delete mode 100644 doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js delete mode 100644 doc/5/core-classes/memory-storage/pttl/index.md delete mode 100644 doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js delete mode 100644 doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js delete mode 100644 doc/5/core-classes/memory-storage/randomkey/index.md delete mode 100644 doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js delete mode 100644 doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js delete mode 100644 doc/5/core-classes/memory-storage/rename/index.md delete mode 100644 doc/5/core-classes/memory-storage/rename/snippets/rename-1.js delete mode 100644 doc/5/core-classes/memory-storage/renamenx/index.md delete mode 100644 doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js delete mode 100644 doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js delete mode 100644 doc/5/core-classes/memory-storage/rpop/index.md delete mode 100644 doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js delete mode 100644 doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js delete mode 100644 doc/5/core-classes/memory-storage/rpoplpush/index.md delete mode 100644 doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js delete mode 100644 doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js delete mode 100644 doc/5/core-classes/memory-storage/rpush/index.md delete mode 100644 doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js delete mode 100644 doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js delete mode 100644 doc/5/core-classes/memory-storage/rpushx/index.md delete mode 100644 doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js delete mode 100644 doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js delete mode 100644 doc/5/core-classes/memory-storage/sadd/index.md delete mode 100644 doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js delete mode 100644 doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js delete mode 100644 doc/5/core-classes/memory-storage/scan/index.md delete mode 100644 doc/5/core-classes/memory-storage/scan/snippets/scan-1.js delete mode 100644 doc/5/core-classes/memory-storage/scan/snippets/scan-2.js delete mode 100644 doc/5/core-classes/memory-storage/scard/index.md delete mode 100644 doc/5/core-classes/memory-storage/scard/snippets/scard-1.js delete mode 100644 doc/5/core-classes/memory-storage/scard/snippets/scard-2.js delete mode 100644 doc/5/core-classes/memory-storage/sdiff/index.md delete mode 100644 doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js delete mode 100644 doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js delete mode 100644 doc/5/core-classes/memory-storage/sdiffstore/index.md delete mode 100644 doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js delete mode 100644 doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js delete mode 100644 doc/5/core-classes/memory-storage/set/index.md delete mode 100644 doc/5/core-classes/memory-storage/set/snippets/set-1.js delete mode 100644 doc/5/core-classes/memory-storage/setex/index.md delete mode 100644 doc/5/core-classes/memory-storage/setex/snippets/setex-1.js delete mode 100644 doc/5/core-classes/memory-storage/setnx/index.md delete mode 100644 doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js delete mode 100644 doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js delete mode 100644 doc/5/core-classes/memory-storage/sinter/index.md delete mode 100644 doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js delete mode 100644 doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js delete mode 100644 doc/5/core-classes/memory-storage/sinterstore/index.md delete mode 100644 doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js delete mode 100644 doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js delete mode 100644 doc/5/core-classes/memory-storage/sismember/index.md delete mode 100644 doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js delete mode 100644 doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js delete mode 100644 doc/5/core-classes/memory-storage/smembers/index.md delete mode 100644 doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js delete mode 100644 doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js delete mode 100644 doc/5/core-classes/memory-storage/smove/index.md delete mode 100644 doc/5/core-classes/memory-storage/smove/snippets/smove-1.js delete mode 100644 doc/5/core-classes/memory-storage/smove/snippets/smove-2.js delete mode 100644 doc/5/core-classes/memory-storage/sort/index.md delete mode 100644 doc/5/core-classes/memory-storage/sort/snippets/sort-1.js delete mode 100644 doc/5/core-classes/memory-storage/sort/snippets/sort-2.js delete mode 100644 doc/5/core-classes/memory-storage/spop/index.md delete mode 100644 doc/5/core-classes/memory-storage/spop/snippets/spop-1.js delete mode 100644 doc/5/core-classes/memory-storage/spop/snippets/spop-2.js delete mode 100644 doc/5/core-classes/memory-storage/srandmember/index.md delete mode 100644 doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js delete mode 100644 doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js delete mode 100644 doc/5/core-classes/memory-storage/srem/index.md delete mode 100644 doc/5/core-classes/memory-storage/srem/snippets/srem-1.js delete mode 100644 doc/5/core-classes/memory-storage/srem/snippets/srem-2.js delete mode 100644 doc/5/core-classes/memory-storage/sscan/index.md delete mode 100644 doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js delete mode 100644 doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js delete mode 100644 doc/5/core-classes/memory-storage/strlen/index.md delete mode 100644 doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js delete mode 100644 doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js delete mode 100644 doc/5/core-classes/memory-storage/sunion/index.md delete mode 100644 doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js delete mode 100644 doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js delete mode 100644 doc/5/core-classes/memory-storage/sunionstore/index.md delete mode 100644 doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js delete mode 100644 doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js delete mode 100644 doc/5/core-classes/memory-storage/time/index.md delete mode 100644 doc/5/core-classes/memory-storage/time/snippets/time-1.js delete mode 100644 doc/5/core-classes/memory-storage/time/snippets/time-2.js delete mode 100644 doc/5/core-classes/memory-storage/touch/index.md delete mode 100644 doc/5/core-classes/memory-storage/touch/snippets/touch-1.js delete mode 100644 doc/5/core-classes/memory-storage/touch/snippets/touch-2.js delete mode 100644 doc/5/core-classes/memory-storage/ttl/index.md delete mode 100644 doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js delete mode 100644 doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js delete mode 100644 doc/5/core-classes/memory-storage/type/index.md delete mode 100644 doc/5/core-classes/memory-storage/type/snippets/type-1.js delete mode 100644 doc/5/core-classes/memory-storage/type/snippets/type-2.js delete mode 100644 doc/5/core-classes/memory-storage/zadd/index.md delete mode 100644 doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js delete mode 100644 doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js delete mode 100644 doc/5/core-classes/memory-storage/zcard/index.md delete mode 100644 doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js delete mode 100644 doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js delete mode 100644 doc/5/core-classes/memory-storage/zcount/index.md delete mode 100644 doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js delete mode 100644 doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js delete mode 100644 doc/5/core-classes/memory-storage/zincrby/index.md delete mode 100644 doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js delete mode 100644 doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js delete mode 100644 doc/5/core-classes/memory-storage/zinterstore/index.md delete mode 100644 doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js delete mode 100644 doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js delete mode 100644 doc/5/core-classes/memory-storage/zlexcount/index.md delete mode 100644 doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js delete mode 100644 doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrange/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrangebylex/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrangebyscore/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrank/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrem/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js delete mode 100644 doc/5/core-classes/memory-storage/zremrangebylex/index.md delete mode 100644 doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js delete mode 100644 doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js delete mode 100644 doc/5/core-classes/memory-storage/zremrangebyrank/index.md delete mode 100644 doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js delete mode 100644 doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js delete mode 100644 doc/5/core-classes/memory-storage/zremrangebyscore/index.md delete mode 100644 doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js delete mode 100644 doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrange/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrangebylex/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrangebyscore/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrank/index.md delete mode 100644 doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js delete mode 100644 doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js delete mode 100644 doc/5/core-classes/memory-storage/zscan/index.md delete mode 100644 doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js delete mode 100644 doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js delete mode 100644 doc/5/core-classes/memory-storage/zscore/index.md delete mode 100644 doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js delete mode 100644 doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js delete mode 100644 doc/5/core-classes/memory-storage/zunionstore/index.md delete mode 100644 doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js delete mode 100644 doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js delete mode 100644 doc/5/core-classes/profile/add-policy/index.md delete mode 100644 doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js delete mode 100644 doc/5/core-classes/profile/constructor/index.md delete mode 100644 doc/5/core-classes/profile/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/profile/delete/index.md delete mode 100644 doc/5/core-classes/profile/delete/snippets/delete-1.js delete mode 100644 doc/5/core-classes/profile/get-policies/index.md delete mode 100644 doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js delete mode 100644 doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js delete mode 100644 doc/5/core-classes/profile/index.md delete mode 100644 doc/5/core-classes/profile/save/index.md delete mode 100644 doc/5/core-classes/profile/save/snippets/save-1.js delete mode 100644 doc/5/core-classes/profile/set-content/index.md delete mode 100644 doc/5/core-classes/profile/set-content/snippets/set-content-1.js delete mode 100644 doc/5/core-classes/profile/set-policies/index.md delete mode 100644 doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js delete mode 100644 doc/5/core-classes/profile/update/index.md delete mode 100644 doc/5/core-classes/profile/update/snippets/update-1.js delete mode 100644 doc/5/core-classes/role/constructor/index.md delete mode 100644 doc/5/core-classes/role/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/role/delete/index.md delete mode 100644 doc/5/core-classes/role/delete/snippets/delete-1.js delete mode 100644 doc/5/core-classes/role/index.md delete mode 100644 doc/5/core-classes/role/save/index.md delete mode 100644 doc/5/core-classes/role/save/snippets/save-1.js delete mode 100644 doc/5/core-classes/role/set-content/index.md delete mode 100644 doc/5/core-classes/role/set-content/snippets/set-content-1.js delete mode 100644 doc/5/core-classes/role/update/index.md delete mode 100644 doc/5/core-classes/role/update/snippets/update-1.js delete mode 100644 doc/5/core-classes/room/constructor/index.md delete mode 100644 doc/5/core-classes/room/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/room/count/index.md delete mode 100644 doc/5/core-classes/room/count/snippets/count-1.js delete mode 100644 doc/5/core-classes/room/count/snippets/count-2.js delete mode 100644 doc/5/core-classes/room/index.md delete mode 100644 doc/5/core-classes/room/renew/index.md delete mode 100644 doc/5/core-classes/room/renew/snippets/renew-1.js delete mode 100644 doc/5/core-classes/room/set-headers/index.md delete mode 100644 doc/5/core-classes/room/set-headers/snippets/set-headers-1.js delete mode 100644 doc/5/core-classes/room/unsubscribe/index.md delete mode 100644 doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js delete mode 100644 doc/5/core-classes/search-result/constructor/index.md delete mode 100644 doc/5/core-classes/search-result/fetch-next/index.md delete mode 100644 doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js delete mode 100644 doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js delete mode 100644 doc/5/core-classes/search-result/index.md delete mode 100644 doc/5/core-classes/security/constructor/index.md delete mode 100644 doc/5/core-classes/security/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/security/create-credentials/index.md delete mode 100644 doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js delete mode 100644 doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js delete mode 100644 doc/5/core-classes/security/create-profile/index.md delete mode 100644 doc/5/core-classes/security/create-profile/snippets/create-profile-1.js delete mode 100644 doc/5/core-classes/security/create-restricted-user/index.md delete mode 100644 doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js delete mode 100644 doc/5/core-classes/security/create-role/index.md delete mode 100644 doc/5/core-classes/security/create-role/snippets/create-role-1.js delete mode 100644 doc/5/core-classes/security/create-user/index.md delete mode 100644 doc/5/core-classes/security/create-user/snippets/create-user-1.js delete mode 100644 doc/5/core-classes/security/delete-credentials/index.md delete mode 100644 doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js delete mode 100644 doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js delete mode 100644 doc/5/core-classes/security/delete-profile/index.md delete mode 100644 doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js delete mode 100644 doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js delete mode 100644 doc/5/core-classes/security/delete-role/index.md delete mode 100644 doc/5/core-classes/security/delete-role/snippets/delete-role-1.js delete mode 100644 doc/5/core-classes/security/delete-role/snippets/delete-role-2.js delete mode 100644 doc/5/core-classes/security/delete-user/index.md delete mode 100644 doc/5/core-classes/security/delete-user/snippets/delete-user-1.js delete mode 100644 doc/5/core-classes/security/delete-user/snippets/delete-user-2.js delete mode 100644 doc/5/core-classes/security/fetch-profile/index.md delete mode 100644 doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js delete mode 100644 doc/5/core-classes/security/fetch-role/index.md delete mode 100644 doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js delete mode 100644 doc/5/core-classes/security/fetch-user/index.md delete mode 100644 doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js delete mode 100644 doc/5/core-classes/security/get-all-credential-fields/index.md delete mode 100644 doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js delete mode 100644 doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js delete mode 100644 doc/5/core-classes/security/get-credentials-fields/index.md delete mode 100644 doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js delete mode 100644 doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js delete mode 100644 doc/5/core-classes/security/get-credentials/index.md delete mode 100644 doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js delete mode 100644 doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js delete mode 100644 doc/5/core-classes/security/get-user-rights/index.md delete mode 100644 doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js delete mode 100644 doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js delete mode 100644 doc/5/core-classes/security/has-credentials/index.md delete mode 100644 doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js delete mode 100644 doc/5/core-classes/security/index.md delete mode 100644 doc/5/core-classes/security/is-action-allowed/index.md delete mode 100644 doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js delete mode 100644 doc/5/core-classes/security/profile/index.md delete mode 100644 doc/5/core-classes/security/profile/snippets/profile-1.js delete mode 100644 doc/5/core-classes/security/replace-user/index.md delete mode 100644 doc/5/core-classes/security/replace-user/snippets/replace-user-1.js delete mode 100644 doc/5/core-classes/security/role/index.md delete mode 100644 doc/5/core-classes/security/role/snippets/role-1.js delete mode 100644 doc/5/core-classes/security/scroll-profiles/index.md delete mode 100644 doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js delete mode 100644 doc/5/core-classes/security/scroll-users/index.md delete mode 100644 doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js delete mode 100644 doc/5/core-classes/security/search-profiles/index.md delete mode 100644 doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js delete mode 100644 doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js delete mode 100644 doc/5/core-classes/security/search-roles/index.md delete mode 100644 doc/5/core-classes/security/search-roles/snippets/search-roles-1.js delete mode 100644 doc/5/core-classes/security/search-roles/snippets/search-roles-2.js delete mode 100644 doc/5/core-classes/security/search-users/index.md delete mode 100644 doc/5/core-classes/security/search-users/snippets/search-users-1.js delete mode 100644 doc/5/core-classes/security/search-users/snippets/search-users-2.js delete mode 100644 doc/5/core-classes/security/update-credentials/index.md delete mode 100644 doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js delete mode 100644 doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js delete mode 100644 doc/5/core-classes/security/update-profile/index.md delete mode 100644 doc/5/core-classes/security/update-profile/snippets/update-profile-1.js delete mode 100644 doc/5/core-classes/security/update-role/index.md delete mode 100644 doc/5/core-classes/security/update-role/snippets/update-role-1.js delete mode 100644 doc/5/core-classes/security/update-user/index.md delete mode 100644 doc/5/core-classes/security/update-user/snippets/update-user-1.js delete mode 100644 doc/5/core-classes/security/user/index.md delete mode 100644 doc/5/core-classes/security/user/snippets/user-1.js delete mode 100644 doc/5/core-classes/security/validate-credentials/index.md delete mode 100644 doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js delete mode 100644 doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js delete mode 100644 doc/5/core-classes/user/add-profile/index.md delete mode 100644 doc/5/core-classes/user/add-profile/snippets/add-profile-1.js delete mode 100644 doc/5/core-classes/user/constructor/index.md delete mode 100644 doc/5/core-classes/user/constructor/snippets/constructor-1.js delete mode 100644 doc/5/core-classes/user/create/index.md delete mode 100644 doc/5/core-classes/user/create/snippets/create-1.js delete mode 100644 doc/5/core-classes/user/delete/index.md delete mode 100644 doc/5/core-classes/user/delete/snippets/delete-1.js delete mode 100644 doc/5/core-classes/user/get-profileids/index.md delete mode 100644 doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js delete mode 100644 doc/5/core-classes/user/get-profiles/index.md delete mode 100644 doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js delete mode 100644 doc/5/core-classes/user/index.md delete mode 100644 doc/5/core-classes/user/replace/index.md delete mode 100644 doc/5/core-classes/user/replace/snippets/replace-1.js delete mode 100644 doc/5/core-classes/user/save-restricted/index.md delete mode 100644 doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js delete mode 100644 doc/5/core-classes/user/save/index.md delete mode 100644 doc/5/core-classes/user/save/snippets/save-1.js delete mode 100644 doc/5/core-classes/user/set-content/index.md delete mode 100644 doc/5/core-classes/user/set-content/snippets/set-content-1.js delete mode 100644 doc/5/core-classes/user/set-credentials/index.md delete mode 100644 doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js delete mode 100644 doc/5/core-classes/user/set-profiles/index.md delete mode 100644 doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js delete mode 100644 doc/5/core-classes/user/update/index.md delete mode 100644 doc/5/core-classes/user/update/snippets/update-1.js delete mode 100644 doc/5/essentials/error-handling/index.md delete mode 100644 doc/5/essentials/error-handling/snippets/handling-errors-1.js delete mode 100644 doc/5/essentials/events/index.md delete mode 100644 doc/5/essentials/index.md delete mode 100644 doc/5/essentials/offline-tools/index.md delete mode 100644 doc/5/essentials/realtime-notifications/index.md delete mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-1.js delete mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-2.js delete mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-3.js delete mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-4.js delete mode 100644 doc/5/essentials/realtime-notifications/snippets/notifications-5.js delete mode 100644 doc/5/index.md diff --git a/doc/5/.keep b/doc/5/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/doc/5/core-classes/collection-mapping/apply/index.md b/doc/5/core-classes/collection-mapping/apply/index.md deleted file mode 100644 index 27b08c2f3..000000000 --- a/doc/5/core-classes/collection-mapping/apply/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: apply -description: CollectionMapping:apply ---- - -# apply - -Applies the new mapping to the collection. - ---- - -## apply([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns this `CollectionMapping` object to allow chaining. - ---- - -## Callback Response - -Returns the updated `CollectionMapping` object. - -## Usage - -<<< ./snippets/apply-1.js diff --git a/doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js b/doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js deleted file mode 100644 index 985b8ffa3..000000000 --- a/doc/5/core-classes/collection-mapping/apply/snippets/apply-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -dataMapping.apply(function (error, result) { - // called once the mapping action has been completed -}); - -// Using promises (NodeJS) -dataMapping.applyPromise().then(function (error, result) { - // resolved once the mapping action has been completed -}); diff --git a/doc/5/core-classes/collection-mapping/constructor/index.md b/doc/5/core-classes/collection-mapping/constructor/index.md deleted file mode 100644 index 611fd4ecb..000000000 --- a/doc/5/core-classes/collection-mapping/constructor/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -code: false -type: page -title: constructor -description: CollectionMapping:constructor -order: 1 ---- - -# CollectionMapping - -When creating a new collection in the persistent data storage layer, Kuzzle uses a default mapping. -This means that, by default, you won't be able to exploit the full capabilities of our persistent data storage layer (currently handled by [ElasticSearch](https://www.elastic.co/products/elasticsearch)), and your searches may suffer from below-average performance, depending on the amount of data you stored in a collection and the complexity of your database. - -The CollectionMapping object allows you to get the current mapping in a collection and to modify it if necessary. - -
-Once a field mapping has been set, it cannot be removed without reconstructing the collection. -
- ---- - -## CollectionMapping(Collection, [mapping]) - -| Arguments | Type | Description | -| ------------ | ----------------------------------- | --------------------------------- | -| `Collection` | [Collection](/sdk/js/5/core-classes/collection/) | An instantiated Collection object | -| `mapping` | JSON Object | Optional mapping | - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ------------- | ----------- | --------------------------------------------- | ------- | -| `headers` | JSON Object | Common headers for all sent documents. | get/set | -| `mapping` | object | Easy-to-understand list of mappings per field | get/set | - -**Note:** the `headers` property is inherited from the provided [Collection](/sdk/js/5/core-classes/collection/) object and can be overrided - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js b/doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js deleted file mode 100644 index a9c44fdee..000000000 --- a/doc/5/core-classes/collection-mapping/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - Constructors are not exposed in the JS/Node SDK. - CollectionMapping objects are returned by the method - Collection.getMapping - - You may also use the Collection.collectionMapping() method: - */ -var mapping = kuzzle.collection('collection', 'index').collectionMapping(); - -mapping = kuzzle.collection('collection', 'index').collectionMapping(mapping); diff --git a/doc/5/core-classes/collection-mapping/index.md b/doc/5/core-classes/collection-mapping/index.md deleted file mode 100644 index f26a7c1a0..000000000 --- a/doc/5/core-classes/collection-mapping/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: CollectionMapping -description: CollectionMapping documentation ---- diff --git a/doc/5/core-classes/collection-mapping/refresh/index.md b/doc/5/core-classes/collection-mapping/refresh/index.md deleted file mode 100644 index 4de73245a..000000000 --- a/doc/5/core-classes/collection-mapping/refresh/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: refresh -description: CollectionMapping:refresh ---- - -# refresh - -Instantiates a new CollectionMapping object with an up-to-date content. - ---- - -## refresh([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the updated `CollectionMapping` object. - -## Usage - -<<< ./snippets/refresh-1.js diff --git a/doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js b/doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js deleted file mode 100644 index c3bb95ade..000000000 --- a/doc/5/core-classes/collection-mapping/refresh/snippets/refresh-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS & Web Browser) -dataMapping.refresh(function (error, result) { - // called once the mapping has been retrieved from Kuzzle -}); - -// Using promises (NodeJS) -dataMapping.refreshPromise().then(result => { - // resolved once the mapping has been retrieved from Kuzzle -}); diff --git a/doc/5/core-classes/collection-mapping/set-headers/index.md b/doc/5/core-classes/collection-mapping/set-headers/index.md deleted file mode 100644 index e01fc3540..000000000 --- a/doc/5/core-classes/collection-mapping/set-headers/index.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -code: false -type: page -title: setHeaders -description: CollectionMapping:setHeaders ---- - -# setHeaders - -This is a helper function returning itself, allowing to easily chain calls. - ---- - -## setHeaders(content, [replace]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------------------------------------------------------- | -| `content` | JSON Object | New content | -| `replace` | boolean | true: replace the current content with the provided data, false: merge it | - -**Note:** by default, the `replace` argument is set to `false` - ---- - -## Return value - -Returns this `CollectionMapping` object to allow chaining. - -## Usage - -<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js deleted file mode 100644 index 4784cc0f5..000000000 --- a/doc/5/core-classes/collection-mapping/set-headers/snippets/set-headers-1.js +++ /dev/null @@ -1 +0,0 @@ -dataMapping.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/collection-mapping/set/index.md b/doc/5/core-classes/collection-mapping/set/index.md deleted file mode 100644 index cb26bf82a..000000000 --- a/doc/5/core-classes/collection-mapping/set/index.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -code: false -type: page -title: set -description: CollectionMapping:set ---- - -# set - -Adds or updates a field mapping. - -
-Changes made by this function won't be applied until you call the apply method -
- ---- - -## set(field, mapping) - -| Arguments | Type | Description | -| --------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `field` | string | Name of the field from which the mapping is to be added or updated | -| `mapping` | JSON Object | Mapping for this field, following the [Elasticsearch Mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/mapping.html) | - ---- - -## Return Value - -Returns this `CollectionMapping` object to allow chaining. - -## Usage - -<<< ./snippets/set-1.js diff --git a/doc/5/core-classes/collection-mapping/set/snippets/set-1.js b/doc/5/core-classes/collection-mapping/set/snippets/set-1.js deleted file mode 100644 index 05e06902a..000000000 --- a/doc/5/core-classes/collection-mapping/set/snippets/set-1.js +++ /dev/null @@ -1 +0,0 @@ -dataMapping.set('field', {type: 'string', index: 'analyzed', null_value: ''}); diff --git a/doc/5/core-classes/collection/collection-mapping/index.md b/doc/5/core-classes/collection/collection-mapping/index.md deleted file mode 100644 index b67ef427e..000000000 --- a/doc/5/core-classes/collection/collection-mapping/index.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -code: false -type: page -title: collectionMapping -description: Collection:collectionMapping ---- - -# collectionMapping - -Creates a new [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object, using its constructor. - ---- - -## collectionMapping([mapping]) - -| Arguments | Type | Description | -| --------- | ----------- | ---------------- | -| `mapping` | JSON Object | Optional mapping | - ---- - -## Return Value - -Returns the newly created [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object. - -## Usage - -<<< ./snippets/collection-mapping-1.js diff --git a/doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js b/doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js deleted file mode 100644 index 0486b4d62..000000000 --- a/doc/5/core-classes/collection/collection-mapping/snippets/collection-mapping-1.js +++ /dev/null @@ -1,6 +0,0 @@ -let dataMapping = kuzzle - .collection('collection', 'index') - .collectionMapping({someField: {type: 'string', index: 'analyzed'}}) - .apply(function (error, result) { - // called once the mapping action has been completed - }); diff --git a/doc/5/core-classes/collection/constructor/index.md b/doc/5/core-classes/collection/constructor/index.md deleted file mode 100644 index ee06952a1..000000000 --- a/doc/5/core-classes/collection/constructor/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -code: false -type: page -title: constructor -description: Collection:constructor -order: 1 ---- - -# Collection - -In Kuzzle, you manipulate documents and subscriptions, both related to collections. - -A collection is a set of data managed by Kuzzle. It acts like a data table for persistent documents, or like a room for pub/sub messages. - ---- - -## Collection(kuzzle, collection, index) - -| Arguments | Type | Description | -| ------------ | ------ | ------------------------------------------------------ | -| `kuzzle` | object | Kuzzle object | -| `collection` | string | The name of the collection you want to manipulate | -| `index` | string | Name of the index containing the collection | - -**Note:** We recommend you instantiate a Collection object by calling [Kuzzle.collection](/sdk/js/5/core-classes/kuzzle/collection) rather than using the constructor directly - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ------------- | ------ | -------------------------------------------------------- | ------- | -| `collection` | string | The name of the collection handled by this instance | get | -| `index` | object | Name of the index containing the collection | get | -| `headers` | object | Headers for all sent documents. | get/set | -| `kuzzle` | object | linked Kuzzle instance | get | - -**Note:** the `headers` property is inherited from the main `Kuzzle` object and can be overrided - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/collection/constructor/snippets/constructor-1.js b/doc/5/core-classes/collection/constructor/snippets/constructor-1.js deleted file mode 100644 index 2bb9fc323..000000000 --- a/doc/5/core-classes/collection/constructor/snippets/constructor-1.js +++ /dev/null @@ -1 +0,0 @@ -let dataCollection = new Collection(kuzzle, "my-collection", "my-index") diff --git a/doc/5/core-classes/collection/count/index.md b/doc/5/core-classes/collection/count/index.md deleted file mode 100644 index 81b6c18d0..000000000 --- a/doc/5/core-classes/collection/count/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: count -description: Collection:count ---- - -# count - -Returns the number of documents matching the provided set of filters. - -
-There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first. -
- ---- - -## count(filters, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | -| `filters` | JSON Object | Filters in [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl.html) format | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a count for the number of document matches as an `integer`. - -## Usage - -<<< ./snippets/count-1.js - -> Callback response: - -```json -12 -``` diff --git a/doc/5/core-classes/collection/count/snippets/count-1.js b/doc/5/core-classes/collection/count/snippets/count-1.js deleted file mode 100644 index 799d5a523..000000000 --- a/doc/5/core-classes/collection/count/snippets/count-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .count({}, function (err, res) { - // ... - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .countPromise({}) - .then(res => { - // ... - }); diff --git a/doc/5/core-classes/collection/count/snippets/count-2.js b/doc/5/core-classes/collection/count/snippets/count-2.js deleted file mode 100644 index a300bc6b4..000000000 --- a/doc/5/core-classes/collection/count/snippets/count-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -12 diff --git a/doc/5/core-classes/collection/create-document/index.md b/doc/5/core-classes/collection/create-document/index.md deleted file mode 100644 index c095a75c9..000000000 --- a/doc/5/core-classes/collection/create-document/index.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -code: false -type: page -title: createDocument -description: Collection:createDocument ---- - -# createDocument - -Create a new document in Kuzzle and instantiate a [Document](/sdk/js/5/core-classes/document/) object. - ---- - -## createDocument(Document, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------- | -| `Document` | object | [Document](/sdk/js/5/core-classes/document/) object | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## createDocument([id], content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------- | -| `id` | string | Optional document identifier | -| `content` | JSON object | Content of the document to create | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | -| `ifExist` | string | If the same document already exists: resolves to an `error`. Replaces the existing document if set to `replace` | `false` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a [Document](/sdk/js/5/core-classes/document/) object containing the newly created document. - -## Usage - -<<< ./snippets/create-document-1.js diff --git a/doc/5/core-classes/collection/create-document/snippets/create-document-1.js b/doc/5/core-classes/collection/create-document/snippets/create-document-1.js deleted file mode 100644 index a7ed362e7..000000000 --- a/doc/5/core-classes/collection/create-document/snippets/create-document-1.js +++ /dev/null @@ -1,16 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .createDocument('foobar', {title: 'foo', content: 'bar'}, {ifExist: 'replace'}, function (err, res) { - // callback called once the create action has been completed - // => the result is a Document object - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .createDocumentPromise('foobar', {title: 'foo', content: 'bar'}, {ifExist: 'replace'}) - .then(res => { - // promise resolved once the create action has been completed - // => the result is a Document object - }); diff --git a/doc/5/core-classes/collection/create/index.md b/doc/5/core-classes/collection/create/index.md deleted file mode 100644 index 31540b342..000000000 --- a/doc/5/core-classes/collection/create/index.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -code: false -type: page -title: create -description: Collection:create ---- - -# create - -Creates a new [collection](/core/1/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided `index`. - - - -You can also provide an optional data mapping that allow you to exploit the full capabilities of our -persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/mapping.html)). - -This method will only update the mapping if the collection already exists. - ---- - -## create([mapping], [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------- | -| `mapping` | JSON Object | Optional data mapping | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Ralue - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. - -## Usage - -<<< ./snippets/create-1.js - -> Callback response: - -```json -{ - "status": 200, - "error": null, - "requestId": "", - "controller": "collection", - "action": "create", - "collection": "", - "index": "index", - "volatile": null, - "result": { - "acknowledged": true - } -} -``` diff --git a/doc/5/core-classes/collection/create/snippets/create-1.js b/doc/5/core-classes/collection/create/snippets/create-1.js deleted file mode 100644 index bf012c39c..000000000 --- a/doc/5/core-classes/collection/create/snippets/create-1.js +++ /dev/null @@ -1,35 +0,0 @@ -// Optional: a mapping can be provided and will be -// applied when the collection is created -const mapping = { - properties: { - field1: { - type: '' - }, - field2: { - type: '' - } - } -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .create(mapping, function (error, result) { - // callback called once the create operation has completed - // => the result is a JSON object containing the raw Kuzzle response: - // { - // acknowledged: true - // } - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .createPromise(mapping) - .then(result => { - // promise resolved once the create operation has completed - // => the result is a JSON object containing the raw Kuzzle response: - // { - // acknowledged: true - // } - }); diff --git a/doc/5/core-classes/collection/create/snippets/create-2.js b/doc/5/core-classes/collection/create/snippets/create-2.js deleted file mode 100644 index 8d12b6f8a..000000000 --- a/doc/5/core-classes/collection/create/snippets/create-2.js +++ /dev/null @@ -1,14 +0,0 @@ -on -{ - "status": 200, - "error": null, - "requestId": "", - "controller": "collection", - "action": "create", - "collection": "", - "index": "index", - "volatile": null, - "result": { - "acknowledged": true - } -} diff --git a/doc/5/core-classes/collection/delete-document/index.md b/doc/5/core-classes/collection/delete-document/index.md deleted file mode 100644 index e394843be..000000000 --- a/doc/5/core-classes/collection/delete-document/index.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -code: false -type: page -title: deleteDocument -description: Collection:deleteDocument ---- - -# deleteDocument - -Delete a stored document, or all stored documents matching a search filter. - -
-There is a small delay between the time a document is deleted and it being reflected in the search layer (usually a couple of seconds). That means that a document that was just deleted may still be returned by this function at first. -
- ---- - -## deleteDocument(documentId, [options], [callback]) - -| Arguments | Type | Description | -| ------------ | ----------- | -------------------------- | -| `documentId` | string | Unique document identifier | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## deleteDocument(filters, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | -| `filters` | JSON object | Filters in [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/query-dsl.html) format | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns an `array` containing the ids of the deleted documents. - -## Usage - -<<< ./snippets/delete-document-1.js - -> Callback response: - -```json -["AVCoeBkimsySTKTfa8AX"] -``` diff --git a/doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js b/doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js deleted file mode 100644 index 0bbffc1c5..000000000 --- a/doc/5/core-classes/collection/delete-document/snippets/delete-document-1.js +++ /dev/null @@ -1,29 +0,0 @@ -// Deleting one document using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .deleteDocument('document unique ID', function (err, res) { - // callback called once the delete action has been completed - }); - -// Deleting one document using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .deleteDocumentPromise('document unique ID') - .then(res => { - // promises resolved once the delete action has been completed - }); - -// Deleting multiple documents using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .deleteDocument({filter: {equals: {title: 'foo'}}}, function (err, res) { - // callback called once the delete with query has been completed - }); - -// Deleting multiple documents using promises (NodeJS) - kuzzle - .collection('collection', 'index') - .deleteDocumentPromise({filter: {equals: {title: 'foo'}}}) - .then(res => { - // promise resolved once the delete by query has been completed - }); diff --git a/doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js b/doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js deleted file mode 100644 index fa8c9067b..000000000 --- a/doc/5/core-classes/collection/delete-document/snippets/delete-document-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -[ "AVCoeBkimsySTKTfa8AX" ] diff --git a/doc/5/core-classes/collection/delete-specifications/index.md b/doc/5/core-classes/collection/delete-specifications/index.md deleted file mode 100644 index c002c49e2..000000000 --- a/doc/5/core-classes/collection/delete-specifications/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: deleteSpecifications -description: Collection:deleteSpecifications ---- - -# deleteSpecifications - -Delete specifications linked to the collection object. - ---- - -## deleteSpecifications([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer indexation to return (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - -## Usage - -<<< ./snippets/delete-specifications-1.js - -> Callback response: - -```json -{ - "acknowledged": true -} -``` diff --git a/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js b/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js deleted file mode 100644 index f9634f346..000000000 --- a/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Deleting specifications using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .deleteSpecifications(function (err, res) { - // callback called once the delete action has been completed - }); - -// Deleting specifications using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .deleteSpecificationsPromise() - .then(res => { - // promises resolved once the delete action has been completed - }); diff --git a/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js b/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js deleted file mode 100644 index 02d519956..000000000 --- a/doc/5/core-classes/collection/delete-specifications/snippets/delete-specifications-2.js +++ /dev/null @@ -1,4 +0,0 @@ -on -{ - "acknowledged": true -} diff --git a/doc/5/core-classes/collection/document/index.md b/doc/5/core-classes/collection/document/index.md deleted file mode 100644 index 542d6c44c..000000000 --- a/doc/5/core-classes/collection/document/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: document -description: Collection:document ---- - -# document - -Creates a new [Document](/sdk/js/5/core-classes/document/) object, using its constructor. - ---- - -## document([id], [content]) - -| Arguments | Type | Description | -| --------- | ----------- | --------------------------- | -| `id` | string | Optional document unique ID | -| `content` | JSON object | Optional document content | - ---- - -## Return Value - -Returns the newly created [Document](/sdk/js/5/core-classes/document) object. - -## Usage - -<<< ./snippets/document-1.js diff --git a/doc/5/core-classes/collection/document/snippets/document-1.js b/doc/5/core-classes/collection/document/snippets/document-1.js deleted file mode 100644 index 49c67048a..000000000 --- a/doc/5/core-classes/collection/document/snippets/document-1.js +++ /dev/null @@ -1,4 +0,0 @@ -let document = kuzzle - .collection('collection', 'index') - .document('id', {some: 'content'}) - .save(); diff --git a/doc/5/core-classes/collection/fetch-document/index.md b/doc/5/core-classes/collection/fetch-document/index.md deleted file mode 100644 index c63060213..000000000 --- a/doc/5/core-classes/collection/fetch-document/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: fetchDocument -description: Collection:fetchDocument ---- - -# fetchDocument - -Retrieves a single stored document using its unique document ID, and returns it as a [Document](/sdk/js/5/core-classes/document/) object. - ---- - -## fetchDocument(documentId, [options], callback) - -| Arguments | Type | Description | -| ------------ | ----------- | ------------------------------ | -| `documentId` | string | Unique document identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a [Document](/sdk/js/5/core-classes/document/) object. - -## Usage - -<<< ./snippets/fetch-document-1.js diff --git a/doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js b/doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js deleted file mode 100644 index d82379b82..000000000 --- a/doc/5/core-classes/collection/fetch-document/snippets/fetch-document-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .fetchDocument('documentId', function (error, result) { - // result is a Document object - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .fetchDocumentPromise('documentId') - .then(result => { - // result is a Document object - }); diff --git a/doc/5/core-classes/collection/get-mapping/index.md b/doc/5/core-classes/collection/get-mapping/index.md deleted file mode 100644 index dacc65cc5..000000000 --- a/doc/5/core-classes/collection/get-mapping/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: getMapping -description: Collection:getMapping ---- - -# getMapping - -Retrieves the current mapping of this collection as a [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object. - ---- - -## getMapping([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a [CollectionMapping](/sdk/js/5/core-classes/collection-mapping/) object. - -## Usage - -<<< ./snippets/get-mapping-1.js diff --git a/doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js b/doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js deleted file mode 100644 index f75d8bf5a..000000000 --- a/doc/5/core-classes/collection/get-mapping/snippets/get-mapping-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .getMapping(function (error, result) { - // result is a CollectionMapping object - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .getMappingPromise() - .then(result => { - // result is a CollectionMapping object - }); diff --git a/doc/5/core-classes/collection/get-specifications/index.md b/doc/5/core-classes/collection/get-specifications/index.md deleted file mode 100644 index c69581602..000000000 --- a/doc/5/core-classes/collection/get-specifications/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: getSpecifications -description: Collection:getSpecifications ---- - -# getSpecifications - -Retrieves the specifications linked to the collection object. - ---- - -## getSpecifications([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - -## Usage - -<<< ./snippets/get-specifications-1.js - -> Callback response - -```json -{ - "validation": { - "strict": "true", - "fields": { - "foo": { - "mandatory": "true", - "type": "string", - "defaultValue": "bar" - } - } - }, - "index": "index", - "collection": "collection" -} -``` diff --git a/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js b/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js deleted file mode 100644 index 13e45d89b..000000000 --- a/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .getSpecifications(function (error, specifications) { - // specifications is a JSON object - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .getSpecificationsPromise() - .then(specifications => { - // specifications is a JSON object - }); diff --git a/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js b/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js deleted file mode 100644 index 9cc82d578..000000000 --- a/doc/5/core-classes/collection/get-specifications/snippets/get-specifications-2.js +++ /dev/null @@ -1,15 +0,0 @@ -on -{ - "validation": { - "strict": "true", - "fields": { - "foo": { - "mandatory": "true", - "type": "string", - "defaultValue": "bar" - } - } - }, - "index": "index", - "collection": "collection" -} diff --git a/doc/5/core-classes/collection/index.md b/doc/5/core-classes/collection/index.md deleted file mode 100644 index e8a690f15..000000000 --- a/doc/5/core-classes/collection/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: Collection -description: Collection documentation ---- diff --git a/doc/5/core-classes/collection/mcreate-document/index.md b/doc/5/core-classes/collection/mcreate-document/index.md deleted file mode 100644 index 5a1a539d9..000000000 --- a/doc/5/core-classes/collection/mcreate-document/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: mcreateDocument -description: Collection:mcreateDocument ---- - -# mCreateDocument - -Create the input [Documents](/sdk/js/5/core-classes/document/). - ---- - -## mCreateDocument(documents, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | -------------------------------------------------- | -| `documents` | Document[] | Array of [Document](/sdk/js/5/core-classes/document/) to create | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. -Can return a 206 partial error in cases where some documents could not be created. - -## Usage - -<<< ./snippets/mcreate-document-1.js - -> Callback response: - -```json -{ - "hits": [{ "first": "document" }, { "second": "document" }], - "total": 2 -} -``` diff --git a/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js b/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js deleted file mode 100644 index e8391da56..000000000 --- a/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var - Document = require('./src/Document'), - firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), - secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .mCreateDocument([firstDocument, secondDocument], function (error, result) { - // callback called once the mCreate operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .mCreateDocumentPromise([firstDocument, secondDocument]) - .then(result => { - // promise resolved once the mCreate operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js b/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js deleted file mode 100644 index 6fe98f89d..000000000 --- a/doc/5/core-classes/collection/mcreate-document/snippets/mcreate-document-2.js +++ /dev/null @@ -1,8 +0,0 @@ -on -{ - "hits": [ - {"first": "document"}, - {"second": "document"} - ], - "total": 2 -} diff --git a/doc/5/core-classes/collection/mcreate-or-replace-document/index.md b/doc/5/core-classes/collection/mcreate-or-replace-document/index.md deleted file mode 100644 index 4b23e9960..000000000 --- a/doc/5/core-classes/collection/mcreate-or-replace-document/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: mcreateOrReplaceDocument -description: Collection:mcreateOrReplaceDocument ---- - -# mCreateOrReplaceDocument - -Create or replace the input [Documents](/sdk/js/5/core-classes/document/). - ---- - -## mCreateOrReplaceDocument(documents, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | ------------------------------------------------------------- | -| `documents` | Document[] | Array of [Document](/sdk/js/5/core-classes/document/) to create or replace | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. -Can return a 206 partial error in cases where some documents could not be created or replaced. - -## Usage - -<<< ./snippets/mcreate-or-replace-document-1.js - -> Callback response: - -```json -{ - "hits": [{ "first": "document" }, { "second": "document" }], - "total": 2 -} -``` diff --git a/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js b/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js deleted file mode 100644 index 2a5d09fc1..000000000 --- a/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var - Document = require('./src/Document'), - firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), - secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .mCreateOrReplaceDocument([firstDocument, secondDocument], function (error, result) { - // callback called once the mCreateOrReplace operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .mCreateOrReplaceDocumentPromise([firstDocument, secondDocument]) - .then(result => { - // promise resolved once the mCreateOrReplace operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js b/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js deleted file mode 100644 index 6fe98f89d..000000000 --- a/doc/5/core-classes/collection/mcreate-or-replace-document/snippets/mcreate-or-replace-document-2.js +++ /dev/null @@ -1,8 +0,0 @@ -on -{ - "hits": [ - {"first": "document"}, - {"second": "document"} - ], - "total": 2 -} diff --git a/doc/5/core-classes/collection/mdelete-document/index.md b/doc/5/core-classes/collection/mdelete-document/index.md deleted file mode 100644 index 0700851c9..000000000 --- a/doc/5/core-classes/collection/mdelete-document/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: mdeleteDocument -description: Collection:mdeleteDocument ---- - -# mDeleteDocument - -Delete multiple [Documents](/sdk/js/5/core-classes/document/) according to the input IDs. - ---- - -## mDeleteDocument(documentIds, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | ----------------------------------- | -| `documentIds` | String[] | Array of IDs of documents to delete | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. -Can return a 206 partial error in cases where some documents could not be deleted. - -## Usage - -<<< ./snippets/mdelete-document-1.js - -> Callback response: - -```json -["doc1", "doc2"] -``` diff --git a/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js b/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js deleted file mode 100644 index 78f4c6666..000000000 --- a/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-1.js +++ /dev/null @@ -1,16 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .mDeleteDocument(['doc1', 'doc2'], function (error, result) { - // callback called once the mDelete operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .mDeleteDocument() - .then(result => { - // promise resolved once the mDelete operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js b/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js deleted file mode 100644 index ffd192655..000000000 --- a/doc/5/core-classes/collection/mdelete-document/snippets/mdelete-document-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -["doc1", "doc2"] diff --git a/doc/5/core-classes/collection/mget-document/index.md b/doc/5/core-classes/collection/mget-document/index.md deleted file mode 100644 index 57baa2a9d..000000000 --- a/doc/5/core-classes/collection/mget-document/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: mgetDocument -description: Collection:mgetDocument ---- - -# mGetDocument - -Get multiple [Documents](/sdk/js/5/core-classes/document/) according to the input document IDs. - ---- - -## mGetDocument(documentIds, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------- | -| `documentIds` | String[] | Array of IDs of documents to retrieve | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. - -## Usage - -<<< ./snippets/mget-document-1.js - -> Callback response: - -```json -{ - "hits": [ - { "_id": "doc1", "first": "document" }, - { "_id": "doc2", "second": "document" } - ], - "total": 2 -} -``` diff --git a/doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js b/doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js deleted file mode 100644 index 9e1aa5e2a..000000000 --- a/doc/5/core-classes/collection/mget-document/snippets/mget-document-1.js +++ /dev/null @@ -1,16 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .mGetDocument(['doc1', 'doc2'], function (error, result) { - // callback called once the mGet operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .mGetDocument() - .then(result => { - // promise resolved once the mGet operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js b/doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js deleted file mode 100644 index c06286b24..000000000 --- a/doc/5/core-classes/collection/mget-document/snippets/mget-document-2.js +++ /dev/null @@ -1,8 +0,0 @@ -on -{ - "hits": [ - {"_id": "doc1", "first": "document"}, - {"_id": "doc2", "second": "document"} - ], - "total": 2 -} diff --git a/doc/5/core-classes/collection/mreplace-document/index.md b/doc/5/core-classes/collection/mreplace-document/index.md deleted file mode 100644 index ed5cb19fe..000000000 --- a/doc/5/core-classes/collection/mreplace-document/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: mreplaceDocument -description: Collection:mreplaceDocument ---- - -# mReplaceDocument - -Replace the provided [Documents](/sdk/js/5/core-classes/document/). - ---- - -## mReplaceDocument(documents, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | --------------------------------------------------- | -| `documents` | Document[] | Array of [Document](/sdk/js/5/core-classes/document/) to replace | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. -Can return a 206 partial error in cases where documents could not be replaced. - -## Usage - -<<< ./snippets/mreplace-document-1.js - -> Callback response: - -```json -{ - "hits": [{ "first": "document" }, { "second": "document" }], - "total": 2 -} -``` diff --git a/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js b/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js deleted file mode 100644 index 39f54a680..000000000 --- a/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var - Document = require('./src/Document'), - firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), - secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .mReplaceDocument([firstDocument, secondDocument], function (error, result) { - // callback called once the mReplace operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .mReplaceDocument([firstDocument, secondDocument]) - .then(result => { - // promise resolved once the mReplace operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js b/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js deleted file mode 100644 index 6fe98f89d..000000000 --- a/doc/5/core-classes/collection/mreplace-document/snippets/mreplace-document-2.js +++ /dev/null @@ -1,8 +0,0 @@ -on -{ - "hits": [ - {"first": "document"}, - {"second": "document"} - ], - "total": 2 -} diff --git a/doc/5/core-classes/collection/mupdate-document/index.md b/doc/5/core-classes/collection/mupdate-document/index.md deleted file mode 100644 index f34f7c7f5..000000000 --- a/doc/5/core-classes/collection/mupdate-document/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: mupdateDocument -description: Collection:mupdateDocument ---- - -# mUpdateDocument - -Update the provided [Documents](/sdk/js/5/core-classes/document/). - ---- - -## mUpdateDocument(documents, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | --------------------------------------------------- | -| `documents` | Document[] | Array of [Documents](/sdk/js/5/core-classes/document/) to update | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. -Can return a 206 partial error in cases where documents could not be updated. - -## Usage - -<<< ./snippets/mupdate-document-1.js - -> Callback response: - -```json -{ - "hits": [{ "first": "document" }, { "second": "document" }], - "total": 2 -} -``` diff --git a/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js b/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js deleted file mode 100644 index 741c750a6..000000000 --- a/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var - Document = require('./src/Document'), - firstDocument = new Document(collection, 'doc1', {title: 'foo', content: 'bar'}), - secondDocument = new Document(collection, 'doc2', {title: 'foo', content: 'bar'}); - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .mUpdateDocument([firstDocument, secondDocument], function (error, result) { - // callback called once the mUpdate operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .mUpdateDocument([firstDocument, secondDocument]) - .then(result => { - // promise resolved once the mUpdate operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js b/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js deleted file mode 100644 index 6fe98f89d..000000000 --- a/doc/5/core-classes/collection/mupdate-document/snippets/mupdate-document-2.js +++ /dev/null @@ -1,8 +0,0 @@ -on -{ - "hits": [ - {"first": "document"}, - {"second": "document"} - ], - "total": 2 -} diff --git a/doc/5/core-classes/collection/publish-message/index.md b/doc/5/core-classes/collection/publish-message/index.md deleted file mode 100644 index d490b23a7..000000000 --- a/doc/5/core-classes/collection/publish-message/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: publishMessage -description: Collection:publishMessage ---- - -# publishMessage - -Publish a real-time message. - ---- - -## publishMessage(Document, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------- | -| `Document` | object | [Document](/sdk/js/5/core-classes/document/) object | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## publishMessage(content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------- | -| `content` | JSON Object | Content of the document to publish | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | ------------------------------------------------------------- | ------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a raw Kuzzle response in JSON format. - -## Usage - -<<< ./snippets/publish-message-1.js diff --git a/doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js b/doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js deleted file mode 100644 index d85010c11..000000000 --- a/doc/5/core-classes/collection/publish-message/snippets/publish-message-1.js +++ /dev/null @@ -1,3 +0,0 @@ -kuzzle - .collection('collection', 'index') - .publishMessage({foo: 'bar', baz: 'qux'}); diff --git a/doc/5/core-classes/collection/replace-document/index.md b/doc/5/core-classes/collection/replace-document/index.md deleted file mode 100644 index 18547e5d0..000000000 --- a/doc/5/core-classes/collection/replace-document/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: replaceDocument -description: Collection:replaceDocument ---- - -# replaceDocument - -Replace an existing document and return the updated version as a [Document](/sdk/js/5/core-classes/document/) object. - ---- - -## replaceDocument(documentId, content, [options], [callback]) - -| Arguments | Type | Description | -| ------------ | ----------- | --------------------------------- | -| `documentId` | string | Unique document identifier | -| `content` | JSON Object | Content of the document to create | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns an updated [Document](/sdk/js/5/core-classes/document/) object. - -## Usage - -<<< ./snippets/replace-document-1.js diff --git a/doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js b/doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js deleted file mode 100644 index 886ddad72..000000000 --- a/doc/5/core-classes/collection/replace-document/snippets/replace-document-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .replaceDocument('documentId', {title: 'foo', content: 'bar'}, function (error, result) { - // result is a Document object - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .replaceDocumentPromise('documentId', {title: 'foo', content: 'bar'}) - .then(result => { - // result is a Document object - }); diff --git a/doc/5/core-classes/collection/room/index.md b/doc/5/core-classes/collection/room/index.md deleted file mode 100644 index 892651950..000000000 --- a/doc/5/core-classes/collection/room/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -code: false -type: page -title: room -description: Collection:room ---- - -# room - -Creates a new [Room](/sdk/js/5/core-classes/room/) object, using its constructor. - ---- - -## room([options]) - -| Arguments | Type | Description | -| --------- | ------ | -------------------------- | -| `options` | object | Subscription configuration | - -## Options - -Provided options are passed directly to the [Room](/sdk/js/5/core-classes/room/) object constructor. - ---- - -## Return Value - -Returns the newly created [Room](/sdk/js/5/core-classes/room/) object. - -## Usage - -<<< ./snippets/room-1.js diff --git a/doc/5/core-classes/collection/room/snippets/room-1.js b/doc/5/core-classes/collection/room/snippets/room-1.js deleted file mode 100644 index 09dc3ff36..000000000 --- a/doc/5/core-classes/collection/room/snippets/room-1.js +++ /dev/null @@ -1,6 +0,0 @@ -let room = kuzzle - .collection('collection', 'index') - .room() - .renew({in: {field: ['some', 'new', 'filter']}}, function (err, res) { - // handle notifications - }); diff --git a/doc/5/core-classes/collection/scroll-specifications/index.md b/doc/5/core-classes/collection/scroll-specifications/index.md deleted file mode 100644 index 0a8209cb4..000000000 --- a/doc/5/core-classes/collection/scroll-specifications/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: scrollSpecifications -description: Collection:scrollSpecifications ---- - -# scrollSpecifications - -Returns a JSON object containing the next page of the scroll session, and the `scrollId` to be used in the next `scroll` action. -A scroll session is always initiated by a `searchSpecification` action with the `scroll` argument. - ---- - -## scrollSpecifications(scrollId, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------- | -| `scrollId` | string | The "scrollId" provided with the last scrollSpecifications response or from the initial searchSpecifications request | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `scroll` | string | Re-initializes the scroll session timeout to its value. If not defined, the scroll timeout is defaulted to a Kuzzle configuration | `undefined` | - -## Usage - -<<< ./snippets/scroll-specifications-1.js - -> Callback response - -```json -{ - "hits": [{ "first": "specification" }, { "second": "specification" }], - "total": 2 -} -``` diff --git a/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js b/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js deleted file mode 100644 index 7e766208a..000000000 --- a/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-1.js +++ /dev/null @@ -1,22 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .scrollSpecifications(scrollId, {scroll: '1m'}, function (err, res) { - res.hits.forEach(function (specification) { - console.log(specification); - }); - - res.total // Total specifications count - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .scrollSpecificationsPromise(scrollId, {scroll: '1m'}) - .then(res => { - res.hits.forEach(specification => { - console.log(specification); - }); - - res.total // Total specifications count - }); diff --git a/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js b/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js deleted file mode 100644 index 4a4171ac0..000000000 --- a/doc/5/core-classes/collection/scroll-specifications/snippets/scroll-specifications-2.js +++ /dev/null @@ -1,8 +0,0 @@ -on -{ - "hits": [ - {"first": "specification"}, - {"second": "specification"} - ], - "total": 2 -} diff --git a/doc/5/core-classes/collection/scroll/index.md b/doc/5/core-classes/collection/scroll/index.md deleted file mode 100644 index 18d5b092d..000000000 --- a/doc/5/core-classes/collection/scroll/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: scroll -description: Collection:scroll ---- - -# scroll - -Returns a [SearchResult](/sdk/js/5/core-classes/search-result/) object containing the next page of the scroll session, and the `scrollId` to be used in the next `scroll` action. -A scroll session is always initiated by a `search` action and including the `scroll` argument; more information below. - -
-There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first. -
- -
- To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search/). -
- ---- - -## scroll(scrollId, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | -| `scrollId` | string | The "scrollId" provided with the last scroll response or from the initial search request if it is the first scroll call | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `scroll` | string | Re-initializes the scroll session timeout to its value. If not defined, the scroll timeout is defaulted to a Kuzzle configuration | `undefined` | - ---- - -## Callback Response - -Returns an instantiated [SearchResult](/sdk/js/5/core-classes/search-result) object. - ---- - -## Usage - -<<< ./snippets/scroll-1.js diff --git a/doc/5/core-classes/collection/scroll/snippets/scroll-1.js b/doc/5/core-classes/collection/scroll/snippets/scroll-1.js deleted file mode 100644 index b3c99b51f..000000000 --- a/doc/5/core-classes/collection/scroll/snippets/scroll-1.js +++ /dev/null @@ -1,18 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .scroll(scrollId, {scroll: '1m'}, function (err, searchResult) { - searchResult.getDocuments().forEach(function (document) { - console.log(document.toString()); - }); - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .scrollPromise(scrollId, {scroll: '1m'}) - .then(searchResult => { - searchResult.getDocuments().forEach(document => { - console.log(document.toString()); - }); - }); diff --git a/doc/5/core-classes/collection/search-specifications/index.md b/doc/5/core-classes/collection/search-specifications/index.md deleted file mode 100644 index 4d52f516a..000000000 --- a/doc/5/core-classes/collection/search-specifications/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: searchSpecifications -description: Collection:searchSpecifications ---- - -# searchSpecifications - -Retrieves every specifications across indexes/collections according to the given filters. - ---- - -## searchSpecifications(filters, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `filters` | JSON object | Search request body, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-body.html) format.
If given an empty object, matches all specifications across index/collections | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `from` | number | Provide the starting offset of the request (used to paginate results) | `0` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | -| `size` | number | Provide the maximum number of results of the request (used to paginate results) | `10` | - -## Usage - -<<< ./snippets/search-specifications-1.js - -> Callback response - -```json -{ - "hits": [{ "first": "specification" }, { "second": "specification" }], - "total": 2, - "scrollId": "foobar" -} -``` diff --git a/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js b/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js deleted file mode 100644 index 2f52e225a..000000000 --- a/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-1.js +++ /dev/null @@ -1,33 +0,0 @@ -const - filters = { - match_all: { - boost: 1 - } - }, - options= { - from: 0, - size: 20 - }; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .searchSpecifications(filters, options, function (err, res) { - res.hits.forEach(function (specification) { - console.log(specification); - }); - - res.total // Total specifications count - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .searchSpecificationsPromise(filters, options) - .then(res => { - res.hits.forEach(specification => { - console.log(specification); - }); - - res.total // Total specifications count - }); diff --git a/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js b/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js deleted file mode 100644 index 181748ef2..000000000 --- a/doc/5/core-classes/collection/search-specifications/snippets/search-specifications-2.js +++ /dev/null @@ -1,9 +0,0 @@ -on -{ - "hits": [ - {"first": "specification"}, - {"second": "specification"} - ], - "total": 2, - "scrollId": "foobar" -} diff --git a/doc/5/core-classes/collection/search/index.md b/doc/5/core-classes/collection/search/index.md deleted file mode 100644 index 609954730..000000000 --- a/doc/5/core-classes/collection/search/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: search -description: Collection:search ---- - -# search - -Executes a search on the collection. - -
-There is a small delay between the time a document is created and its availability in our search layer (usually a couple of seconds). That means that a document that was just created might not be returned by this function at first. -
- -## Processing large data sets - -When processing a large number of documents (i.e. more than 1000), using `search` is not always the best option. - -Pagination of results can be done by using the from and size but the cost becomes prohibitive when deep pagination is reached. In fact, Elasticsearch, Kuzzle's embedded database, limits results to 10,000 records by default. - -Instead, the recommended way to process a large number of documents is to use [`Collection.scroll`](/sdk/js/5/core-classes/collection/scroll/) or, easier, [`SearchResult.fetchNext`](/sdk/js/5/core-classes/search-result/fetch-next). - -See [`SearchResult.fetchNext`](/sdk/js/5/core-classes/search-result/fetch-next/#how-to-process-every-document-of-a-collection) for an example of how to process every document of a collection. - ---- - -## search(body, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `body` | JSON object | Search request body, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/search-request-body.html) format.
If given an empty object, matches all documents in the collection | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `from` | number | Provide the starting offset of the request (used to paginate results) | `0` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | -| `size` | number | Provide the maximum number of results of the request (used to paginate results) | `10` | - -
- To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search/). -
- ---- - -## Callback Response - -Returns an instance of [SearchResult](/sdk/js/5/core-classes/search-result). - -## Usage - -<<< ./snippets/search-1.js diff --git a/doc/5/core-classes/collection/search/snippets/search-1.js b/doc/5/core-classes/collection/search/snippets/search-1.js deleted file mode 100644 index 7f99a05f8..000000000 --- a/doc/5/core-classes/collection/search/snippets/search-1.js +++ /dev/null @@ -1,61 +0,0 @@ -const - body = { - query: { - bool: { - must: [ - { - terms: {status: ['idle', 'wantToHire', 'toHire', 'riding']} - }, - { - term: {type: 'cab'} - }, - { - geo_distance: { - distance: '10km', - pos: {lat: '48.8566140', lon: '2.352222'} - } - } - ] - } - }, - sort: [ - 'status', - { - _geo_distance : { - pos: {lat: '48.8566140', lon: '2.352222'}, - order : "asc" - } - }, - {date: "desc"} - ], - aggregations: { - aggs_name: { - terms: { - field: "field_name" - } - } - } - }, - options = { - from: 0, - size: 20 - }; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .search(body, options, function (err, searchResult) { - searchResult.getDocuments().forEach(function(document) { - console.log(document.toString()); - }); - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .searchPromise(body, options) - .then(searchResult => { - searchResult.getDocuments().forEach(document => { - console.log(document.toString()); - }); - }); diff --git a/doc/5/core-classes/collection/set-headers/index.md b/doc/5/core-classes/collection/set-headers/index.md deleted file mode 100644 index a515777c0..000000000 --- a/doc/5/core-classes/collection/set-headers/index.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -code: false -type: page -title: setHeaders -description: Collection:setHeaders ---- - -# setHeaders - -This is a helper function returning itself, allowing to easily set headers while chaining calls. - ---- - -## setHeaders(content, [replace]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------------------------------------------------------- | -| `content` | JSON Object | New content | -| `replace` | boolean | true: replace the current content with the provided data, false: merge it | - -**Note:** by default, the `replace` argument is set to `false` - ---- - -## Return value - -Returns the `Collection` object to allow chaining. - -## Usage - -<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js deleted file mode 100644 index 73417e559..000000000 --- a/doc/5/core-classes/collection/set-headers/snippets/set-headers-1.js +++ /dev/null @@ -1,6 +0,0 @@ -kuzzle - .collection('collection', 'index') - .setHeaders({ - someContent: 'someValue', - volatile: { someVolatileData: ['with', 'some', 'values']} - }, true); diff --git a/doc/5/core-classes/collection/subscribe/index.md b/doc/5/core-classes/collection/subscribe/index.md deleted file mode 100644 index a6ca04c71..000000000 --- a/doc/5/core-classes/collection/subscribe/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: subscribe -description: Collection:subscribe ---- - -# subscribe - -Subscribes to this collection with a set of filters. - -The provided callback will be called everytime a [notification](/sdk/js/5/essentials/realtime-notifications) is received from Kuzzle. - ---- - -## subscribe(filters, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------------------------------------- | -| `filters` | JSON Object | [Koncorde Filters](/core/1/koncorde) | -| `options` | object | (Optional) Subscription configuration. Passed to the Room constructor. | -| `callback` | function | Callback to call every time a notification is received on this subscription | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `scope` | string | Filter document notifications depending on their scope status. You may receive entering documents (scope: `in`), leaving documents (scope: `out`), all documents changes (scope: `all`) or filter these notifications completely (scope: `none`). This filter does not affect pub/sub messages or user events. | `all` | -| `state` | string | Filter document notifications depending on the state of the modifying request. You may receive real-time notifications when a document is about to be changed (state: `pending`), or be notified when the change has been fully written in the database (state: `done`), or both (state: `all`). This filter does not affect pub/sub messages or user events. | `done` | -| `subscribeToSelf` | boolean | (Don't) subscribe to notifications fired as a consequence of our own queries | `true` | -| `users` | string | Filter notifications fired upon a user entering the room (user: `in`), leaving the room (user: `out`), or both (user: `all`). Setting this variable to `none` prevents receiving these notifications | `none` | - -The `options` object is directly passed to the Room constructor. -See the [Room object](/sdk/js/5/core-classes/room/) documentation for more information about these options and notifications. - ---- - -## Return Value - -Returns an object exposing the following method: - `onDone(callback)` - -The `callback` argument is called when the subscription ends, either successfully or with an error. - -## Usage - -<<< ./snippets/subscribe-1.js diff --git a/doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js b/doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js deleted file mode 100644 index 4260d9623..000000000 --- a/doc/5/core-classes/collection/subscribe/snippets/subscribe-1.js +++ /dev/null @@ -1,10 +0,0 @@ -kuzzle - .collection('collection', 'index') - .subscribe({equals: {title: 'foo'}}, function (error, result) { - // called each time a new notification on this filter is received - // check the Room/Notifications section of this documentation - // to get notification examples - }) - .onDone(function (err, roomObject) { - // Handles the subscription result. Can be chained. - }); diff --git a/doc/5/core-classes/collection/truncate/index.md b/doc/5/core-classes/collection/truncate/index.md deleted file mode 100644 index e36c24832..000000000 --- a/doc/5/core-classes/collection/truncate/index.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -code: false -type: page -title: truncate -description: Collection:truncate ---- - -# truncate - -Truncate the collection, removing all stored documents but keeping all associated mappings. - -This method is a lot faster than removing all documents using multiple delete requests. - ---- - -## truncate([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. - -## Usage - -<<< ./snippets/truncate-1.js - -> Callback response: - -```json -{ - "status": 200, - "error": null, - "requestId": "8fdc0efb-6fc7-427d-a3a1-fd8cf5eabc20", - "controller": "admin", - "action": "truncateCollection", - "collection": "name of the truncated collection", - "index": "name of the index containing the truncated collection", - "volatile": {}, - "state": "done", - "result": { "acknowledged": true } -} -``` diff --git a/doc/5/core-classes/collection/truncate/snippets/truncate-1.js b/doc/5/core-classes/collection/truncate/snippets/truncate-1.js deleted file mode 100644 index dd29f22ca..000000000 --- a/doc/5/core-classes/collection/truncate/snippets/truncate-1.js +++ /dev/null @@ -1,16 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .truncate(function (error, result) { - // callback called once the truncate operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); - -// Using promises (NodeJS only) -kuzzle - .collection('collection', 'index') - .truncatePromise() - .then(result => { - // promise resolved once the truncate operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/collection/truncate/snippets/truncate-2.js b/doc/5/core-classes/collection/truncate/snippets/truncate-2.js deleted file mode 100644 index 467755810..000000000 --- a/doc/5/core-classes/collection/truncate/snippets/truncate-2.js +++ /dev/null @@ -1,13 +0,0 @@ -on -{ - "status": 200, - "error": null, - "requestId": "8fdc0efb-6fc7-427d-a3a1-fd8cf5eabc20", - "controller": "admin", - "action": "truncateCollection", - "collection": "name of the truncated collection", - "index": "name of the index containing the truncated collection", - "volatile": {}, - "state": "done", - "result": { "acknowledged": true } -} diff --git a/doc/5/core-classes/collection/update-document/index.md b/doc/5/core-classes/collection/update-document/index.md deleted file mode 100644 index 8892252d8..000000000 --- a/doc/5/core-classes/collection/update-document/index.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -code: false -type: page -title: updateDocument -description: Collection:updateDocument ---- - -# updateDocument - -Update parts of a document, by replacing some fields or adding new ones. -Note that you cannot remove fields this way: missing fields will simply be left unchanged. - ---- - -## updateDocument(documentId, content, [options], [callback]) - -| Arguments | Type | Description | -| ------------ | ----------- | --------------------------------- | -| `documentId` | string | Unique document identifier | -| `content` | JSON object | Content of the document to create | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | -| `retryOnConflict` | int | Number of retries to attempt before rejecting this update because of a cluster sync conflict | `0` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - ---- - -## Callback Response - -Returns an up-to-date [Document](/sdk/js/5/core-classes/document/) object. - -## Usage - -<<< ./snippets/update-document-1.js diff --git a/doc/5/core-classes/collection/update-document/snippets/update-document-1.js b/doc/5/core-classes/collection/update-document/snippets/update-document-1.js deleted file mode 100644 index 2bd52470f..000000000 --- a/doc/5/core-classes/collection/update-document/snippets/update-document-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .updateDocument('documentId', {title: 'foo', content: 'bar'}, function (error, result) { - // result is a Document object - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .updateDocumentPromise('documentId', {title: 'foo', content: 'bar'}) - .then(result => { - // result is a Document object - }); diff --git a/doc/5/core-classes/collection/update-specifications/index.md b/doc/5/core-classes/collection/update-specifications/index.md deleted file mode 100644 index 354ccc70b..000000000 --- a/doc/5/core-classes/collection/update-specifications/index.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -code: false -type: page -title: updateSpecifications -description: Collection:updateSpecifications ---- - -# updateSpecifications - -Update parts of a specification, by replacing some fields or adding new ones. -Note that you cannot remove fields this way: missing fields will simply be left unchanged. - ---- - -## updateSpecifications(content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------- | -| `content` | JSON object | Content of the specification to update | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | -| `retryOnConflict` | int | Number of retries to attempt before rejecting this update because of a cluster sync conflict | `0` | - ---- - -## Return Value - -Returns the `Collection` object to allow chaining. - -## Usage - -<<< ./snippets/update-specifications-1.js - -> Callback response - -```json -{ - "index": { - "collection": { - "strict": "true", - "fields": { - "foo": { - "mandatory": "true", - "type": "string", - "defaultValue": "bar" - } - } - } - } -} -``` diff --git a/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js b/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js deleted file mode 100644 index ea849af77..000000000 --- a/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-1.js +++ /dev/null @@ -1,25 +0,0 @@ -var specifications = { - strict: 'true', - fields: { - foo: { - mandatory: true, - type: 'string', - defaultValue: 'bar' - } - } -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .updateSpecifications(specifications, function (err, res) { - // result is a JSON object - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .updateSpecificationsPromise(specifications) - .then(res => { - // result is a JSON object - }); diff --git a/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js b/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js deleted file mode 100644 index 97b002288..000000000 --- a/doc/5/core-classes/collection/update-specifications/snippets/update-specifications-2.js +++ /dev/null @@ -1,15 +0,0 @@ -on -{ - "index": { - "collection": { - "strict":"true", - "fields": { - "foo": { - "mandatory": "true", - "type": "string", - "defaultValue": "bar" - } - } - } - } -} diff --git a/doc/5/core-classes/collection/validate-specifications/index.md b/doc/5/core-classes/collection/validate-specifications/index.md deleted file mode 100644 index d85c48fcf..000000000 --- a/doc/5/core-classes/collection/validate-specifications/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: validateSpecifications -description: Collection:validateSpecifications ---- - -# validateSpecifications - -Validate a specification. - ---- - -## validateSpecifications(content, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------- | -| `content` | JSON object | Content of the specification to validate | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a boolean indicating whether or not the input specifications is valid or not. - -## Usage - -<<< ./snippets/validate-specifications-1.js diff --git a/doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js b/doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js deleted file mode 100644 index a29110176..000000000 --- a/doc/5/core-classes/collection/validate-specifications/snippets/validate-specifications-1.js +++ /dev/null @@ -1,25 +0,0 @@ -var specifications = { - strict: 'true', - fields: { - foo: { - mandatory: true, - type: 'string', - defaultValue: 'bar' - } - } -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .collection('collection', 'index') - .validateSpecifications(specifications, function (err, isValid) { - // isValid is a boolean - }); - -// Using promises (NodeJS) -kuzzle - .collection('collection', 'index') - .validateSpecificationsPromise(specifications) - .then(isValid => { - // isValid is a boolean - }); diff --git a/doc/5/core-classes/document/constructor/index.md b/doc/5/core-classes/document/constructor/index.md deleted file mode 100644 index cb8b7b66b..000000000 --- a/doc/5/core-classes/document/constructor/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: constructor -description: Document:constructor -order: 1 ---- - -# Document - -Kuzzle handles two types of documents: realtime messages and stored documents. Document is the object representation of one of these document types. - ---- - -## Document(Collection, [documentId], [content]) - -| Arguments | Type | Description | -| ------------ | ----------- | --------------------------------------------------- | -| `Collection` | object | An instantiated Collection object | -| `content` | JSON Object | Initializes this document with the provided content | -| `documentId` | string | ID of an existing document. | - -**Note:** this constructor won't make any call to Kuzzle. When providing only a document ID, the `refresh` method should be called to retrieve the corresponding document content. - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ------------- | ----------- | ----------------------------------------------- | ------- | -| `collection` | string | The collection associated to this document | get | -| `content` | JSON Object | The content of the document | get/set | -| `headers` | JSON Object | Common headers for all sent documents. | get/set | -| `id` | string | Unique document identifier | get/set | -| `meta` | JSON Object | Document metadata | get | -| `version` | integer | Current document version | get | - -**Notes:** - -- setting a new value to the `content` property is equivalent to calling `setContent(data, false)` -- setting a new value to the `id` property will force this value for this document -- the `headers` property is inherited from the provided `Collection` object and can be overrided - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/document/constructor/snippets/constructor-1.js b/doc/5/core-classes/document/constructor/snippets/constructor-1.js deleted file mode 100644 index 18248e986..000000000 --- a/doc/5/core-classes/document/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - Constructors are not exposed in the JS/Node SDK. - Document objects are returned by various Collection methods. - - You may also use the Collection.document() method: - */ -var document = kuzzle.collection('collection', 'index').document('id'); - -document = kuzzle - .collection('collection', 'index') - .document({content: 'some content'}); - -document = kuzzle - .collection('collection', 'index') - .document('id', {content: 'some content'}); diff --git a/doc/5/core-classes/document/delete/index.md b/doc/5/core-classes/document/delete/index.md deleted file mode 100644 index db330b06d..000000000 --- a/doc/5/core-classes/document/delete/index.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -code: false -type: page -title: delete -description: Document:delete ---- - -# delete - -Deletes this document in Kuzzle. - ---- - -## delete([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Callback Response - -Returns a string containing the ID of the deleted document. - -## Usage - -<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/document/delete/snippets/delete-1.js b/doc/5/core-classes/document/delete/snippets/delete-1.js deleted file mode 100644 index 6236c9c6f..000000000 --- a/doc/5/core-classes/document/delete/snippets/delete-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -document.delete(function (error, result) { - // called once the delete action has been completed -}); - -// Using promises (NodeJS) -document.deletePromise().then(result => { - // called once the delete action has been completed -}); diff --git a/doc/5/core-classes/document/exists/index.md b/doc/5/core-classes/document/exists/index.md deleted file mode 100644 index 3eba069fc..000000000 --- a/doc/5/core-classes/document/exists/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: exists -description: Document:exists ---- - -# exists - -Checks if the document exists in Kuzzle. - ---- - -## exists([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Return a boolean indicating whether or not the document exists in Kuzzle. - -## Usage - -<<< ./snippets/exists-1.js diff --git a/doc/5/core-classes/document/exists/snippets/exists-1.js b/doc/5/core-classes/document/exists/snippets/exists-1.js deleted file mode 100644 index 4023ef1fc..000000000 --- a/doc/5/core-classes/document/exists/snippets/exists-1.js +++ /dev/null @@ -1,4 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -document.exists(function (error, exists) { - // called once the exists check has been completed -}); diff --git a/doc/5/core-classes/document/index.md b/doc/5/core-classes/document/index.md deleted file mode 100644 index 83afce740..000000000 --- a/doc/5/core-classes/document/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: Document -description: Document documentation ---- diff --git a/doc/5/core-classes/document/publish/index.md b/doc/5/core-classes/document/publish/index.md deleted file mode 100644 index 0b8683c19..000000000 --- a/doc/5/core-classes/document/publish/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: publish -description: Document:publish ---- - -# publish - -Publishes the content of this document as a real-time message. - ---- - -## publish([options]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | ------------------------------------------------------------- | ------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns this `Document` object to allow chaining. - -## Usage - -<<< ./snippets/publish-1.js diff --git a/doc/5/core-classes/document/publish/snippets/publish-1.js b/doc/5/core-classes/document/publish/snippets/publish-1.js deleted file mode 100644 index 984a19847..000000000 --- a/doc/5/core-classes/document/publish/snippets/publish-1.js +++ /dev/null @@ -1 +0,0 @@ -document.publish(); diff --git a/doc/5/core-classes/document/refresh/index.md b/doc/5/core-classes/document/refresh/index.md deleted file mode 100644 index 946629af3..000000000 --- a/doc/5/core-classes/document/refresh/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: refresh -description: Document:refresh ---- - -# refresh - -Creates a new `Document` object with the last version of this document stored in Kuzzle. - ---- - -## refresh([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Return a new `Document` object containing the last document version. - -## Usage - -<<< ./snippets/refresh-1.js diff --git a/doc/5/core-classes/document/refresh/snippets/refresh-1.js b/doc/5/core-classes/document/refresh/snippets/refresh-1.js deleted file mode 100644 index 719626798..000000000 --- a/doc/5/core-classes/document/refresh/snippets/refresh-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -document.refresh(function (error, result) { - // called once the refresh action has been completed -}); - -// Using promises (NodeJS) -document.refreshPromise().then(result => { - // called once the refresh action has been completed -}); diff --git a/doc/5/core-classes/document/save/index.md b/doc/5/core-classes/document/save/index.md deleted file mode 100644 index 07da6e4be..000000000 --- a/doc/5/core-classes/document/save/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: save -description: Document:save ---- - -# save - -Saves this document into Kuzzle. - -If this is a new document, this function will create it in Kuzzle and the `id` property will be made available. -Otherwise, this method will replace the latest version of the document in Kuzzle with the content of this current object. - ---- - -## save([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns this `Document` object to allow chaining. - ---- - -## Callback Response - -Return this `Document` object once the document has been saved. - -## Usage - -<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/document/save/snippets/save-1.js b/doc/5/core-classes/document/save/snippets/save-1.js deleted file mode 100644 index d16b8379e..000000000 --- a/doc/5/core-classes/document/save/snippets/save-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -document.save(function (error, result) { - // called once the save action has been completed -}); - -// Using promises (NodeJS) -document.savePromise().then(result => { - // called once the save action has been completed -}); diff --git a/doc/5/core-classes/document/set-content/index.md b/doc/5/core-classes/document/set-content/index.md deleted file mode 100644 index a0dfd6396..000000000 --- a/doc/5/core-classes/document/set-content/index.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -code: false -type: page -title: setContent -description: Document:setContent ---- - -# setContent - -Replaces the current content with new data. -This is a helper function returning a reference to itself so that you can easily chain calls. - -
-Changes made by this function won't be applied until the save method is called -
- ---- - -## setContent(data, [replace]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------------------------------------------------------- | -| `data` | JSON Object | New content | -| `replace` | boolean | true: replace the current content with the provided data, false: merge it | - -**Note:** by default, the `replace` argument is set to `false` - ---- - -## Return Value - -Returns this `Document` object to allow chaining. - -## Usage - -<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/document/set-content/snippets/set-content-1.js b/doc/5/core-classes/document/set-content/snippets/set-content-1.js deleted file mode 100644 index 94179832c..000000000 --- a/doc/5/core-classes/document/set-content/snippets/set-content-1.js +++ /dev/null @@ -1 +0,0 @@ -document.setContent({newContent: 'someValue'}, true); diff --git a/doc/5/core-classes/document/set-headers/index.md b/doc/5/core-classes/document/set-headers/index.md deleted file mode 100644 index 11907035e..000000000 --- a/doc/5/core-classes/document/set-headers/index.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -code: false -type: page -title: setHeaders -description: Document:setHeaders ---- - -# setHeaders - -This is a helper function returning itself, allowing to easily chain calls. - ---- - -## setHeaders(content, [replace]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------------------------------------------------------- | -| `content` | JSON Object | New content | -| `replace` | boolean | true: replace the current content with the provided data, false: merge it | - -**Note:** by default, the `replace` argument is set to `false` - ---- - -## Return value - -Returns this `Document` object to allow chaining. - -## Usage - -<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/document/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/document/set-headers/snippets/set-headers-1.js deleted file mode 100644 index 42f05bc62..000000000 --- a/doc/5/core-classes/document/set-headers/snippets/set-headers-1.js +++ /dev/null @@ -1 +0,0 @@ -document.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/document/subscribe/index.md b/doc/5/core-classes/document/subscribe/index.md deleted file mode 100644 index 93b07d030..000000000 --- a/doc/5/core-classes/document/subscribe/index.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -code: false -type: page -title: subscribe -description: Document:subscribe ---- - -# subscribe - -Listens to changes occuring in this document. -Throws an error if this document has not yet been created in Kuzzle. - -The provided callback will be called everytime a [notification](/sdk/js/5/essentials/realtime-notifications) is received from Kuzzle. - ---- - -## subscribe([options], callback) - -| Arguments | Type | Description | -| ---------- | -------- | ---------------------------------------------------------------------------------- | -| `options` | object | Subscription configuration | -| `callback` | function | Callback that will be called each time a change has been detected on this document | - ---- - -## Options - -Options are directly passed to the [Room](/sdk/js/5/core-classes/room/) object constructor. - ---- - -## Return Value - -Returns an object exposing the following method: - `onDone(callback)` - -The `callback` argument is called when the subscription ends, either successfully or with an error. - -## Usage - -<<< ./snippets/subscribe-1.js diff --git a/doc/5/core-classes/document/subscribe/snippets/subscribe-1.js b/doc/5/core-classes/document/subscribe/snippets/subscribe-1.js deleted file mode 100644 index a412af97c..000000000 --- a/doc/5/core-classes/document/subscribe/snippets/subscribe-1.js +++ /dev/null @@ -1,15 +0,0 @@ -document - .subscribe(function (error, notification) { - // called each time a change occurs on this document - }) - .onDone(function (error, roomObject) { - // Handles the subscription result - }); - -document - .subscribe({subscribeToSelf: true, volatile: { myId: 'someId'}}, function (error, notification) { - // called each time a change occurs on this document - }) - .onDone(function (error, roomObject) { - // Handles the subscription result - }); diff --git a/doc/5/core-classes/index.md b/doc/5/core-classes/index.md deleted file mode 100644 index 736c461bc..000000000 --- a/doc/5/core-classes/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -code: false -type: branch -order: 100 -title: Core Classes -description: Javascript SDK v5.x core classes ---- diff --git a/doc/5/core-classes/kuzzle/add-listener/index.md b/doc/5/core-classes/kuzzle/add-listener/index.md deleted file mode 100644 index e85a6b101..000000000 --- a/doc/5/core-classes/kuzzle/add-listener/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: addListener -description: Kuzzle:addListener ---- - -# addListener - -Adds a listener to an event. When an event is fired, listeners are called in the order that they are added. - ---- - -## addListener(event, listener) - -| Arguments | Type | Description | -| ---------- | -------- | -------------------------------------------------------------------------------- | -| `event` | string | One of the event described in the `Event Handling` section of this documentation | -| `listener` | function | The function to call each time one of the registered event is fired | - ---- - -## Return Value - -Returns the `Kuzzle` object to allow chaining. - -## Usage - -<<< ./snippets/add-listener-1.js diff --git a/doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js b/doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js deleted file mode 100644 index 78860fa65..000000000 --- a/doc/5/core-classes/kuzzle/add-listener/snippets/add-listener-1.js +++ /dev/null @@ -1,4 +0,0 @@ - var callback = function () { - // Actions to perform when receiving a 'connected' global event - }; - kuzzle.addListener('connected', callback); diff --git a/doc/5/core-classes/kuzzle/check-token/index.md b/doc/5/core-classes/kuzzle/check-token/index.md deleted file mode 100644 index bfc6698ea..000000000 --- a/doc/5/core-classes/kuzzle/check-token/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: checkToken -description: Kuzzle:checkToken ---- - -# checkToken - -> Callback response if the token is valid: - -```json -{ - "expiresAt": 1454588077399, - "valid": true -} -``` - -> Callback response if the token is invalid: - -```json -{ - "valid": false, - "state": "" -} -``` - -Checks the validity of a JSON Web Token. - -
-This method is non-queuable, meaning that during offline mode, it will be discarded and the callback return an error. -
- ---- - -## checkToken(token, callback) - -| Arguments | Type | Description | -| ---------- | -------- | ------------------------------ | -| `token` | string | The token to check | -| `callback` | function | Callback handling the response | - -**Note:** this method sends an unauthenticated API call to Kuzzle, meaning it ignores the JWT Token property, even if it has been set. - ---- - -## Callback Response - -Returns a JSON object with a `valid` boolean property. -If the token is valid, an `expiresAt` property is set with the expiration timestamp. If not, a `state` property is set explaining why the token is invalid. - -## Usage - -<<< ./snippets/check-token-1.js diff --git a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js deleted file mode 100644 index 6be6881e1..000000000 --- a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.checkToken(token, function (err, res) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle.checkTokenPromise(token) - .then(res => { - // ... - }); diff --git a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js deleted file mode 100644 index 4b1fde6f2..000000000 --- a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "expiresAt": 1454588077399, - "valid": true -} diff --git a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js b/doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js deleted file mode 100644 index 6ee92f464..000000000 --- a/doc/5/core-classes/kuzzle/check-token/snippets/check-token-3.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "valid": false, - "state": "" -} diff --git a/doc/5/core-classes/kuzzle/collection/index.md b/doc/5/core-classes/kuzzle/collection/index.md deleted file mode 100644 index ae8febbf0..000000000 --- a/doc/5/core-classes/kuzzle/collection/index.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -code: false -type: page -title: collection -description: Kuzzle:collection ---- - -# collection - -Instantiates a new [Collection](/sdk/js/5/core-classes/collection) object. - ---- - -## collection(collection, [index]) - -| Arguments | Type | Description | -| ------------ | ------ | ------------------------------------------------------ | -| `collection` | string | The name of the collection you want to manipulate | -| `index` | string | The name of the index containing the collection | - -If no `index` is provided, the factory will take the default index set in the main Kuzzle SDK instance. If no default index has been set, an error is thrown. - -The `index` argument takes precedence over the default index. - ---- - -## Return Value - -Returns a [Collection](/sdk/js/5/core-classes/collection) object. - -## Usage - -<<< ./snippets/collection-1.js diff --git a/doc/5/core-classes/kuzzle/collection/snippets/collection-1.js b/doc/5/core-classes/kuzzle/collection/snippets/collection-1.js deleted file mode 100644 index f1a0285cf..000000000 --- a/doc/5/core-classes/kuzzle/collection/snippets/collection-1.js +++ /dev/null @@ -1,7 +0,0 @@ -var collection = kuzzle.collection('collection', 'index'); - -// or using a default index: -var - kuzzle = new Kuzzle('localhost', {defaultIndex: 'index'}); - -collection = kuzzle.collection('collection'); diff --git a/doc/5/core-classes/kuzzle/connect/index.md b/doc/5/core-classes/kuzzle/connect/index.md deleted file mode 100644 index 53925694a..000000000 --- a/doc/5/core-classes/kuzzle/connect/index.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -code: false -type: page -title: connect -description: Kuzzle:connect ---- - -# connect - -Connects to Kuzzle using the `host` parameter provided in the constructor. -Has no effect if `connect` is set to `auto`, unless `disconnect` has been called first. - ---- - -## Return value - -Returns the `Kuzzle` object to allow chaining. - ---- - -## Callback Response - -If a callback has been provided to the `Kuzzle` constructor, it will be called with the `Kuzzle` instance once connected to Kuzzle - -## Usage - -<<< ./snippets/connect-1.js diff --git a/doc/5/core-classes/kuzzle/connect/snippets/connect-1.js b/doc/5/core-classes/kuzzle/connect/snippets/connect-1.js deleted file mode 100644 index 599a215cd..000000000 --- a/doc/5/core-classes/kuzzle/connect/snippets/connect-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.connect(); diff --git a/doc/5/core-classes/kuzzle/constructor/index.md b/doc/5/core-classes/kuzzle/constructor/index.md deleted file mode 100644 index a99a5d2b2..000000000 --- a/doc/5/core-classes/kuzzle/constructor/index.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -code: false -type: page -title: Kuzzle -description: Entry point and main class for the entire SDK -order: 100 ---- - -# Constructor - -This is the main entry point to communicate with Kuzzle. Every other object inherits properties from the `Kuzzle` object. - ---- - -## Kuzzle(host, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------- | -| `host` | string | The server name (or the IP address) of a Kuzzle server installation | -| `options` | JSON object | Optional Kuzzle connection configuration | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ------------------- | ----------- | ------------------------------------------------------------------ | -------- | -| `autoQueue` | boolean | Automatically queue all requests during offline mode | `false` | -| `autoReconnect` | boolean | Automatically reconnect after a connection loss | `true` | -| `autoReplay` | boolean | Automatically replay queued requests on a `reconnected` event | `false` | -| `autoResubscribe` | boolean | Automatically renew all subscriptions on a `reconnected` event | `true` | -| `connect` | string | Manually or automatically connect to the Kuzzle instance | `auto` | -| `defaultIndex` | string | Set the default index to use | | -| `headers` | JSON object | Common headers for all sent documents | | -| `volatile` | JSON object | Common volatile data, will be sent to all future requests | | -| `offlineMode` | string | Offline mode configuration | `manual` | -| `port` | integer | Kuzzle network port | 7512 | -| `queueTTL` | integer | Time a queued request is kept during offline mode, in milliseconds | `120000` | -| `queueMaxSize` | integer | Number of maximum requests kept during offline mode | `500` | -| `replayInterval` | integer | Delay between each replayed requests, in milliseconds | `10` | -| `reconnectionDelay` | integer | number of milliseconds between reconnection attempts | `1000` | -| `sslConnection` | boolean | Switch Kuzzle connection to SSL mode | `false` | - -**Notes:** - -- the `offlineMode` option only accepts the `manual` and `auto` values - ---- - -## Properties - -| Property name | Type | Description | Writable? | -| -------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | :-------: | -| `autoQueue` | boolean | Automatically queue all requests during offline mode | Yes | -| `autoReconnect` | boolean | Automatically reconnect after a connection loss | No | -| `autoReplay` | boolean | Automatically replay queued requests on a `reconnected` event | Yes | -| `autoResubscribe` | boolean | Automatically renew all subscriptions on a `reconnected` event | No | -| `defaultIndex` | string | Kuzzle's default index to use | Yes | -| `headers` | JSON object | Common headers for all sent documents. | Yes | -| `host` | string | Target Kuzzle host name/address | No | -| `jwtToken` | string | Token used in requests for authentication. | Yes | -| `offlineQueue` | JSON object | Contains the queued requests during offline mode | No | -| `offlineQueueLoader` | function | Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue | Yes | -| `port` | integer | Kuzzle network port | No | -| `queueFilter` | function | Called during offline mode. Takes a request object as arguments and returns a boolean, indicating if a request can be queued | Yes | -| `queueMaxSize` | integer | Number of maximum requests kept during offline mode | Yes | -| `queueTTL` | integer | Time a queued request is kept during offline mode, in milliseconds | Yes | -| `replayInterval` | integer | Delay between each replayed requests | Yes | -| `reconnectionDelay` | integer | Number of milliseconds between reconnection attempts | No | -| `sslConnection` | boolean | Connect to Kuzzle using SSL | No | -| `volatile` | JSON object | Common volatile data, will be sent to all future requests | Yes | - -**Notes:** - -- if `connect` is set to `manual`, the `connect` method will have to be called manually -- the kuzzle instance will automatically queue all requests, and play them automatically once a first connection is established, regardless of the `connect` or offline mode option values. -- multiple methods allow passing specific `volatile` data. These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones. -- the `queueFilter` property is a function taking a JSON object as an argument. This object is the request sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format -- if `queueTTL` is set to `0`, requests are kept indefinitely -- The offline buffer acts like a first-in first-out (FIFO) queue, meaning that if the `queueMaxSize` limit is reached, older requests are discarded to make room for new requests -- if `queueMaxSize` is set to `0`, an unlimited number of requests is kept until the buffer is flushed -- the `offlineQueueLoader` must be set with a function, taking no argument, and returning an array of objects containing a `query` member with a Kuzzle query to be replayed, and an optional `cb` member with the corresponding callback to invoke with the query result -- updates to `host`, `port`, `autoReconnect`, `reconnectionDelay` and `sslConnection` properties will only take effect on next `connect` call - ---- - -## Callback response - -If the connection succeeds, resolves to the `Kuzzle` object itself. -If the `connect` option is set to `manual`, the callback will be called after the `connect` method is resolved. - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js b/doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js deleted file mode 100644 index 3662b82eb..000000000 --- a/doc/5/core-classes/kuzzle/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,11 +0,0 @@ -var kuzzle = new Kuzzle('localhost', { - defaultIndex: 'some index', - autoReconnect: true, - headers: {someheader: "value"}, - port: 7512 -}); - -// A callback is also available and will be invoked once connected to the Kuzzle instance: -kuzzle = new Kuzzle('localhost', function (err, res) { - // ... -}); diff --git a/doc/5/core-classes/kuzzle/create-index/index.md b/doc/5/core-classes/kuzzle/create-index/index.md deleted file mode 100644 index 025c48f4b..000000000 --- a/doc/5/core-classes/kuzzle/create-index/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: createIndex -description: Kuzzle:createIndex ---- - -# createIndex - -Create a new empty index, with no associated mapping. - ---- - -## createIndex([index], [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------------------------------------------------------------- | -| `index` | string | Optional index to query. If no set, defaults to [Kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties) | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the index creation status. - -## Usage - -<<< ./snippets/create-index-1.js - -> Callback response: - -```json -{ - "acknowledged": true, - "shards_acknowledged": true -} -``` diff --git a/doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js b/doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js deleted file mode 100644 index 1d719b3b1..000000000 --- a/doc/5/core-classes/kuzzle/create-index/snippets/create-index-1.js +++ /dev/null @@ -1,13 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.createIndex('myIndex', function (err, res) { - // callback called once the create operation has completed - // => the result is a JSON object containing the raw Kuzzle response -}); - -// Using promises (node.js) -kuzzle - .createIndexPromise('myIndex') - .then(res => { - // promise resolved once the create operation has completed - // => the result is a JSON object containing the raw Kuzzle response - }); diff --git a/doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js b/doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js deleted file mode 100644 index 35daced6f..000000000 --- a/doc/5/core-classes/kuzzle/create-index/snippets/create-index-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "acknowledged": true, - "shards_acknowledged": true -} diff --git a/doc/5/core-classes/kuzzle/create-my-credentials/index.md b/doc/5/core-classes/kuzzle/create-my-credentials/index.md deleted file mode 100644 index 47880f5dc..000000000 --- a/doc/5/core-classes/kuzzle/create-my-credentials/index.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -code: false -type: page -title: createMyCredentials -description: Kuzzle:createMyCredentials ---- - -# createMyCredentials - -Create the current user's credentials for the specified strategy. The credentials required will depend on the authentication plugin and strategy. - ---- - -## createMyCredentials(strategy, credentials, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------- | -| `strategy` | string | Strategy you want to create credentials for | -| `credentials` | JSON object | The credentials | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the created credentials. - -## Usage - -<<< ./snippets/create-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js b/doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js deleted file mode 100644 index 926313a6e..000000000 --- a/doc/5/core-classes/kuzzle/create-my-credentials/snippets/create-my-credentials-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.createMyCredentials('local', {'username': 'foo'}, function (err, res) { - console.log(res); // {username: 'bar', kuid: ''} -}); - -// Using promises (node.js) -kuzzle - .createMyCredentials('local', {'username': 'foo'}) - .then(res => { - console.log(res); // {username: 'foo', kuid: ''} - }); diff --git a/doc/5/core-classes/kuzzle/delete-my-credentials/index.md b/doc/5/core-classes/kuzzle/delete-my-credentials/index.md deleted file mode 100644 index 500d333e9..000000000 --- a/doc/5/core-classes/kuzzle/delete-my-credentials/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: deleteMyCredentials -description: Kuzzle:deleteMyCredentials ---- - -# deleteMyCredentials - -Delete the current user's credentials for the specified `strategy`. - ---- - -## deleteMyCredentials(strategy, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------- | -| `strategy` | string | Strategy you want to delete credentials from | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the query status. - -## Usage - -<<< ./snippets/delete-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js b/doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js deleted file mode 100644 index 2903370c8..000000000 --- a/doc/5/core-classes/kuzzle/delete-my-credentials/snippets/delete-my-credentials-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.deleteMyCredentials('local', function (err, res) { - console.log(res); // {acknowledged: true} -}); - -// Using promises (node.js) -kuzzle - .deleteMyCredentials('local') - .then(res => { - console.log(res); // {acknowledged: true} - }); diff --git a/doc/5/core-classes/kuzzle/disconnect/index.md b/doc/5/core-classes/kuzzle/disconnect/index.md deleted file mode 100644 index 57a6f0842..000000000 --- a/doc/5/core-classes/kuzzle/disconnect/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -code: false -type: page -title: disconnect -description: Kuzzle:disconnect ---- - -# disconnect - -Closes the current connection, and frees all allocated resources. -Contrary to the `offline` state (when the network connection is unexpectedly lost), `disconnect()` invalidates the instance, which cannot be used until [connect()](/sdk/js/5/core-classes/kuzzle/connect) is explicitly called. -This action does not trigger a `disconnected` event since this event is triggered when an unexpected disconnection occur. - -## Usage - -<<< ./snippets/disconnect-1.js diff --git a/doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js b/doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js deleted file mode 100644 index e7a7f4d6e..000000000 --- a/doc/5/core-classes/kuzzle/disconnect/snippets/disconnect-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.disconnect(); diff --git a/doc/5/core-classes/kuzzle/flush-queue/index.md b/doc/5/core-classes/kuzzle/flush-queue/index.md deleted file mode 100644 index 8409cb448..000000000 --- a/doc/5/core-classes/kuzzle/flush-queue/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: flushQueue -description: Kuzzle:flushQueue ---- - -# flushQueue - -Empties the offline queue without replaying it. - ---- - -## Return Value - -Returns the `Kuzzle` SDK instance to allow chaining. - -## Usage - -<<< ./snippets/flush-queue-1.js diff --git a/doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js b/doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js deleted file mode 100644 index 8dc566cd5..000000000 --- a/doc/5/core-classes/kuzzle/flush-queue/snippets/flush-queue-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.flushQueue(); diff --git a/doc/5/core-classes/kuzzle/get-all-statistics/index.md b/doc/5/core-classes/kuzzle/get-all-statistics/index.md deleted file mode 100644 index d4419693d..000000000 --- a/doc/5/core-classes/kuzzle/get-all-statistics/index.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -code: false -type: page -title: getAllStatistics -description: Kuzzle:getAllStatistics ---- - -# getAllStatistics - -> Callback response example: - -```json -[ - { - "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "mqtt": 37, "socketio": 17 }, - "failedRequests": { "socketio": 1 }, - "timestamp": "1453110641308" - }, - { - "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "socketio": 34 }, - "failedRequests": { "socketio": 3 }, - "timestamp": "1453110642308" - }, - { - "connections": {}, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "socketio": 40 }, - "failedRequests": {}, - "timestamp": "1453110643308" - } -] -``` - -Kuzzle monitors active connections, and ongoing/completed/failed requests. -This method returns all available statistics from Kuzzle. - ---- - -## getAllStatistics([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -### Callback Response - -Returns an array of JSON objects that each contain a statistics frame. - -## Usage - -<<< ./snippets/get-all-statistics-1.js diff --git a/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js b/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js deleted file mode 100644 index 058f42f39..000000000 --- a/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-1.js +++ /dev/null @@ -1,15 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.getAllStatistics(function (err, stats) { - stats.forEach(function (frame) { - // loop through all returned frames - }); -}); - -// Using promises (NodeJS only) -kuzzle - .getAllStatisticsPromise() - .then(stats => { - stats.forEach(function (frame) { - // loop through all returned frames - }); - }); diff --git a/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js b/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js deleted file mode 100644 index cdc4bb943..000000000 --- a/doc/5/core-classes/kuzzle/get-all-statistics/snippets/get-all-statistics-2.js +++ /dev/null @@ -1,16 +0,0 @@ -on -[{ "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "mqtt": 37, "socketio": 17 }, - "failedRequests": { "socketio": 1 }, - "timestamp": "1453110641308" }, - { "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "socketio": 34 }, - "failedRequests": { "socketio": 3 }, - "timestamp": "1453110642308" }, - { "connections": {}, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "socketio": 40 }, - "failedRequests": {}, - "timestamp": "1453110643308" }] diff --git a/doc/5/core-classes/kuzzle/get-auto-refresh/index.md b/doc/5/core-classes/kuzzle/get-auto-refresh/index.md deleted file mode 100644 index 602f3dc51..000000000 --- a/doc/5/core-classes/kuzzle/get-auto-refresh/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: getAutoRefresh -description: Kuzzle:getAutoRefresh ---- - -# getAutoRefresh - -The `autoRefresh` flag, when set to true, will make Kuzzle perform a -[`refresh`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html) request -immediately after each write request, causing documents to be immediately visible in a search. - -The `getAutoRefresh` function returns the current `autoRefresh` status for the given index. - -
-

- A refresh operation comes with some performance costs. -

-

- While forcing the autoRefresh can be convenient on a development or test environmnent, we recommend that you avoid - using it in production or at least carefully monitor its implications before using it. -

-
- ---- - -#### getAutoRefresh([index], [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------------------------------------------------------------- | -| `index` | string | Optional index to query. If no set, defaults to [Kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties) | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a boolean with the index `autoRefresh` status. - -## Usage - -<<< ./snippets/get-auto-refresh-1.js diff --git a/doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js b/doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js deleted file mode 100644 index 6e5e6e536..000000000 --- a/doc/5/core-classes/kuzzle/get-auto-refresh/snippets/get-auto-refresh-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.getAutoRefresh('myIndex', function (err, autoRefresh) { - console.log(autoRefresh); // true|false -}); - -// Using promises (node.js) -kuzzle - .getAutoRefreshPromise('myIndex') - .then(autoRefresh => { - console.log(autoRefresh); // true|false - }); diff --git a/doc/5/core-classes/kuzzle/get-jwt-token/index.md b/doc/5/core-classes/kuzzle/get-jwt-token/index.md deleted file mode 100644 index 3bb975114..000000000 --- a/doc/5/core-classes/kuzzle/get-jwt-token/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: getJwtToken -description: Kuzzle:getJwtToken ---- - -# getJwtToken - -Get internal jwtToken used to request kuzzle. - ---- - -## Return Value - -Returns the stored JWT as a string value. - -## Usage - -<<< ./snippets/get-jwt-token-1.js diff --git a/doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js b/doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js deleted file mode 100644 index 1d2553c5e..000000000 --- a/doc/5/core-classes/kuzzle/get-jwt-token/snippets/get-jwt-token-1.js +++ /dev/null @@ -1 +0,0 @@ -var jwtToken = kuzzle.getJwtToken(); diff --git a/doc/5/core-classes/kuzzle/get-my-credentials/index.md b/doc/5/core-classes/kuzzle/get-my-credentials/index.md deleted file mode 100644 index 87cf1c5bf..000000000 --- a/doc/5/core-classes/kuzzle/get-my-credentials/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: getMyCredentials -description: Kuzzle:getMyCredentials ---- - -# getMyCredentials - -Get [credential information](/core/1/guides/essentials/user-authentication/#user-credentials) for the current user. - ---- - -## getMyCredentials(strategy, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `strategy` | string | Strategy you want to get credentials from | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the credentials for the provided authentication strategy. - -## Usage - -<<< ./snippets/get-my-credentials-1.js - -> Callback response - -```json -{ - "username": "foo", - "kuid": "" -} -``` diff --git a/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js b/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js deleted file mode 100644 index 09411170f..000000000 --- a/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.getMyCredentials('local', function (error, credentials) { - -}); - -// Using promises (node.js) -kuzzle - .getMyCredentialsPromise('local') - .then(credentials => { - - }); diff --git a/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js b/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js deleted file mode 100644 index f12a9c355..000000000 --- a/doc/5/core-classes/kuzzle/get-my-credentials/snippets/get-my-credentials-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "username": "foo", - "kuid": "" -} diff --git a/doc/5/core-classes/kuzzle/get-my-rights/index.md b/doc/5/core-classes/kuzzle/get-my-rights/index.md deleted file mode 100644 index 59eb74a4e..000000000 --- a/doc/5/core-classes/kuzzle/get-my-rights/index.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -code: false -type: page -title: getMyRights -description: Kuzzle:getMyRights ---- - -# getMyRights - -Gets the rights for the current user. - ---- - -## getMyRights([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of rights. - -## Usage - -<<< ./snippets/get-my-rights-1.js - -> Callback response - -```json -[ - { - "controller": "my-controller", - "action": "my-action", - "index": "*", - "collection": "*", - "value": "allowed" - }, - { - "controller": "another-controller", - "action": "*", - "index": "my-index", - "collection": "*", - "value": "conditional" - } -] -``` diff --git a/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js b/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js deleted file mode 100644 index cc193102e..000000000 --- a/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .getMyRights(function(error, rights) { - // result is an array of objects - }); - -// Using promises (NodeJS) -kuzzle - .getMyRightsPromise() - .then(rights => { - // result is an array of objects - }); diff --git a/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js b/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js deleted file mode 100644 index 8615b7d40..000000000 --- a/doc/5/core-classes/kuzzle/get-my-rights/snippets/get-my-rights-2.js +++ /dev/null @@ -1,17 +0,0 @@ -on -[ - { - "controller": "my-controller", - "action": "my-action", - "index": "*", - "collection": "*", - "value": "allowed" - }, - { - "controller": "another-controller", - "action": "*", - "index": "my-index", - "collection": "*", - "value": "conditional" - } -] diff --git a/doc/5/core-classes/kuzzle/get-server-info/index.md b/doc/5/core-classes/kuzzle/get-server-info/index.md deleted file mode 100644 index 0763ecaca..000000000 --- a/doc/5/core-classes/kuzzle/get-server-info/index.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -code: false -type: page -title: getServerInfo -description: Kuzzle:getServerInfo ---- - -# getServerInfo - -> Callback response example: - -```json -{ - "kuzzle": { - "api": { - "routes": { - "controller1": { - "action1": { - "controller": "controller1", - "action": "action1", - "http": { - "verb": "GET", - "url": "/action1/url" - } - }, - "action2": { - "controller": "controller1", - "action": "action2", - "http": { - "verb": "POST", - "url": "/action2/url" - } - }, - { - "...": "..." - } - }, - "pluginName/controller": { - "action": { - "controller": "pluginName/controller", - "action": "action", - "http": { - "verb": "GET", - "url": "/action/url" - } - }, - { - "...": " ..." - } - }, - { - "...": "..." - } - }, - "version": "" - }, - "memoryUsed": 12345, - "nodeVersion": "v6.9.5", - "plugins": {}, - "system": { - "cpus": [ - { - "cpu1": "informations" - }, - { - "...": "..." - } - ], - "memory": { - "free": 123456, - "total": 1234567 - } - }, - "uptime": "", - "version": "" - }, - "services": { - "internalCache": { - "kuzzle memory cache": "informations", - "...": "..." - }, - "memoryStorage": { - "API memory storage": "informations", - "...": "..." - }, - { - "...": "..." - } - } -} -``` - -Retrieves information about Kuzzle plugins and active services. - ---- - -## getServerInfo([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a JSON object containing server information. - -## Usage - -<<< ./snippets/get-server-info-1.js diff --git a/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js b/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js deleted file mode 100644 index 4318d5d2c..000000000 --- a/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.getServerInfo(function (err, stats) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle.getServerInfoPromise() - .then(infos => { - // ... - }); diff --git a/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js b/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js deleted file mode 100644 index 2ce1e6d2c..000000000 --- a/doc/5/core-classes/kuzzle/get-server-info/snippets/get-server-info-2.js +++ /dev/null @@ -1,79 +0,0 @@ -on -{ - "kuzzle": { - "api": { - "routes": { - "controller1": { - "action1": { - "controller": "controller1", - "action": "action1", - "http": { - "verb": "GET", - "url": "/action1/url" - } - }, - "action2": { - "controller": "controller1", - "action": "action2", - "http": { - "verb": "POST", - "url": "/action2/url" - } - }, - { - "...": "..." - } - }, - "pluginName/controller": { - "action": { - "controller": "pluginName/controller", - "action": "action", - "http": { - "verb": "GET", - "url": "/action/url" - } - }, - { - "...": " ..." - } - }, - { - "...": "..." - } - }, - "version": "" - }, - "memoryUsed": 12345, - "nodeVersion": "v6.9.5", - "plugins": {}, - "system": { - "cpus": [ - { - "cpu1": "informations" - }, - { - "...": "..." - } - ], - "memory": { - "free": 123456, - "total": 1234567 - } - }, - "uptime": "", - "version": "" - }, - "services": { - "internalCache": { - "kuzzle memory cache": "informations", - "...": "..." - }, - "memoryStorage": { - "API memory storage": "informations", - "...": "..." - }, - { - "...": "..." - } - } -} diff --git a/doc/5/core-classes/kuzzle/get-statistics/index.md b/doc/5/core-classes/kuzzle/get-statistics/index.md deleted file mode 100644 index 6c153beef..000000000 --- a/doc/5/core-classes/kuzzle/get-statistics/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: getStatistics -description: Kuzzle:getStatistics ---- - -# getStatistics - -> Without argument, retrieves the last statistic frame in an array: -> When providing a timestamp, retrieves all frames recorded after that timestamp: -> Kuzzle server monitors active connections, and ongoing/completed/failed requests. -> This method returns either the last statistics frame, or a set of frames starting from a provided timestamp. - ---- - -## getStatistics([timestamp], [options], callback) - -| Arguments | Type | Description | -| ----------- | ----------- | ---------------------------------------------------------------- | -| `timestamp` | Epoch time | Optional starting time from which the frames are to be retrieved | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - -**Note:** Kuzzle statistics are cleaned up regularly. If the timestamp is set too far in the past, then this method will return all available statistics. - ---- - -### Callback Response - -Returns an `array` containing one or more statistics frame (as JSON objects). - -## Usage - -<<< ./snippets/get-statistics-1.js - -<<< ./snippets/get-statistics-2.js - -> Callback response: - -```json -[ - { - "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "mqtt": 37, "socketio": 17 }, - "failedRequests": { "socketio": 1 }, - "timestamp": "1453110641308" - } -] -``` diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js deleted file mode 100644 index 5704ddfa5..000000000 --- a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.getStatistics(function (err, statistics) { -}); - -// Using promises (NodeJS only) -kuzzle - .getStatisticsPromise() - .then(statistics => { - }); diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js deleted file mode 100644 index d21210ee6..000000000 --- a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-2.js +++ /dev/null @@ -1,14 +0,0 @@ -// Date can be either in ISO format or a timestamp (utc, in milliseconds) -var ts = Date.parse('2015-10-26T12:19:10.213Z'); - -// Using callbacks (NodeJS or Web Browser) -kuzzle.getStatistics(ts, function (error, statistics) { - -}); - -// Using promises (NodeJS only) -kuzzle - .getStatisticsPromise(ts) - .then(statistics => { - - }); diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js deleted file mode 100644 index f5444693e..000000000 --- a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-3.js +++ /dev/null @@ -1,15 +0,0 @@ - -// Date can be either in ISO format or a timestamp (utc, in milliseconds) -var ts = Date.parse('2015-10-26T12:19:10.213Z'); - -// Using callbacks (NodeJS or Web Browser) -kuzzle.getStatistics(ts, function (error, statistics) { - -}); - -// Using promises (NodeJS only) -kuzzle - .getStatisticsPromise(ts) - .then(statistics => { - - }); diff --git a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js b/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js deleted file mode 100644 index 1a0a6480c..000000000 --- a/doc/5/core-classes/kuzzle/get-statistics/snippets/get-statistics-4.js +++ /dev/null @@ -1,24 +0,0 @@ -on -[ - { - "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "mqtt": 37, "socketio": 17 }, - "failedRequests": { "socketio": 1 }, - "timestamp": "1453110641308" - }, - { - "connections": { "socketio": 1 }, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "socketio": 34 }, - "failedRequests": { "socketio": 3 }, - "timestamp": "1453110642308" - }, - { - "connections": {}, - "ongoingRequests": { "rest": 0, "socketio": 0 }, - "completedRequests": { "socketio": 40 }, - "failedRequests": {}, - "timestamp": "1453110643308" - } -] diff --git a/doc/5/core-classes/kuzzle/index.md b/doc/5/core-classes/kuzzle/index.md deleted file mode 100644 index 970ce750e..000000000 --- a/doc/5/core-classes/kuzzle/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -code: false -type: branch -title: Kuzzle -description: Kuzzle documentation -order: 500 ---- diff --git a/doc/5/core-classes/kuzzle/list-collections/index.md b/doc/5/core-classes/kuzzle/list-collections/index.md deleted file mode 100644 index da279b964..000000000 --- a/doc/5/core-classes/kuzzle/list-collections/index.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -code: false -type: page -title: listCollections -description: Kuzzle:listCollections ---- - -# listCollections - -Returns the list of known collections contained in a specified index. - ---- - -## listCollections([index], [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------- | -| `index` | string | Index containing the collections to be listed | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `from` | integer | Determines the starting point of the pagination. By default, start at the beggining | `0` | -| `size` | integer | Determines the size of the returned result set. By default, no limit is applied | `undefined` | -| `type` | string | Get either `stored` collections or `realtime` ones. By default, list `all` collections | `all` | - -If no `index` argument is provided, the `defaultIndex` property is used. If no default index is found, this method throws an error. - ---- - -## Callback Response - -Returns an array of JSON objects containing the list of stored and/or realtime collections on the provided index. - -## Usage - -<<< ./snippets/list-collections-1.js - -> Callback response: - -```json -[ - { "name": "realtime_1", "type": "realtime" }, - { "name": "realtime_2", "type": "realtime" }, - { "name": "realtime_...", "type": "realtime" }, - { "name": "realtime_n", "type": "realtime" }, - { "name": "stored_1", "type": "stored" }, - { "name": "stored_2", "type": "stored" }, - { "name": "stored_...", "type": "stored" }, - { "name": "stored_n", "type": "stored" } -] -``` diff --git a/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js b/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js deleted file mode 100644 index 42d90486e..000000000 --- a/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.listCollections('index', {type: 'stored', from: 0, size: 42}, function (err, collections) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle - .listCollectionsPromise('index', {type: 'stored'}) - .then(collections => { - // ... - }); diff --git a/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js b/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js deleted file mode 100644 index 4f51edc2b..000000000 --- a/doc/5/core-classes/kuzzle/list-collections/snippets/list-collections-2.js +++ /dev/null @@ -1,11 +0,0 @@ -on -[ - {"name": "realtime_1", "type": "realtime"}, - {"name": "realtime_2", "type": "realtime"}, - {"name": "realtime_...", "type": "realtime"}, - {"name": "realtime_n", "type": "realtime"}, - {"name": "stored_1", "type": "stored"}, - {"name": "stored_2", "type": "stored"}, - {"name": "stored_...", "type": "stored"}, - {"name": "stored_n", "type": "stored"} -] diff --git a/doc/5/core-classes/kuzzle/list-indexes/index.md b/doc/5/core-classes/kuzzle/list-indexes/index.md deleted file mode 100644 index 10c74d5bd..000000000 --- a/doc/5/core-classes/kuzzle/list-indexes/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: listIndexes -description: Kuzzle:listIndexes ---- - -# listIndexes - -Returns the list of indexes stored in Kuzzle. - ---- - -## listIndexes([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an `array` of index names. - -## Usage - -<<< ./snippets/list-indexes-1.js - -> Callback response: - -```json -["index", "another index", "..."] -``` diff --git a/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js b/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js deleted file mode 100644 index 59d4a2d3a..000000000 --- a/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.listIndexes(function (err, indexes) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle - .listIndexesPromise() - .then(indexes => { - // ... - }); diff --git a/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js b/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js deleted file mode 100644 index 428366b57..000000000 --- a/doc/5/core-classes/kuzzle/list-indexes/snippets/list-indexes-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -[ "index", "another index", "..."] diff --git a/doc/5/core-classes/kuzzle/login/index.md b/doc/5/core-classes/kuzzle/login/index.md deleted file mode 100644 index a5cee00fe..000000000 --- a/doc/5/core-classes/kuzzle/login/index.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -code: false -type: page -title: login -description: Kuzzle:login ---- - -# login - -Login a user using a specified strategy and their credentials. - -If the Kuzzle response contains a JWT Token, the Kuzzle SDK token is set and the `loginAttempt` event is fired immediately with the following object: -`{ success: true }` -This is the case, for instance, with the `local` authentication strategy. - -If the request succeeds but there is no token, then it means that the chosen strategy is a two-steps authentication method, such as the OAUTH strategy. In that case, the `loginAttempt` event is **not** fired. To complete the login, the `setJwtToken` method must be called either with a token or with an appropriate Kuzzle response. - -If the login attempt fails, the `loginAttempt` event is fired with the following response: -`{ success: false, error: 'error message' }` - -
-This method is non-queuable, meaning that during offline mode, it will be discarded and the callback will be called with an error. [Learn more.](/core/1/guides/essentials/user-authentication/#local-strategy) -
- ---- - -## login(strategy, [credentials], [expiresIn], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------------------ | -| `strategy` | string | Authentication strategy (local, facebook, github, ...) | -| `credentials` | JSON object | Optional login credentials, depending on the strategy | -| `expiresIn` | _varies_ | Login expiration time | -| `callback` | function | Optional callback handling the response | - -**Note:** If the `expiresIn` argument is not set, the default token expiration value will be taken from the Kuzzle server configuration. - -By default, Kuzzle comes with the [kuzzle-plugin-auth-passport-local](https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local) plugin, which provides the `local` authentication strategy. -This strategy requires a `username` and `password` as `credentials` - ---- - -## Callback Response - -Returns a JSON object containing the Kuzzle response. - -## Usage - -<<< ./snippets/login-1.js diff --git a/doc/5/core-classes/kuzzle/login/snippets/login-1.js b/doc/5/core-classes/kuzzle/login/snippets/login-1.js deleted file mode 100644 index 6bfad2757..000000000 --- a/doc/5/core-classes/kuzzle/login/snippets/login-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Expiration time is expressed as a string following the -// time conversion library: https://www.npmjs.com/package/ms - var expiresIn = "1h"; - -// Using callbacks (NodeJS or Web Browser) -kuzzle.login("local", {username: "username", password: "password"}, expiresIn, function (err, res) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle.loginPromise("local", {username: "username", password: "password"}, expiresIn) - .then(res => { - // ... - }); diff --git a/doc/5/core-classes/kuzzle/logout/index.md b/doc/5/core-classes/kuzzle/logout/index.md deleted file mode 100644 index 9e4896e88..000000000 --- a/doc/5/core-classes/kuzzle/logout/index.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -code: false -type: page -title: logout -description: Kuzzle:logout ---- - -# logout - -Logs the user out. - -
-This method is non-queuable, meaning that during offline mode, it will be discarded and the callback will be called with an error. -
- ---- - -## logout([callback]) - -| Arguments | Type | Description | -| ---------- | -------- | --------------------------------------- | -| `callback` | function | Optional callback handling the response | - -This method empties the `jwtToken` property - ---- - -## Return value - -Returns the `Kuzzle` SDK object to allow chaining. - ---- - -## Callback Response - -Returns the `Kuzzle` SDK object once the logout process is complete, either successfully or not. -The `Kuzzle` SDK object will unset the `jwtToken` property if the user is successfully logged out. - -## Usage - -<<< ./snippets/logout-1.js diff --git a/doc/5/core-classes/kuzzle/logout/snippets/logout-1.js b/doc/5/core-classes/kuzzle/logout/snippets/logout-1.js deleted file mode 100644 index 6a74a0804..000000000 --- a/doc/5/core-classes/kuzzle/logout/snippets/logout-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.logout(function (err, res) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle.logoutPromise() - .then(res => { - // ... - }); diff --git a/doc/5/core-classes/kuzzle/memory-storage/index.md b/doc/5/core-classes/kuzzle/memory-storage/index.md deleted file mode 100644 index 004032f22..000000000 --- a/doc/5/core-classes/kuzzle/memory-storage/index.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -code: false -type: page -title: memoryStorage -description: Kuzzle:memoryStorage ---- - -## memoryStorage - -A [MemoryStorage](/sdk/js/5/core-classes/memory-storage) singleton. diff --git a/doc/5/core-classes/kuzzle/now/index.md b/doc/5/core-classes/kuzzle/now/index.md deleted file mode 100644 index 5d4795393..000000000 --- a/doc/5/core-classes/kuzzle/now/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: now -description: Kuzzle:now ---- - -# now - -Retrieves the current Kuzzle time. - ---- - -## now([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an `integer` containing the current Kuzzle time, encoded as an UTC Epoch time in milliseconds. - -## Usage - -<<< ./snippets/now-1.js - -> Callback response: - -```json -1447151167622 -``` diff --git a/doc/5/core-classes/kuzzle/now/snippets/now-1.js b/doc/5/core-classes/kuzzle/now/snippets/now-1.js deleted file mode 100644 index f081ec673..000000000 --- a/doc/5/core-classes/kuzzle/now/snippets/now-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.now(function (err, res) { - // 'res' contains the Kuzzle timestamp (utc, in milliseconds) -}); - -// Using promises (NodeJS only) -kuzzle.nowPromise().then(res => { - // 'res' contains the Kuzzle timestamp (utc, in milliseconds) -}); diff --git a/doc/5/core-classes/kuzzle/now/snippets/now-2.js b/doc/5/core-classes/kuzzle/now/snippets/now-2.js deleted file mode 100644 index d611c182d..000000000 --- a/doc/5/core-classes/kuzzle/now/snippets/now-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -1447151167622 diff --git a/doc/5/core-classes/kuzzle/query/index.md b/doc/5/core-classes/kuzzle/query/index.md deleted file mode 100644 index 38078616a..000000000 --- a/doc/5/core-classes/kuzzle/query/index.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -code: false -type: page -title: query -description: Kuzzle:query ---- - -## query - -Base method used to send queries to Kuzzle, following the [API Documentation](/core/1/api). - -
-This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
-Refer to Kuzzle's API Reference [here](/core/1/api) -
- ---- - -## query(queryArgs, query, [options], [callback]) - -| Argument | Type | Description | -| ----------- | ----------- | -------------------- | -| `queryArgs` | JSON object | Query base arguments | -| `query` | JSON object | Query to execute | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback | - ---- - -## queryArgs - -`queryArgs` is a JSON object allowing Kuzzle to route your query to the right API method: - -| Option | Type | Description | Required? | -| ------------ | ------ | --------------------------------------- | --------- | -| `controller` | string | API Controller argument | required | -| `action` | string | API Controller action | required | -| `index` | string | Index concerned by the action | optional | -| `collection` | string | Data collection concerned by the action | optional | - ---- - -## query - -## `query` is a JSON object containing arguments specific to the query, such as a `body` property, a JWT hash, a document `_id`, or generic query options (such as `from` or `size` for [search queries](/core/1/api/controllers/document/search/)) - -## Options - -| Option | Type | Description | Default | -| ---------- | ----------- | ------------------------------------------------------------- | ------- | -| `volatile` | JSON object | Additional information passed to notifications to other users | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - ---- - -## Callback Response - -Returns a `JSON object` containing the raw Kuzzle response. - -## Usage - -<<< ./snippets/query-1.js - -> Callback response: - -```json -{ - "error": null, - "result": { - "action": "action", - "controller": "controller", - "requestId": "bf87b930-7c02-11e5-ab10-dfa9e9fd2e07", - "other properties": "depends of the query made" - } -} -``` diff --git a/doc/5/core-classes/kuzzle/query/snippets/query-1.js b/doc/5/core-classes/kuzzle/query/snippets/query-1.js deleted file mode 100644 index b51aea5a9..000000000 --- a/doc/5/core-classes/kuzzle/query/snippets/query-1.js +++ /dev/null @@ -1,23 +0,0 @@ -const - args = { - controller: 'controller', - action: 'action' - }, - query = { - body: { - foo: 'bar' - }, - other: 'argument' - }; - -// Using callbacks (NodeJS or Web Browser) -kuzzle.query(args, query, function (err, res) { - // ... -}); - -// Using promises (NodeJS only) -kuzzle - .queryPromise(args, query) - .then(result => { - - }); diff --git a/doc/5/core-classes/kuzzle/query/snippets/query-2.js b/doc/5/core-classes/kuzzle/query/snippets/query-2.js deleted file mode 100644 index efcebd8c0..000000000 --- a/doc/5/core-classes/kuzzle/query/snippets/query-2.js +++ /dev/null @@ -1,9 +0,0 @@ -on -{ "error": null, - "result": { - "action": "action", - "controller": "controller", - "requestId": "bf87b930-7c02-11e5-ab10-dfa9e9fd2e07", - "other properties": "depends of the query made" - } -} diff --git a/doc/5/core-classes/kuzzle/refresh-index/index.md b/doc/5/core-classes/kuzzle/refresh-index/index.md deleted file mode 100644 index c786e737c..000000000 --- a/doc/5/core-classes/kuzzle/refresh-index/index.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -code: false -type: page -title: refreshIndex -description: Kuzzle:refreshIndex ---- - -# refreshIndex - -When writing or deleting documents in Kuzzle, the update needs to be indexed before being reflected -in the search index. -By default, this operation can take up to 1 second. - -Given an index, the `refresh` action forces a [`refresh`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html), -on it, making the documents visible to search immediately. - -
- A refresh operation comes with some performance costs.
-
- From elasticsearch documentation: -
- "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." -
-
- ---- - -## refreshIndex([index], [options], [callback]) - -| Argument | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------- | -| `index` | string | _Optional_. The index to refresh. If not set, defaults to [kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties). | -| `options` | JSON object | Optional parameters | -| `callback` | function | _Optional_. Callback handling the response. | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - ---- - -## Callback Response - -Returns a JSON structure matching the response from Elasticsearch. - -## Usage - -<<< ./snippets/refresh-index-1.js diff --git a/doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js b/doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js deleted file mode 100644 index 25b7abd30..000000000 --- a/doc/5/core-classes/kuzzle/refresh-index/snippets/refresh-index-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.refreshIndex('myIndex'); diff --git a/doc/5/core-classes/kuzzle/remove-all-listeners/index.md b/doc/5/core-classes/kuzzle/remove-all-listeners/index.md deleted file mode 100644 index 4d571d6a5..000000000 --- a/doc/5/core-classes/kuzzle/remove-all-listeners/index.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -code: false -type: page -title: removeAllListeners -description: Kuzzle:removeAllListeners ---- - -# removeAllListeners - -Removes all listeners, either from a specific event or from all events - ---- - -## removeAllListeners([event]) - -| Arguments | Type | Description | -| --------- | ------ | -------------------------------------------------------------------------------- | -| `event` | string | One of the event described in the `Event Handling` section of this documentation | - ---- - -## Return Value - -Returns the `Kuzzle` object to allow chaining. - -## Usage - -<<< ./snippets/remove-all-listeners-1.js diff --git a/doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js b/doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js deleted file mode 100644 index 7fe6782fb..000000000 --- a/doc/5/core-classes/kuzzle/remove-all-listeners/snippets/remove-all-listeners-1.js +++ /dev/null @@ -1,5 +0,0 @@ -// Removes all listeners on the "unsubscribed" global event -kuzzle.removeAllListeners('disconnected'); - -// Removes all listeners on all global events -kuzzle.removeAllListeners(); diff --git a/doc/5/core-classes/kuzzle/remove-listener/index.md b/doc/5/core-classes/kuzzle/remove-listener/index.md deleted file mode 100644 index d3a87872b..000000000 --- a/doc/5/core-classes/kuzzle/remove-listener/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: removeListener -description: Kuzzle:removeListener ---- - -# removeListener - -Remove a listener from an event. - ---- - -## removeListener(event, callback) - -| Arguments | Type | Description | -| ---------- | --------------- | --------------------------------------------------------------------------------- | -| `event` | string | One of the events described in the `Event Handling` section of this documentation | -| `callback` | function/object | the callback | - ---- - -## Return Value - -Returns the `Kuzzle` object to allow chaining. - -## Usage - -<<< ./snippets/remove-listener-1.js diff --git a/doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js b/doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js deleted file mode 100644 index 3d9b14c46..000000000 --- a/doc/5/core-classes/kuzzle/remove-listener/snippets/remove-listener-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.removeListener('disconnected', callback); diff --git a/doc/5/core-classes/kuzzle/replay-queue/index.md b/doc/5/core-classes/kuzzle/replay-queue/index.md deleted file mode 100644 index f7bd90ba1..000000000 --- a/doc/5/core-classes/kuzzle/replay-queue/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: replayQueue -description: Kuzzle:replayQueue ---- - -# replayQueue - -Replays the requests queued during offline mode. Works only if the SDK is not in a `disconnected` state, and if the `autoReplay` option is set to `false`. - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - -## Usage - -<<< ./snippets/replay-queue-1.js diff --git a/doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js b/doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js deleted file mode 100644 index 527244e92..000000000 --- a/doc/5/core-classes/kuzzle/replay-queue/snippets/replay-queue-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.replayQueue(); diff --git a/doc/5/core-classes/kuzzle/security/index.md b/doc/5/core-classes/kuzzle/security/index.md deleted file mode 100644 index 83d944dda..000000000 --- a/doc/5/core-classes/kuzzle/security/index.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -code: false -type: page -title: security -description: Kuzzle:security ---- - -# security - -A [Security](/sdk/js/5/core-classes/security) singleton. diff --git a/doc/5/core-classes/kuzzle/set-auto-refresh/index.md b/doc/5/core-classes/kuzzle/set-auto-refresh/index.md deleted file mode 100644 index e7dc7c4c5..000000000 --- a/doc/5/core-classes/kuzzle/set-auto-refresh/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: setAutoRefresh -description: Kuzzle:setAutoRefresh ---- - -# setAutoRefresh - -The `autoRefresh` flag, when set to true, will make Kuzzle perform a -[`refresh`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-refresh.html) request -immediately after each write request, causing documents to be immediately visible in a search. - -Given an index, the `setAutoRefresh` function updates its `autoRefresh` status. - -
-

- A refresh operation comes with some performance costs. -

-

- While forcing the autoRefresh can be convenient on a development or test environmnent, we recommend that you avoid - using it in production or at least carefully monitor its implications before using it. -

-
- ---- - -## setAutoRefresh([index], autoRefresh, [options], [callback]) - -| Argument | Type | Description | -| ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------- | -| `index` | string | _Optional_ The index to set the `autoRefresh` for. If not set, defaults to [kuzzle.defaultIndex](/sdk/js/5/core-classes/kuzzle/#properties). | -| `autoRefresh` | boolean | The value to set for the `autoRefresh` setting. | -| `options` | JSON object | Optional parameters | -| `callback` | function | _Optional_ Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - ---- - -## Callback Response - -Returns a boolean with the new `autoRefresh` status. - -## Usage - -<<< ./snippets/set-auto-refresh-1.js diff --git a/doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js b/doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js deleted file mode 100644 index 2c4eb8b17..000000000 --- a/doc/5/core-classes/kuzzle/set-auto-refresh/snippets/set-auto-refresh-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.setAutoRefresh('myIndex', true); diff --git a/doc/5/core-classes/kuzzle/set-default-index/index.md b/doc/5/core-classes/kuzzle/set-default-index/index.md deleted file mode 100644 index e6cae0556..000000000 --- a/doc/5/core-classes/kuzzle/set-default-index/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: setDefaultIndex -description: Kuzzle:setDefaultIndex ---- - -# setDefaultIndex - -Set the default index. Has the same effect than the `defaultIndex` constructor option. - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - -## Usage - -<<< ./snippets/set-default-index-1.js diff --git a/doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js b/doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js deleted file mode 100644 index 39611cf15..000000000 --- a/doc/5/core-classes/kuzzle/set-default-index/snippets/set-default-index-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.setDefaultIndex('index'); diff --git a/doc/5/core-classes/kuzzle/set-headers/index.md b/doc/5/core-classes/kuzzle/set-headers/index.md deleted file mode 100644 index e2a134fca..000000000 --- a/doc/5/core-classes/kuzzle/set-headers/index.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -code: false -type: page -title: setHeaders -description: Kuzzle:setHeaders ---- - -# setHeaders - -This is a helper function returning itself, allowing to easily chain calls. - ---- - -## setHeaders(content, [replace]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------------------------------------------------------- | -| `content` | JSON Object | New content | -| `replace` | boolean | true: replace the current content with the provided data, false: merge it | - -**Note:** by default, the `replace` argument is set to `false` - ---- - -## Return value - -Returns the `Kuzzle` object to allow chaining. - -## Usage - -<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js deleted file mode 100644 index fa867c0ed..000000000 --- a/doc/5/core-classes/kuzzle/set-headers/snippets/set-headers-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/kuzzle/set-jwt-token/index.md b/doc/5/core-classes/kuzzle/set-jwt-token/index.md deleted file mode 100644 index 131f462f1..000000000 --- a/doc/5/core-classes/kuzzle/set-jwt-token/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -code: false -type: page -title: setJwtToken -description: Kuzzle:setJwtToken ---- - -# setJwtToken - -Sets the internal JWT token which will be used when making requests to Kuzzle. - -If the provided token is valid, a `loginAttempt` event is fired with the following object: -`{ success: true }` - -If not, the `loginAttempt` event is fired with the following response: -`{ success: false, error: 'error message' }` - ---- - -## setJwtToken(jwtToken) - -| Arguments | Type | Description | -| ---------- | ------ | ----------------------------------- | -| `jwtToken` | string | Previously generated JSON Web Token | - ---- - -## setJwtToken(kuzzleResponse) - -| Arguments | Type | Description | -| ---------------- | ----------- | ----------------------------------------------------------- | -| `kuzzleResponse` | JSON object | Final Kuzzle response from a 2-steps authentication process | - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - -## Usage - -<<< ./snippets/set-jwt-token-1.js diff --git a/doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js b/doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js deleted file mode 100644 index d01baca48..000000000 --- a/doc/5/core-classes/kuzzle/set-jwt-token/snippets/set-jwt-token-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Directly with a JWT Token -kuzzle.setJwtToken('some jwt token'); - -/* - Or with a Kuzzle response. - For instance, the final OAUTH2 response is obtained with a redirection from Kuzzle, - and it can be provided to this method directly - */ -kuzzle.setJwtToken(authenticationResponse); diff --git a/doc/5/core-classes/kuzzle/start-queuing/index.md b/doc/5/core-classes/kuzzle/start-queuing/index.md deleted file mode 100644 index 24748085e..000000000 --- a/doc/5/core-classes/kuzzle/start-queuing/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: startQueuing -description: Kuzzle:startQueuing ---- - -# startQueuing - -Starts the requests queuing. Works only in offline mode, and if the [autoQueue](/sdk/js/5/core-classes/kuzzle/#properties) option is set to `false`. - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - -## Usage - -<<< ./snippets/start-queuing-1.js diff --git a/doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js b/doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js deleted file mode 100644 index 947392364..000000000 --- a/doc/5/core-classes/kuzzle/start-queuing/snippets/start-queuing-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.startQueuing(); diff --git a/doc/5/core-classes/kuzzle/stop-queuing/index.md b/doc/5/core-classes/kuzzle/stop-queuing/index.md deleted file mode 100644 index 87144629f..000000000 --- a/doc/5/core-classes/kuzzle/stop-queuing/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: stopQueuing -description: Kuzzle:stopQueuing ---- - -# stopQueuing - -Stops the requests queuing. Works only in offline mode, and if the [autoQueue](/sdk/js/5/core-classes/kuzzle/#properties) option is set to `false`. - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - -## Usage - -<<< ./snippets/stop-queuing-1.js diff --git a/doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js b/doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js deleted file mode 100644 index 0d82bef00..000000000 --- a/doc/5/core-classes/kuzzle/stop-queuing/snippets/stop-queuing-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.stopQueuing(); diff --git a/doc/5/core-classes/kuzzle/unset-jwt-token/index.md b/doc/5/core-classes/kuzzle/unset-jwt-token/index.md deleted file mode 100644 index ec766f9a8..000000000 --- a/doc/5/core-classes/kuzzle/unset-jwt-token/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: unsetJwtToken -description: Kuzzle:unsetJwtToken ---- - -# unsetJwtToken - -Unsets the internal JSON Web Token used for authentication, and stops all existing subscriptions. - ---- - -## Return Value - -Returns the `Kuzzle` SDK object to allow chaining. - -## Usage - -<<< ./snippets/unset-jwt-token-1.js diff --git a/doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js b/doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js deleted file mode 100644 index 3d5c2510a..000000000 --- a/doc/5/core-classes/kuzzle/unset-jwt-token/snippets/unset-jwt-token-1.js +++ /dev/null @@ -1 +0,0 @@ -kuzzle.unsetJwtToken(); diff --git a/doc/5/core-classes/kuzzle/update-my-credentials/index.md b/doc/5/core-classes/kuzzle/update-my-credentials/index.md deleted file mode 100644 index c79cef8b0..000000000 --- a/doc/5/core-classes/kuzzle/update-my-credentials/index.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -code: false -type: page -title: updateMyCredentials -description: Kuzzle:updateMyCredentials ---- - -# updateMyCredentials - -Update current user credentials for the specified `strategy`. The credentials to send depend on the authentication plugin and the strategy. - ---- - -## updateMyCredentials(strategy, credentials, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `strategy` | string | Strategy you want to create credentials in | -| `credentials` | JSON object | The credentials | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback response - -Returns an object reflecting the updated credentials. - -## Usage - -<<< ./snippets/update-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js b/doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js deleted file mode 100644 index 3d9a498c1..000000000 --- a/doc/5/core-classes/kuzzle/update-my-credentials/snippets/update-my-credentials-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.updateMyCredentials('local', {'username': 'foo'}, function (err, res) { - console.log(res); // {username: 'bar', kuid: ''} -}); - -// Using promises (node.js) -kuzzle - .updateMyCredentials('local', {'username': 'foo'}) - .then(res => { - console.log(res); // {username: 'foo', kuid: ''} - }); diff --git a/doc/5/core-classes/kuzzle/update-self/index.md b/doc/5/core-classes/kuzzle/update-self/index.md deleted file mode 100644 index b70e919ae..000000000 --- a/doc/5/core-classes/kuzzle/update-self/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: updateSelf -description: Kuzzle:updateSelf ---- - -# updateSelf - ---- - -## updateSelf(content, [options], [callback]) - -Performs a partial update on the current user. - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------- | -| `content` | JSON Object | A plain javascript object representing the user | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `Kuzzle` SDK object to allow chaining. - ---- - -## Callback Response - -Returns the updated user object. - -## Usage - -<<< ./snippets/update-self-1.js diff --git a/doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js b/doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js deleted file mode 100644 index ad7d42dd4..000000000 --- a/doc/5/core-classes/kuzzle/update-self/snippets/update-self-1.js +++ /dev/null @@ -1,18 +0,0 @@ -var newContent = { - firstname: 'My Name Is', - lastname: 'Jonas' -}; - - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .updateSelf(newContent, function (err, updatedUser) { - - }); - -// Using promises (NodeJS) -kuzzle - .updateSelfPromise(newContent) - .then(updatedUser => { - - }); diff --git a/doc/5/core-classes/kuzzle/validate-my-credentials/index.md b/doc/5/core-classes/kuzzle/validate-my-credentials/index.md deleted file mode 100644 index fc4cfc24d..000000000 --- a/doc/5/core-classes/kuzzle/validate-my-credentials/index.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -code: false -type: page -title: validateMyCredentials -description: Kuzzle:validateMyCredentials ---- - -# validateMyCredentials - -Update current user's credentials for the specified `strategy`. The credentials to send depend on the authentication plugin and the strategy. - ---- - -## validateMyCredentials(strategy, credentials, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `strategy` | string | Strategy you want to create credentials in | -| `credentials` | JSON object | The credentials | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns true or false. - -## Usage - -<<< ./snippets/validate-my-credentials-1.js diff --git a/doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js b/doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js deleted file mode 100644 index 5d58fd2ff..000000000 --- a/doc/5/core-classes/kuzzle/validate-my-credentials/snippets/validate-my-credentials-1.js +++ /dev/null @@ -1,11 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.validateMyCredentials('local', {'username': 'foo'}, function (err, res) { - console.log(res); // true or false -}); - -// Using promises (node.js) -kuzzle - .validateMyCredentials('local', {'username': 'foo'}) - .then(res => { - console.log(res); // true or false - }); diff --git a/doc/5/core-classes/kuzzle/who-am-i/index.md b/doc/5/core-classes/kuzzle/who-am-i/index.md deleted file mode 100644 index da5d4ed9b..000000000 --- a/doc/5/core-classes/kuzzle/who-am-i/index.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -code: false -type: page -title: whoAmI -description: Kuzzle:whoAmI ---- - -# whoAmI - -Returns informations about the user who is currently loggedin. - ---- - -## whoAmI(callback) - -| Arguments | Type | Description | -| ---------- | -------- | ------------------------------ | -| `callback` | function | Callback handling the response | - ---- - -## Callback Response - -Returns an instantiated [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/who-am-i-1.js diff --git a/doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js b/doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js deleted file mode 100644 index 31befd392..000000000 --- a/doc/5/core-classes/kuzzle/who-am-i/snippets/who-am-i-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.whoAmI(function (err, result) { - // "result" is a User object -}); - -// Using promises (NodeJS only) -kuzzle.whoAmIPromise() - .then(res => { - // "res" is a User object - }); diff --git a/doc/5/core-classes/memory-storage/append/index.md b/doc/5/core-classes/memory-storage/append/index.md deleted file mode 100644 index c0f448827..000000000 --- a/doc/5/core-classes/memory-storage/append/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: append -description: MemoryStorage:append ---- - -# append - -Appends a value to a key. If the key does not exist, it is created. - -[[_Redis documentation_]](https://redis.io/commands/append) - ---- - -## append(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------- | -| `key` | string | Key identifier | -| `value` | string | Value to append to the key | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Return an integer containing the new length of the key's value. - -## Usage - -<<< ./snippets/append-1.js - -> Callback response: - -```json -5 -``` diff --git a/doc/5/core-classes/memory-storage/append/snippets/append-1.js b/doc/5/core-classes/memory-storage/append/snippets/append-1.js deleted file mode 100644 index 3dca48f14..000000000 --- a/doc/5/core-classes/memory-storage/append/snippets/append-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.append('key', 'value', function (err, newLength) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.appendPromise('key', 'value') - .then(newLength => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/append/snippets/append-2.js b/doc/5/core-classes/memory-storage/append/snippets/append-2.js deleted file mode 100644 index 151b916ea..000000000 --- a/doc/5/core-classes/memory-storage/append/snippets/append-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -5 diff --git a/doc/5/core-classes/memory-storage/bitcount/index.md b/doc/5/core-classes/memory-storage/bitcount/index.md deleted file mode 100644 index d8706973d..000000000 --- a/doc/5/core-classes/memory-storage/bitcount/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: bitcount -description: MemoryStorage:bitcount ---- - -# bitcount - -Counts the number of set bits (population counting) in a string. - -[[_Redis documentation_]](https://redis.io/commands/bitcount) - ---- - -## bitcount(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `end` | int | Ending offset | `-1` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `start` | int | Starting offset | `0` | - ---- - -## Callback Response - -Return an integer containing the count of set bits. - -## Usage - -<<< ./snippets/bitcount-1.js - -> Callback response: - -```json -21 -``` diff --git a/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js b/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js deleted file mode 100644 index 556ef98d9..000000000 --- a/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.bitcount('key', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.bitcountPromise('key') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js b/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js deleted file mode 100644 index edd1f5c86..000000000 --- a/doc/5/core-classes/memory-storage/bitcount/snippets/bitcount-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -21 diff --git a/doc/5/core-classes/memory-storage/bitop/index.md b/doc/5/core-classes/memory-storage/bitop/index.md deleted file mode 100644 index 0fc0ecaaa..000000000 --- a/doc/5/core-classes/memory-storage/bitop/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: bitop -description: MemoryStorage:bitop ---- - -# bitop - -Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key. - -[[_Redis documentation_]](https://redis.io/commands/bitop) - ---- - -## bitop(key, operation, keys, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | --------------------------------------------------------------------------- | -| `key` | string | Destination key identifier | -| `operation` | string | Bitwise operation to perform.
Allowed values: `AND`, `OR`, `XOR`, `NOT` | -| `keys` | array | list of source keys on which the bitwise operation will be applied | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the length of the new key's value. - -## Usage - -<<< ./snippets/bitop-1.js - -> Callback response: - -```json -42 -``` diff --git a/doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js b/doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js deleted file mode 100644 index 42302c9bc..000000000 --- a/doc/5/core-classes/memory-storage/bitop/snippets/bitop-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.bitop('key', 'AND', ['srckey1', 'srckey2', '...'], function (err, length) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.bitopPromise('key', 'AND', ['srckey1', 'srckey2', '...']) - .then(length => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js b/doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js deleted file mode 100644 index 37c3eb98c..000000000 --- a/doc/5/core-classes/memory-storage/bitop/snippets/bitop-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -42 diff --git a/doc/5/core-classes/memory-storage/bitpos/index.md b/doc/5/core-classes/memory-storage/bitpos/index.md deleted file mode 100644 index a97cf2347..000000000 --- a/doc/5/core-classes/memory-storage/bitpos/index.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -code: false -type: page -title: bitpos -description: MemoryStorage:bitpos ---- - -# bitpos - -Returns the position of the first bit set to 1 or 0 in a string, or in a substring. - -[[_Redis documentation_]](https://redis.io/commands/bitpos) - ---- - -## bitpos(key, bit, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `bit` | int | Bit to search.
Allowed values: `0`, `1` | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `end` | int | Ending offset | `-1` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `start` | int | Starting offset | `0` | - ---- - -## Callback Response - -Returns an integer containing the first position of the searched bit in the string value. - -## Usage - -<<< ./snippets/bitpos-1.js - -> Callback response: - -```json -0 -``` diff --git a/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js b/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js deleted file mode 100644 index ca2c8114d..000000000 --- a/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.bitpos('key', 0, function (err, position) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.bitpos('key', 0) - .then(position => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js b/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js deleted file mode 100644 index 41199acf8..000000000 --- a/doc/5/core-classes/memory-storage/bitpos/snippets/bitpos-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -0 diff --git a/doc/5/core-classes/memory-storage/constructor/index.md b/doc/5/core-classes/memory-storage/constructor/index.md deleted file mode 100644 index 25829924d..000000000 --- a/doc/5/core-classes/memory-storage/constructor/index.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -code: false -type: page -title: constructor -description: MemoryStorage:constructor -order: 1 ---- - -# Constructor - -Kuzzle's memory storage is a data store separate from the database layer. -It uses Redis internally, and most of its underlying functions are exposed by Kuzzle. - ---- - -## MemoryStorage(Kuzzle) - -| Arguments | Type | Description | -| --------- | ------ | ----------------------------------------------------- | -| `Kuzzle` | object | An instantiated [Kuzzle](/sdk/js/5/core-classes/kuzzle) SDK object | - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js b/doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js deleted file mode 100644 index cb06ac37e..000000000 --- a/doc/5/core-classes/memory-storage/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - Constructor is not exposed in the JS/Node SDK. You may get the instantiated - MemoryStorage object by calling Kuzzle.memoryStorage - */ -var memoryStorage = kuzzle.memoryStorage; diff --git a/doc/5/core-classes/memory-storage/dbsize/index.md b/doc/5/core-classes/memory-storage/dbsize/index.md deleted file mode 100644 index f56d31c29..000000000 --- a/doc/5/core-classes/memory-storage/dbsize/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: dbsize -description: MemoryStorage:dbsize ---- - -# dbsize - -Returns the number of keys in the application database. - -[[_Redis documentation_]](https://redis.io/commands/dbsize) - ---- - -## dbsize([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of keys in the application database. - -## Usage - -<<< ./snippets/dbsize-1.js - -> Callback response: - -```json -12 -``` diff --git a/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js b/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js deleted file mode 100644 index a8733f009..000000000 --- a/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.dbsize(function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.dbsize() - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js b/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js deleted file mode 100644 index a300bc6b4..000000000 --- a/doc/5/core-classes/memory-storage/dbsize/snippets/dbsize-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -12 diff --git a/doc/5/core-classes/memory-storage/decr/index.md b/doc/5/core-classes/memory-storage/decr/index.md deleted file mode 100644 index 1f3665a12..000000000 --- a/doc/5/core-classes/memory-storage/decr/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: decr -description: MemoryStorage:decr ---- - -# decr - -Decrements the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/decr) - ---- - -## decr(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated key value. - -## Usage - -<<< ./snippets/decr-1.js - -> Callback response: - -```json --1 -``` diff --git a/doc/5/core-classes/memory-storage/decr/snippets/decr-1.js b/doc/5/core-classes/memory-storage/decr/snippets/decr-1.js deleted file mode 100644 index 540c9fec1..000000000 --- a/doc/5/core-classes/memory-storage/decr/snippets/decr-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.decr('key', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.decrPromise('key') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/decr/snippets/decr-2.js b/doc/5/core-classes/memory-storage/decr/snippets/decr-2.js deleted file mode 100644 index 222304a0a..000000000 --- a/doc/5/core-classes/memory-storage/decr/snippets/decr-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on --1 diff --git a/doc/5/core-classes/memory-storage/decrby/index.md b/doc/5/core-classes/memory-storage/decrby/index.md deleted file mode 100644 index 3b944e405..000000000 --- a/doc/5/core-classes/memory-storage/decrby/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: decrby -description: MemoryStorage:decrby ---- - -# decrby - -Decrements the number stored at `key` by a provided integer value. If the key does not exist, it is set to 0 before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/decrby) - ---- - -## decrby(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `value` | int | Decrement value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated key value. - -## Usage - -<<< ./snippets/decrby-1.js - -> Callback response: - -```json -57 -``` diff --git a/doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js b/doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js deleted file mode 100644 index e4fc69cc7..000000000 --- a/doc/5/core-classes/memory-storage/decrby/snippets/decrby-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.decrby('key', 42, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.decrbyPromise('key', 42) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js b/doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js deleted file mode 100644 index f48a95b8f..000000000 --- a/doc/5/core-classes/memory-storage/decrby/snippets/decrby-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -57 diff --git a/doc/5/core-classes/memory-storage/del/index.md b/doc/5/core-classes/memory-storage/del/index.md deleted file mode 100644 index 28111fa9c..000000000 --- a/doc/5/core-classes/memory-storage/del/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: del -description: MemoryStorage:del ---- - -# del - -Deletes a list of keys. - -[[_Redis documentation_]](https://redis.io/commands/del) - ---- - -## del(keys, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------- | -| `keys` | array | List of keys to delete | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Return an integer containing the number of deleted keys. - -## Usage - -<<< ./snippets/del-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/del/snippets/del-1.js b/doc/5/core-classes/memory-storage/del/snippets/del-1.js deleted file mode 100644 index 849185f3d..000000000 --- a/doc/5/core-classes/memory-storage/del/snippets/del-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.del(['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.delPromise(['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/del/snippets/del-2.js b/doc/5/core-classes/memory-storage/del/snippets/del-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/del/snippets/del-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/exists/index.md b/doc/5/core-classes/memory-storage/exists/index.md deleted file mode 100644 index 7e1429376..000000000 --- a/doc/5/core-classes/memory-storage/exists/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: exists -description: MemoryStorage:exists ---- - -# exists - -Checks if the specified keys exist in the database. - -[[_Redis documentation_]](https://redis.io/commands/exists) - ---- - -## exists(keys, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------- | -| `keys` | array | List of keys to check for existence | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of existing keys amongst the provided list. - -## Usage - -<<< ./snippets/exists-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/exists/snippets/exists-1.js b/doc/5/core-classes/memory-storage/exists/snippets/exists-1.js deleted file mode 100644 index ae851b6ef..000000000 --- a/doc/5/core-classes/memory-storage/exists/snippets/exists-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.exists(['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.existsPromise(['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/exists/snippets/exists-2.js b/doc/5/core-classes/memory-storage/exists/snippets/exists-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/exists/snippets/exists-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/expire/index.md b/doc/5/core-classes/memory-storage/expire/index.md deleted file mode 100644 index 50f009038..000000000 --- a/doc/5/core-classes/memory-storage/expire/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: expire -description: MemoryStorage:expire ---- - -# expire - -Sets a timeout (in seconds) on a key. After the timeout has expired, the key will automatically be deleted. - -[[_Redis documentation_]](https://redis.io/commands/expire) - ---- - -## expire(key, seconds, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------ | -| `key` | string | Key identifier | -| `seconds` | int | Time to live, in seconds | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/expire-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/expire/snippets/expire-1.js b/doc/5/core-classes/memory-storage/expire/snippets/expire-1.js deleted file mode 100644 index a4f312e8b..000000000 --- a/doc/5/core-classes/memory-storage/expire/snippets/expire-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.expire('key', 42, function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.expirePromise('key', 42) - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/expire/snippets/expire-2.js b/doc/5/core-classes/memory-storage/expire/snippets/expire-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/expire/snippets/expire-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/expireat/index.md b/doc/5/core-classes/memory-storage/expireat/index.md deleted file mode 100644 index fd4d4a3e7..000000000 --- a/doc/5/core-classes/memory-storage/expireat/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: expireat -description: MemoryStorage:expireat ---- - -# expireat - -Sets an expiration timestamp on a key. After the timestamp has been reached, the key will automatically be deleted. -The `timestamp` parameter accepts an [Epoch time](https://en.wikipedia.org/wiki/Unix_time) value. - -[[_Redis documentation_]](https://redis.io/commands/expireat) - ---- - -## expireat(key, timestamp, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | -------------------- | -| `key` | string | Key identifier | -| `timestamp` | int | Expiration timestamp | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/expireat-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js b/doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js deleted file mode 100644 index c48464b33..000000000 --- a/doc/5/core-classes/memory-storage/expireat/snippets/expireat-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.expireat('key', 1488372354, function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.expireatPromise('key', 1488372354) - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js b/doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/expireat/snippets/expireat-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/flushdb/index.md b/doc/5/core-classes/memory-storage/flushdb/index.md deleted file mode 100644 index fea0cd9f5..000000000 --- a/doc/5/core-classes/memory-storage/flushdb/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: flushdb -description: MemoryStorage:flushdb ---- - -# flushdb - -Deletes all the keys of the database dedicated to client applications (the reserved space for Kuzzle is unaffected). - -[[_Redis documentation_]](https://redis.io/commands/flushdb) - ---- - -## flushdb([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/flushdb-1.js diff --git a/doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js b/doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js deleted file mode 100644 index 7488c9fed..000000000 --- a/doc/5/core-classes/memory-storage/flushdb/snippets/flushdb-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.flushdb(function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.flushdbPromise() - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/geoadd/index.md b/doc/5/core-classes/memory-storage/geoadd/index.md deleted file mode 100644 index 9afecc2ea..000000000 --- a/doc/5/core-classes/memory-storage/geoadd/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: geoadd -description: MemoryStorage:geoadd ---- - -# geoadd - -Adds geospatial points to the specified key. - -[[_Redis documentation_]](https://redis.io/commands/geoadd) - ---- - -## geoadd(key, points, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `key` | string | Destination key identifier | -| `points` | array of objects | List of geospatial points to add. Each point is described by a JSON object containing the following properties:
`lon` (longitude, `float`), `lat` (latitude, `float`), `name` (point identifier, `string`) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of points added to the key. - -## Usage - -<<< ./snippets/geoadd-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js b/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js deleted file mode 100644 index d58f22050..000000000 --- a/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-1.js +++ /dev/null @@ -1,23 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -var points = [ - { - lon: 13.361389, - lat: 38.115556, - name: 'Palermo' - }, - { - lon: 15.087269, - lat: 37.502669, - name: 'Catania' - } -]; - -kuzzle.memoryStorage.geoadd('key', points, function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.geoaddPromise('key', points) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js b/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/geoadd/snippets/geoadd-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/geodist/index.md b/doc/5/core-classes/memory-storage/geodist/index.md deleted file mode 100644 index 66fa1674c..000000000 --- a/doc/5/core-classes/memory-storage/geodist/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: geodist -description: MemoryStorage:geodist ---- - -# geodist - -Returns the distance between two geospatial members of a key (see [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)). -The returned distance is expressed in meters by default. - -[[_Redis documentation_]](https://redis.io/commands/geodist) - ---- - -## geodist(key, member1, member2, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------- | -| `key` | string | Key identifier | -| `member1` | string | Name of the first geospatial point | -| `member2` | string | Name of the second geospatial point | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `unit` | string | Distance unit.
Allowed values: `m`, `km`, `mi`, `ft` | `m` | - ---- - -## Callback Response - -Returns the calculated distance between the two provided geospatial points. - -## Usage - -<<< ./snippets/geodist-1.js - -> Callback response: - -```json -166274.1516 -``` diff --git a/doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js b/doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js deleted file mode 100644 index 88cdfb0cc..000000000 --- a/doc/5/core-classes/memory-storage/geodist/snippets/geodist-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.geodist('key', 'Palermo', 'Catania', function (err, distance) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.geodistPromise('key', 'Palermo', 'Catania') - .then(distance => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js b/doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js deleted file mode 100644 index 693f2c08d..000000000 --- a/doc/5/core-classes/memory-storage/geodist/snippets/geodist-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -166274.1516 diff --git a/doc/5/core-classes/memory-storage/geohash/index.md b/doc/5/core-classes/memory-storage/geohash/index.md deleted file mode 100644 index b8c934f64..000000000 --- a/doc/5/core-classes/memory-storage/geohash/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: geohash -description: MemoryStorage:geohash ---- - -# geohash - -Returns a valid [geohash](https://en.wikipedia.org/wiki/Geohash) for the provided key's members (see [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)). - -[[_Redis documentation_]](https://redis.io/commands/geohash) - ---- - -## geohash(key, members, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------------- | -| `key` | string | Key identifier | -| `members` | array | List of geospatial points contained in the key | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of geohashes, in the same order than the provided members list. - -## Usage - -<<< ./snippets/geohash-1.js - -> Callback response: - -```json -["sqc8b49rny0", "sqdtr74hyu0"] -``` diff --git a/doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js b/doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js deleted file mode 100644 index fc54fd8b1..000000000 --- a/doc/5/core-classes/memory-storage/geohash/snippets/geohash-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.geohash('key', ['Palermo', 'Catania'], function (err, hashes) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.geohashPromise('key', ['Palermo', 'Catania']) - .then(hashes => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js b/doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js deleted file mode 100644 index e12045358..000000000 --- a/doc/5/core-classes/memory-storage/geohash/snippets/geohash-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -["sqc8b49rny0", "sqdtr74hyu0"] diff --git a/doc/5/core-classes/memory-storage/geopos/index.md b/doc/5/core-classes/memory-storage/geopos/index.md deleted file mode 100644 index fc7c7b489..000000000 --- a/doc/5/core-classes/memory-storage/geopos/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: geopos -description: MemoryStorage:geopos ---- - -# geopos - -Returns the positions (longitude, latitude) of the provided key's members (see [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)). - -[[_Redis documentation_]](https://redis.io/commands/geopos) - ---- - -## geopos(key, members, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------------- | -| `key` | string | Key identifier | -| `members` | array | List of geospatial points contained in the key | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of longitude-latitude pairs, in the same order as the provided members list. - -## Usage - -<<< ./snippets/geopos-1.js - -> Callback response: - -```json -[[13.361389, 38.115556], [15.087269, 37.502669]] -``` diff --git a/doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js b/doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js deleted file mode 100644 index 5ceba6ff6..000000000 --- a/doc/5/core-classes/memory-storage/geopos/snippets/geopos-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.geopos('key', ['Palermo', 'Catania'], function (err, positions) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.geoposPromise('key', ['Palermo', 'Catania']) - .then(positions => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js b/doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js deleted file mode 100644 index 2e0bb3357..000000000 --- a/doc/5/core-classes/memory-storage/geopos/snippets/geopos-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -[ [13.361389, 38.115556], [15.087269, 37.502669]] diff --git a/doc/5/core-classes/memory-storage/georadius/index.md b/doc/5/core-classes/memory-storage/georadius/index.md deleted file mode 100644 index 8f24a2389..000000000 --- a/doc/5/core-classes/memory-storage/georadius/index.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -code: false -type: page -title: georadius -description: MemoryStorage:georadius ---- - -# georadius - -> Callback response, with no option provided: - -```json -[{ "name": "Palermo" }, { "name": "Catania" }] -``` - -> Callback response, with the "withcoord" option: - -```json -[ - { "name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963] }, - { "name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162] } -] -``` - -> Callback response, with the "withdist" option: - -```json -[ - { "name": "Palermo", "distance": 190.4424 }, - { "name": "Catania", "distance": 56.4413 } -] -``` - -Returns the members (added with [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)) of a given key inside the provided geospatial radius. - -[[_Redis documentation_]](https://redis.io/commands/georadius) - ---- - -## georadius(key, longitude, latitude, distance, unit, [options], callback) - -| Arguments | Type | Description | -| ----------- | ----------- | ------------------------------------- | -| `key` | string | Key identifier | -| `longitude` | double | Longitude of the center of the radius | -| `latitude` | double | Latitude of the center of the radius | -| `distance` | double | Maximum distance from the center | -| `unit` | string | Distance unit | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | -| `count` | int | Limit the result set to `count` members | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `sort` | string | Return items from the nearest to the farthest to the center (`ASC`) or vice versa (`DESC`) | `null` | -| `withcoord` | boolean | Also return the longitude and latitude coordinates of the matching items | `false` | -| `withdist` | boolean | Also return the distance of the returned items from the specified center, in the same unit than the one provided with `unit` | `false` | - ---- - -## Callback Response - -Returns an array of names for points that are inside the provided radius. - -## Usage - -<<< ./snippets/georadius-1.js diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js deleted file mode 100644 index 417ea2401..000000000 --- a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.georadius('key', 15, 37, 200, 'km', function (err, points) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.georadiusPromise('key', 15, 37, 200, 'km') - .then(points => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js deleted file mode 100644 index 814c3f98c..000000000 --- a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - {"name": "Palermo"}, - {"name": "Catania"} -] diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js deleted file mode 100644 index c2f47e84a..000000000 --- a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-3.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - {"name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963]}, - {"name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162]} -] diff --git a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js b/doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js deleted file mode 100644 index c57742f47..000000000 --- a/doc/5/core-classes/memory-storage/georadius/snippets/georadius-4.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - {"name": "Palermo", "distance": 190.4424}, - {"name": "Catania", "distance": 56.4413} -] diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/index.md b/doc/5/core-classes/memory-storage/georadiusbymember/index.md deleted file mode 100644 index 829fa499c..000000000 --- a/doc/5/core-classes/memory-storage/georadiusbymember/index.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -code: false -type: page -title: georadiusbymember -description: MemoryStorage:georadiusbymember ---- - -# georadiusbymember - -> Callback response, with the "withcoord" option: - -```json -[ - { "name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963] }, - { "name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162] } -] -``` - -> Callback response, with the "withdist" option: - -```json -[ - { "name": "Palermo", "distance": 190.4424 }, - { "name": "Catania", "distance": 56.4413 } -] -``` - -Returns the members (added with [geoadd](/sdk/js/5/core-classes/memory-storage/geoadd)) of a given key inside the provided geospatial radius, centered around one of a key's member. -[[_Redis documentation_]](https://redis.io/commands/georadiusbymember) - ---- - -## georadiusbymember(key, member, distance, unit, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------------------- | -| `key` | string | Key identifier | -| `member` | string | Name of the point to use as the center of the radius | -| `distance` | double | Maximum distance from the center | -| `unit` | string | Distance unit | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | -| `count` | int | Limit the result set to `count` members | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `sort` | string | Return items from the nearest to the farthest to the center (`ASC`) or vice versa (`DESC`) | `null` | -| `withcoord` | boolean | Also return the longitude and latitude coordinates of the matching items | `false` | -| `withdist` | boolean | Also return the distance of the returned items from the specified center, in the same unit than the one provided with `unit` | `false` | - ---- - -## Callback Response - -Returns an array of names for points that are inside the provided radius. - -## Usage - -<<< ./snippets/georadiusbymember-1.js - -> Callback response: - -```json -[{ "name": "Palermo" }, { "name": "Catania" }] -``` diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js deleted file mode 100644 index 1553ad7f1..000000000 --- a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.georadiusbymember('key', 'Palermo', 200, 'km', function (err, points) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.georadiusbymemberPromise('key', 'Palermo', 200, 'km') - .then(points => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js deleted file mode 100644 index 814c3f98c..000000000 --- a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - {"name": "Palermo"}, - {"name": "Catania"} -] diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js deleted file mode 100644 index c2f47e84a..000000000 --- a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-3.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - {"name": "Palermo", "coordinates": [13.361389338970184, 38.1155563954963]}, - {"name": "Catania", "coordinates": [15.087267458438873, 37.50266842333162]} -] diff --git a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js b/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js deleted file mode 100644 index c57742f47..000000000 --- a/doc/5/core-classes/memory-storage/georadiusbymember/snippets/georadiusbymember-4.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - {"name": "Palermo", "distance": 190.4424}, - {"name": "Catania", "distance": 56.4413} -] diff --git a/doc/5/core-classes/memory-storage/get/index.md b/doc/5/core-classes/memory-storage/get/index.md deleted file mode 100644 index 6efa32bae..000000000 --- a/doc/5/core-classes/memory-storage/get/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: get -description: MemoryStorage:get ---- - -# get - -Returns the value of a key, or null if the key doesn’t exist. - -[[_Redis documentation_]](https://redis.io/commands/get) - ---- - -## get(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the key's value. - -## Usage - -<<< ./snippets/get-1.js - -> Callback response: - -```json -"value" -``` diff --git a/doc/5/core-classes/memory-storage/get/snippets/get-1.js b/doc/5/core-classes/memory-storage/get/snippets/get-1.js deleted file mode 100644 index 88dc20a45..000000000 --- a/doc/5/core-classes/memory-storage/get/snippets/get-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.get('key', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.getPromise('key') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/get/snippets/get-2.js b/doc/5/core-classes/memory-storage/get/snippets/get-2.js deleted file mode 100644 index 232c95de2..000000000 --- a/doc/5/core-classes/memory-storage/get/snippets/get-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"value" diff --git a/doc/5/core-classes/memory-storage/getbit/index.md b/doc/5/core-classes/memory-storage/getbit/index.md deleted file mode 100644 index 056aee190..000000000 --- a/doc/5/core-classes/memory-storage/getbit/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: getbit -description: MemoryStorage:getbit ---- - -# getbit - -Returns the bit value at `offset`, in the string value stored in a key. - -[[_Redis documentation_]](https://redis.io/commands/getbit) - ---- - -## getbit(key, offset, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------- | -| `key` | string | Key identifier | -| `offset` | int | Offset position in the key's value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the bit value at the provided offset. - -## Usage - -<<< ./snippets/getbit-1.js - -> Callback response: - -```json -1 -``` diff --git a/doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js b/doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js deleted file mode 100644 index c34fc3b73..000000000 --- a/doc/5/core-classes/memory-storage/getbit/snippets/getbit-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.getbit('key', 10, function (err, bit) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.getbitPromise('key', 10) - .then(bit => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js b/doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js deleted file mode 100644 index b52a3a5b9..000000000 --- a/doc/5/core-classes/memory-storage/getbit/snippets/getbit-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -1 diff --git a/doc/5/core-classes/memory-storage/getrange/index.md b/doc/5/core-classes/memory-storage/getrange/index.md deleted file mode 100644 index 25f2f2a61..000000000 --- a/doc/5/core-classes/memory-storage/getrange/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: getrange -description: MemoryStorage:getrange ---- - -# getrange - -Returns a substring of a key's value (index starts at position `0`). - -[[_Redis documentation_]](https://redis.io/commands/getrange) - ---- - -## getrange(key, start, end, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `start` | int | Starting index | -| `end` | int | Ending index | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a substring of the key's value. - -## Usage - -<<< ./snippets/getrange-1.js - -> Callback response: - -```json -"lue" -``` diff --git a/doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js b/doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js deleted file mode 100644 index d95017c5c..000000000 --- a/doc/5/core-classes/memory-storage/getrange/snippets/getrange-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.getrange('key', 2, 4, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.getrangePromise('key', 2, 4) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js b/doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js deleted file mode 100644 index 2c016d6db..000000000 --- a/doc/5/core-classes/memory-storage/getrange/snippets/getrange-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"lue" diff --git a/doc/5/core-classes/memory-storage/getset/index.md b/doc/5/core-classes/memory-storage/getset/index.md deleted file mode 100644 index ae9ca06d8..000000000 --- a/doc/5/core-classes/memory-storage/getset/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: getset -description: MemoryStorage:getset ---- - -# getset - -Sets a new value for a key and returns its previous value. - -[[_Redis documentation_]](https://redis.io/commands/getset) - ---- - -## getset(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `value` | string | Key's new value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the key's previous value. - -## Usage - -<<< ./snippets/getset-1.js - -> Callback response: - -```json -"value" -``` diff --git a/doc/5/core-classes/memory-storage/getset/snippets/getset-1.js b/doc/5/core-classes/memory-storage/getset/snippets/getset-1.js deleted file mode 100644 index e7fa29268..000000000 --- a/doc/5/core-classes/memory-storage/getset/snippets/getset-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.getset('key', 'new value', function (err, oldValue) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.getsetPromise('key', 'new value') - .then(oldValue => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/getset/snippets/getset-2.js b/doc/5/core-classes/memory-storage/getset/snippets/getset-2.js deleted file mode 100644 index 232c95de2..000000000 --- a/doc/5/core-classes/memory-storage/getset/snippets/getset-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"value" diff --git a/doc/5/core-classes/memory-storage/hdel/index.md b/doc/5/core-classes/memory-storage/hdel/index.md deleted file mode 100644 index bb45ad605..000000000 --- a/doc/5/core-classes/memory-storage/hdel/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: hdel -description: MemoryStorage:hdel ---- - -# hdel - -Removes fields from a hash. - -[[_Redis documentation_]](https://redis.io/commands/hdel) - ---- - -## hdel(key, fields, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------- | -| `key` | string | Key identifier | -| `fields` | array | List of field names to delete | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the number of removed fields. - -## Usage - -<<< ./snippets/hdel-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js b/doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js deleted file mode 100644 index 0c5b40e42..000000000 --- a/doc/5/core-classes/memory-storage/hdel/snippets/hdel-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hdel('key', ['field1', 'field2'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hdelPromise('key', ['field1', 'field2']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js b/doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/hdel/snippets/hdel-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/hexists/index.md b/doc/5/core-classes/memory-storage/hexists/index.md deleted file mode 100644 index 3e94401ed..000000000 --- a/doc/5/core-classes/memory-storage/hexists/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: hexists -description: MemoryStorage:hexists ---- - -# hexists - -Checks if a field exists in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hexists) - ---- - -## hexists(key, field, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `field` | string | Field name | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -A boolean value specifying if the field exists or not. - -## Usage - -<<< ./snippets/hexists-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js b/doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js deleted file mode 100644 index 26c260fe7..000000000 --- a/doc/5/core-classes/memory-storage/hexists/snippets/hexists-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hexists('key', 'field1', function (err, exists) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hexistsPromise('key', 'field1') - .then(exists => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js b/doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/hexists/snippets/hexists-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/hget/index.md b/doc/5/core-classes/memory-storage/hget/index.md deleted file mode 100644 index 5322b41f1..000000000 --- a/doc/5/core-classes/memory-storage/hget/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: hget -description: MemoryStorage:hget ---- - -# hget - -Returns the field’s value of a hash. - -[[_Redis documentation_]](https://redis.io/commands/hget) - ---- - -## hget(key, field, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `field` | string | Field name | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the requested field's value. - -## Usage - -<<< ./snippets/hget-1.js - -> Callback response: - -```json -"foo" -``` diff --git a/doc/5/core-classes/memory-storage/hget/snippets/hget-1.js b/doc/5/core-classes/memory-storage/hget/snippets/hget-1.js deleted file mode 100644 index 461d8350a..000000000 --- a/doc/5/core-classes/memory-storage/hget/snippets/hget-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hget('key', 'field1', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hgetPromise('key', 'field1') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hget/snippets/hget-2.js b/doc/5/core-classes/memory-storage/hget/snippets/hget-2.js deleted file mode 100644 index f24302b01..000000000 --- a/doc/5/core-classes/memory-storage/hget/snippets/hget-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"foo" diff --git a/doc/5/core-classes/memory-storage/hgetall/index.md b/doc/5/core-classes/memory-storage/hgetall/index.md deleted file mode 100644 index 2418b5e26..000000000 --- a/doc/5/core-classes/memory-storage/hgetall/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: hgetall -description: MemoryStorage:hgetall ---- - -# hgetall - -Returns all fields and values of a hash. - -[[_Redis documentation_]](https://redis.io/commands/hgetall) - ---- - -## hgetall(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a JSON object containing the fields and values of a hash. - -## Usage - -<<< ./snippets/hgetall-1.js - -> Callback response: - -```json -{ - "field1": "value", - "field2": "value", - "...": "..." -} -``` diff --git a/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js b/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js deleted file mode 100644 index dab553b94..000000000 --- a/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hgetall('key', function (err, hash) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hgetallPromise('key') - .then(hash => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js b/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js deleted file mode 100644 index dfe6f2c8a..000000000 --- a/doc/5/core-classes/memory-storage/hgetall/snippets/hgetall-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -{ - "field1": "value", - "field2": "value", - "...": "..." -} diff --git a/doc/5/core-classes/memory-storage/hincrby/index.md b/doc/5/core-classes/memory-storage/hincrby/index.md deleted file mode 100644 index 9fd655fc6..000000000 --- a/doc/5/core-classes/memory-storage/hincrby/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: hincrby -description: MemoryStorage:hincrby ---- - -# hincrby - -Increments the number stored in a hash field by the provided integer value. - -[[_Redis documentation_]](https://redis.io/commands/hincrby) - ---- - -## hincrby(key, field, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------- | -| `key` | string | Key identifier | -| `field` | string | Hash field to increment | -| `value` | int | Increment value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the newly incremented value. - -## Usage - -<<< ./snippets/hincrby-1.js - -> Callback response: - -```json -45 -``` diff --git a/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js b/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js deleted file mode 100644 index b31e0f98f..000000000 --- a/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hincrby('key', 'field', 42, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hincrbyPromise('key', 'field', 42) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js b/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js deleted file mode 100644 index 8851a4c48..000000000 --- a/doc/5/core-classes/memory-storage/hincrby/snippets/hincrby-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -45 diff --git a/doc/5/core-classes/memory-storage/hincrbyfloat/index.md b/doc/5/core-classes/memory-storage/hincrbyfloat/index.md deleted file mode 100644 index 928ddf69b..000000000 --- a/doc/5/core-classes/memory-storage/hincrbyfloat/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: hincrbyfloat -description: MemoryStorage:hincrbyfloat ---- - -# hincrbyfloat - -Increments the number stored in a hash field by the provided float value. - -[[_Redis documentation_]](https://redis.io/commands/hincrbyfloat) - ---- - -## hincrbyfloat(key, field, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------- | -| `key` | string | Key identifier | -| `field` | string | Hash field to increment | -| `value` | double | Increment value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the newly incremented value, as a floating point number. - -## Usage - -<<< ./snippets/hincrbyfloat-1.js - -> Callback response: - -```json -48.14159 -``` diff --git a/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js b/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js deleted file mode 100644 index c3c07babc..000000000 --- a/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hincrbyfloat('key', 'field', 3.14159, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hincrbyfloatPromise('key', 'field', 3.14159) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js b/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js deleted file mode 100644 index 36507f180..000000000 --- a/doc/5/core-classes/memory-storage/hincrbyfloat/snippets/hincrbyfloat-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -48.14159 diff --git a/doc/5/core-classes/memory-storage/hkeys/index.md b/doc/5/core-classes/memory-storage/hkeys/index.md deleted file mode 100644 index 48642fcd3..000000000 --- a/doc/5/core-classes/memory-storage/hkeys/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: hkeys -description: MemoryStorage:hkeys ---- - -# hkeys - -Returns all field names contained in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hkeys) - ---- - -## hkeys(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of field names. - -## Usage - -<<< ./snippets/hkeys-1.js - -> Callback response: - -```json -["field1", "field2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js b/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js deleted file mode 100644 index 9733a9c40..000000000 --- a/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hkeys('key', function (err, fields) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hkeysPromise('key') - .then(fields => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js b/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js deleted file mode 100644 index 9ca12bcb4..000000000 --- a/doc/5/core-classes/memory-storage/hkeys/snippets/hkeys-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "field1", - "field2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/hlen/index.md b/doc/5/core-classes/memory-storage/hlen/index.md deleted file mode 100644 index df5c9e431..000000000 --- a/doc/5/core-classes/memory-storage/hlen/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: hlen -description: MemoryStorage:hlen ---- - -# hlen - -Returns the number of fields contained in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hlen) - ---- - -## hlen(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of fields in the hash. - -## Usage - -<<< ./snippets/hlen-1.js - -> Callback response: - -```json -13 -``` diff --git a/doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js b/doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js deleted file mode 100644 index 744995c88..000000000 --- a/doc/5/core-classes/memory-storage/hlen/snippets/hlen-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hlen('key', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hlenPromise('key') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js b/doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js deleted file mode 100644 index f1b8f19fe..000000000 --- a/doc/5/core-classes/memory-storage/hlen/snippets/hlen-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -13 diff --git a/doc/5/core-classes/memory-storage/hmget/index.md b/doc/5/core-classes/memory-storage/hmget/index.md deleted file mode 100644 index 5c1717013..000000000 --- a/doc/5/core-classes/memory-storage/hmget/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: hmget -description: MemoryStorage:hmget ---- - -# hmget - -Returns the values of the specified hash’s fields. - -[[_Redis documentation_]](https://redis.io/commands/hmget) - ---- - -## hmget(key, fields, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------- | -| `key` | string | Key identifier | -| `fields` | array | List of fields to examine | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array containing the specified fields values. - -## Usage - -<<< ./snippets/hmget-1.js - -> Callback response: - -```json -["field1's value", "field2's value", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js b/doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js deleted file mode 100644 index 2daf16594..000000000 --- a/doc/5/core-classes/memory-storage/hmget/snippets/hmget-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hmget('key', ['field1', 'field2', '...'], function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hmgetPromise('key', ['field1', 'field2', '...']) - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js b/doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js deleted file mode 100644 index 2091a55af..000000000 --- a/doc/5/core-classes/memory-storage/hmget/snippets/hmget-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "field1's value", - "field2's value", - "..." -] diff --git a/doc/5/core-classes/memory-storage/hmset/index.md b/doc/5/core-classes/memory-storage/hmset/index.md deleted file mode 100644 index cfd9485f1..000000000 --- a/doc/5/core-classes/memory-storage/hmset/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: hmset -description: MemoryStorage:hmset ---- - -# hmset - -Sets multiple fields at once in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hmset) - ---- - -## hmset(key, entries, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `key` | string | Key identifier | -| `entries` | array | List of fields to add, with their value. Each entry is described by a JSON object containing the following properties:
`field` (field name), `value` (field's value) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/hmset-1.js diff --git a/doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js b/doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js deleted file mode 100644 index f95b22c00..000000000 --- a/doc/5/core-classes/memory-storage/hmset/snippets/hmset-1.js +++ /dev/null @@ -1,16 +0,0 @@ -var entries = [ - {"field": "field1", "value": "foo"}, - {"field": "field2", "value": "bar"}, - {"field": "...", "value": "..."} -]; - -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hmset('key', entries, function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hmsetPromise('key', entries) - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hscan/index.md b/doc/5/core-classes/memory-storage/hscan/index.md deleted file mode 100644 index a22c45412..000000000 --- a/doc/5/core-classes/memory-storage/hscan/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: hscan -description: MemoryStorage:hscan ---- - -# hscan - -Identical to [scan](/sdk/js/5/core-classes/memory-storage/scan), except that `hscan` iterates over the fields contained in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hscan) - ---- - -## hscan(key, cursor, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | -| `key` | string | Key identifier | -| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------- | ------- | -| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | -| `match` | string | Search only for field names matching the provided pattern | `*` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object containing 2 entries: - -- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) -- an array of field names and values - -## Usage - -<<< ./snippets/hscan-1.js - -> Callback response: - -```json -{ - "cursor": 18, - "values": ["field1", "field1 value", "field2", "field2 value"] -} -``` diff --git a/doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js b/doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js deleted file mode 100644 index 7facec61c..000000000 --- a/doc/5/core-classes/memory-storage/hscan/snippets/hscan-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hscan('key', 0, function (err, page) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hscanPromise('key', 0) - .then(page => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js b/doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js deleted file mode 100644 index 1cfcb5088..000000000 --- a/doc/5/core-classes/memory-storage/hscan/snippets/hscan-2.js +++ /dev/null @@ -1,10 +0,0 @@ -on -{ - "cursor": 18, - "values": [ - "field1", - "field1 value", - "field2", - "field2 value" - ] -} diff --git a/doc/5/core-classes/memory-storage/hset/index.md b/doc/5/core-classes/memory-storage/hset/index.md deleted file mode 100644 index 681f1df14..000000000 --- a/doc/5/core-classes/memory-storage/hset/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: hset -description: MemoryStorage:hset ---- - -# hset - -Sets a field and its value in a hash. If the key does not exist, a new key holding a hash is created. If the field already exists, its value is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/hset) - ---- - -## hset(key, field, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------- | -| `key` | string | Key identifier | -| `field` | string | Field name to insert or to update | -| `value` | string | Associated field value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/hset-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/hset/snippets/hset-1.js b/doc/5/core-classes/memory-storage/hset/snippets/hset-1.js deleted file mode 100644 index d9ea2c703..000000000 --- a/doc/5/core-classes/memory-storage/hset/snippets/hset-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hset('key', 'field', 'value', function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hsetPromise('key', 'field', 'value') - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hset/snippets/hset-2.js b/doc/5/core-classes/memory-storage/hset/snippets/hset-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/hset/snippets/hset-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/hsetnx/index.md b/doc/5/core-classes/memory-storage/hsetnx/index.md deleted file mode 100644 index 967dae516..000000000 --- a/doc/5/core-classes/memory-storage/hsetnx/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: hsetnx -description: MemoryStorage:hsetnx ---- - -# hsetnx - -Sets a field and its value in a hash, only if the field does not already exist. - -[[_Redis documentation_]](https://redis.io/commands/hsetnx) - ---- - -## hsetnx(key, field, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------- | -| `key` | string | Key identifier | -| `field` | string | Field name to insert or to update | -| `value` | string | Associated field value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/hsetnx-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js b/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js deleted file mode 100644 index 60e63cf92..000000000 --- a/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hsetnx('key', 'field', 'value', function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hsetnxPromise('key', 'field', 'value') - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js b/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/hsetnx/snippets/hsetnx-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/hstrlen/index.md b/doc/5/core-classes/memory-storage/hstrlen/index.md deleted file mode 100644 index cf3896557..000000000 --- a/doc/5/core-classes/memory-storage/hstrlen/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: hstrlen -description: MemoryStorage:hstrlen ---- - -# hstrlen - -Returns the string length of a field’s value in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hstrlen) - ---- - -## hstrlen(key, field, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `field` | string | Hash field name | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the string length of a field's value. - -## Usage - -<<< ./snippets/hstrlen-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js b/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js deleted file mode 100644 index c40752775..000000000 --- a/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hstrlen('key', 'field', function (err, length) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hstrlenPromise('key', 'field') - .then(length => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js b/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/hstrlen/snippets/hstrlen-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/hvals/index.md b/doc/5/core-classes/memory-storage/hvals/index.md deleted file mode 100644 index 32037b88e..000000000 --- a/doc/5/core-classes/memory-storage/hvals/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: hvals -description: MemoryStorage:hvals ---- - -# hvals - -Returns all values contained in a hash. - -[[_Redis documentation_]](https://redis.io/commands/hvals) - ---- - -## hvals(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array containing the values of a hash. - -## Usage - -<<< ./snippets/hvals-1.js - -> Callback response: - -```json -["field1's value", "field2's value", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js b/doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js deleted file mode 100644 index de4bf1abd..000000000 --- a/doc/5/core-classes/memory-storage/hvals/snippets/hvals-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.hvals('key', function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.hvalsPromise('key') - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js b/doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js deleted file mode 100644 index 2091a55af..000000000 --- a/doc/5/core-classes/memory-storage/hvals/snippets/hvals-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "field1's value", - "field2's value", - "..." -] diff --git a/doc/5/core-classes/memory-storage/incr/index.md b/doc/5/core-classes/memory-storage/incr/index.md deleted file mode 100644 index 0a4e352d9..000000000 --- a/doc/5/core-classes/memory-storage/incr/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: incr -description: MemoryStorage:incr ---- - -# incr - -Increments the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/incr) - ---- - -## incr(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated key value. - -## Usage - -<<< ./snippets/incr-1.js - -> Callback response: - -```json -42 -``` diff --git a/doc/5/core-classes/memory-storage/incr/snippets/incr-1.js b/doc/5/core-classes/memory-storage/incr/snippets/incr-1.js deleted file mode 100644 index 4738ccff7..000000000 --- a/doc/5/core-classes/memory-storage/incr/snippets/incr-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.incr('key', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.incrPromise('key') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/incr/snippets/incr-2.js b/doc/5/core-classes/memory-storage/incr/snippets/incr-2.js deleted file mode 100644 index 37c3eb98c..000000000 --- a/doc/5/core-classes/memory-storage/incr/snippets/incr-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -42 diff --git a/doc/5/core-classes/memory-storage/incrby/index.md b/doc/5/core-classes/memory-storage/incrby/index.md deleted file mode 100644 index 1120542e1..000000000 --- a/doc/5/core-classes/memory-storage/incrby/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: incrby -description: MemoryStorage:incrby ---- - -# incrby - -Increments the number stored at `key` by the provided integer value. If the key does not exist, it is set to 0 before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/incrby) - ---- - -## incrby(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `value` | int | Increment value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated key value. - -## Usage - -<<< ./snippets/incrby-1.js - -> Callback response: - -```json -39 -``` diff --git a/doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js b/doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js deleted file mode 100644 index c000641e1..000000000 --- a/doc/5/core-classes/memory-storage/incrby/snippets/incrby-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.incrby('key', -3, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.incrbyPromise('key', -3) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js b/doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js deleted file mode 100644 index e16c5dd01..000000000 --- a/doc/5/core-classes/memory-storage/incrby/snippets/incrby-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -39 diff --git a/doc/5/core-classes/memory-storage/incrbyfloat/index.md b/doc/5/core-classes/memory-storage/incrbyfloat/index.md deleted file mode 100644 index 3e7c6b584..000000000 --- a/doc/5/core-classes/memory-storage/incrbyfloat/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: incrbyfloat -description: MemoryStorage:incrbyfloat ---- - -# incrbyfloat - -Increments the number stored at `key` by the provided float value. If the key does not exist, it is set to 0 before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/incrbyfloat) - ---- - -## incrbyfloat(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `value` | double | Increment value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a floating point number that contains the updated key value. - -## Usage - -<<< ./snippets/incrbyfloat-1.js - -> Callback response: - -```json -38.85841 -``` diff --git a/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js b/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js deleted file mode 100644 index 23a466e0b..000000000 --- a/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.incrbyfloat('key', -3.14159, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.incrbyfloatPromise('key', -3.14159) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js b/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js deleted file mode 100644 index ee0587c3d..000000000 --- a/doc/5/core-classes/memory-storage/incrbyfloat/snippets/incrbyfloat-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -38.85841 diff --git a/doc/5/core-classes/memory-storage/index.md b/doc/5/core-classes/memory-storage/index.md deleted file mode 100644 index 8cca5f310..000000000 --- a/doc/5/core-classes/memory-storage/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: MemoryStorage -description: MemoryStorage documentation ---- diff --git a/doc/5/core-classes/memory-storage/keys/index.md b/doc/5/core-classes/memory-storage/keys/index.md deleted file mode 100644 index 124460575..000000000 --- a/doc/5/core-classes/memory-storage/keys/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: keys -description: MemoryStorage:keys ---- - -# keys - -Returns all keys matching the provided pattern. - -[[_Redis documentation_]](https://redis.io/commands/keys) - ---- - -## keys(pattern, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------- | -| `pattern` | string | Pattern used to filter the returned key names | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of key names matching the provided pattern. - -## Usage - -<<< ./snippets/keys-1.js - -> Callback response: - -```json -["foo", "foobar", "foofighters"] -``` diff --git a/doc/5/core-classes/memory-storage/keys/snippets/keys-1.js b/doc/5/core-classes/memory-storage/keys/snippets/keys-1.js deleted file mode 100644 index 8f76af182..000000000 --- a/doc/5/core-classes/memory-storage/keys/snippets/keys-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.keys('foo*', function (err, keys) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.keysPromise('foo*') - .then(keys => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/keys/snippets/keys-2.js b/doc/5/core-classes/memory-storage/keys/snippets/keys-2.js deleted file mode 100644 index 20d7ee850..000000000 --- a/doc/5/core-classes/memory-storage/keys/snippets/keys-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "foo", - "foobar", - "foofighters" -] diff --git a/doc/5/core-classes/memory-storage/lindex/index.md b/doc/5/core-classes/memory-storage/lindex/index.md deleted file mode 100644 index 81d068f4c..000000000 --- a/doc/5/core-classes/memory-storage/lindex/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: lindex -description: MemoryStorage:lindex ---- - -# lindex - -Returns the element at the provided index in a list. - -[[_Redis documentation_]](https://redis.io/commands/lindex) - ---- - -## lindex(key, index, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------- | -| `key` | string | Key identifier | -| `index` | int | Element position in the list | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a string containing the retrieved element's value. - -## Usage - -<<< ./snippets/lindex-1.js - -> Callback response: - -```json -"foo" -``` diff --git a/doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js b/doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js deleted file mode 100644 index f6aee8d19..000000000 --- a/doc/5/core-classes/memory-storage/lindex/snippets/lindex-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lindex('key', 3, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lindexPromise('key', 3) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js b/doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js deleted file mode 100644 index f24302b01..000000000 --- a/doc/5/core-classes/memory-storage/lindex/snippets/lindex-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"foo" diff --git a/doc/5/core-classes/memory-storage/linsert/index.md b/doc/5/core-classes/memory-storage/linsert/index.md deleted file mode 100644 index 2a8f02880..000000000 --- a/doc/5/core-classes/memory-storage/linsert/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: linsert -description: MemoryStorage:linsert ---- - -# linsert - -Inserts a value in a list, either before or after the reference pivot value. - -[[_Redis documentation_]](https://redis.io/commands/linsert) - ---- - -## linsert(key, position, pivot, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------- | -| `key` | string | Key identifier | -| `position` | string | Indicates if the new value is to be inserted before or after the pivot value.
Allowed values: `before`, `after` | -| `pivot` | string | Pivot value used as a point of reference in the list | -| `value` | string | The value to insert | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated number of items in the list. - -## Usage - -<<< ./snippets/linsert-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js b/doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js deleted file mode 100644 index eceeb012f..000000000 --- a/doc/5/core-classes/memory-storage/linsert/snippets/linsert-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.linsert('key', 'after', 'foo', 'bar', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.linsertPromise('key', 'after', 'foo', 'bar') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js b/doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/linsert/snippets/linsert-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/llen/index.md b/doc/5/core-classes/memory-storage/llen/index.md deleted file mode 100644 index 680aad099..000000000 --- a/doc/5/core-classes/memory-storage/llen/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: llen -description: MemoryStorage:llen ---- - -# llen - -Counts the number of items in a list. - -[[_Redis documentation_]](https://redis.io/commands/llen) - ---- - -## llen(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of items of a list. - -## Usage - -<<< ./snippets/llen-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/llen/snippets/llen-1.js b/doc/5/core-classes/memory-storage/llen/snippets/llen-1.js deleted file mode 100644 index 2cdc6f787..000000000 --- a/doc/5/core-classes/memory-storage/llen/snippets/llen-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.llen('key', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.llenPromise('key') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/llen/snippets/llen-2.js b/doc/5/core-classes/memory-storage/llen/snippets/llen-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/llen/snippets/llen-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/lpop/index.md b/doc/5/core-classes/memory-storage/lpop/index.md deleted file mode 100644 index f1bbed674..000000000 --- a/doc/5/core-classes/memory-storage/lpop/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: lpop -description: MemoryStorage:lpop ---- - -# lpop - -Removes and returns the first element of a list. - -[[_Redis documentation_]](https://redis.io/commands/lpop) - ---- - -## lpop(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the value of the removed item. - -## Usage - -<<< ./snippets/lpop-1.js - -> Callback response: - -```json -"foo" -``` diff --git a/doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js b/doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js deleted file mode 100644 index 7de8b04fa..000000000 --- a/doc/5/core-classes/memory-storage/lpop/snippets/lpop-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lpop('key', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lpopPromise('key') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js b/doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js deleted file mode 100644 index f24302b01..000000000 --- a/doc/5/core-classes/memory-storage/lpop/snippets/lpop-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"foo" diff --git a/doc/5/core-classes/memory-storage/lpush/index.md b/doc/5/core-classes/memory-storage/lpush/index.md deleted file mode 100644 index e76093e27..000000000 --- a/doc/5/core-classes/memory-storage/lpush/index.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -code: false -type: page -title: lpush -description: MemoryStorage:lpush ---- - -# lpush - -Prepends the specified values to a list. If the key does not exist, it is created holding an empty list before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/lpush) - ---- - -## lpush(key, values, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------ | -| `key` | string | Key identifier | -| `values` | array | Values to add at the beginning of the list | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated number of items in the list. - -## Usage - -<<< ./snippets/lpush-1.js - -> Callback response: - -```json -6 -``` diff --git a/doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js b/doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js deleted file mode 100644 index dcceb1321..000000000 --- a/doc/5/core-classes/memory-storage/lpush/snippets/lpush-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lpush('key', ['foo', 'bar', 'baz'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lpushPromise('key', ['foo', 'bar', 'baz']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js b/doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js deleted file mode 100644 index eb054e2c9..000000000 --- a/doc/5/core-classes/memory-storage/lpush/snippets/lpush-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -6 diff --git a/doc/5/core-classes/memory-storage/lpushx/index.md b/doc/5/core-classes/memory-storage/lpushx/index.md deleted file mode 100644 index e35a3874f..000000000 --- a/doc/5/core-classes/memory-storage/lpushx/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: lpushx -description: MemoryStorage:lpushx ---- - -# lpushx - -Prepends the specified value to a list, only if the key already exists and if it holds a list. - -[[_Redis documentation_]](https://redis.io/commands/lpushx) - ---- - -## lpushx(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `key` | string | Key identifier | -| `value` | array | Value to add at the beginning of the list | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated number of items in the list. - -## Usage - -<<< ./snippets/lpushx-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js b/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js deleted file mode 100644 index 6402a95de..000000000 --- a/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lpushx('key', 'foo', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lpushxPromise('key', 'foo') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js b/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/lpushx/snippets/lpushx-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/lrange/index.md b/doc/5/core-classes/memory-storage/lrange/index.md deleted file mode 100644 index 7197445c8..000000000 --- a/doc/5/core-classes/memory-storage/lrange/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: lrange -description: MemoryStorage:lrange ---- - -# lrange - -Returns the list elements between the start and stop positions (inclusive). - -[[_Redis documentation_]](https://redis.io/commands/lrange) - ---- - -## lrange(key, start, stop, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `start` | int | Start position | -| `stop` | int | End position | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of retrieved values. - -## Usage - -<<< ./snippets/lrange-1.js - -> Callback response: - -```json -["foo", "bar"] -``` diff --git a/doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js b/doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js deleted file mode 100644 index f5d626418..000000000 --- a/doc/5/core-classes/memory-storage/lrange/snippets/lrange-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lrange('key', 0, 1, function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lrangePromise('key', 0, 1) - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js b/doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js deleted file mode 100644 index 40f7d1c40..000000000 --- a/doc/5/core-classes/memory-storage/lrange/snippets/lrange-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - "foo", - "bar" -] diff --git a/doc/5/core-classes/memory-storage/lrem/index.md b/doc/5/core-classes/memory-storage/lrem/index.md deleted file mode 100644 index 29f5f02ef..000000000 --- a/doc/5/core-classes/memory-storage/lrem/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: lrem -description: MemoryStorage:lrem ---- - -# lrem - -Removes the first `count` occurences of elements equal to `value` from a list. - -[[_Redis documentation_]](https://redis.io/commands/lrem) - ---- - -## lrem(key, count, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `count` | int | Number of occurences of the value to remove | -| `value` | string | Value to be removed from the list | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of removed elements. - -## Usage - -<<< ./snippets/lrem-1.js - -> Callback response: - -```json -1 -``` diff --git a/doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js b/doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js deleted file mode 100644 index 0edd79920..000000000 --- a/doc/5/core-classes/memory-storage/lrem/snippets/lrem-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lrem('key', 1, 'foo', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lremPromise('key', 1, 'foo') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js b/doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js deleted file mode 100644 index b52a3a5b9..000000000 --- a/doc/5/core-classes/memory-storage/lrem/snippets/lrem-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -1 diff --git a/doc/5/core-classes/memory-storage/lset/index.md b/doc/5/core-classes/memory-storage/lset/index.md deleted file mode 100644 index 8a00bee81..000000000 --- a/doc/5/core-classes/memory-storage/lset/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: lset -description: MemoryStorage:lset ---- - -# lset - -Sets the list element at `index` with the provided value. - -[[_Redis documentation_]](https://redis.io/commands/lset) - ---- - -## lset(key, index, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------ | -| `key` | string | Key identifier | -| `index` | int | Position of the list to update | -| `value` | string | New value at the provided list index | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/lset-1.js diff --git a/doc/5/core-classes/memory-storage/lset/snippets/lset-1.js b/doc/5/core-classes/memory-storage/lset/snippets/lset-1.js deleted file mode 100644 index e6d1e2dcd..000000000 --- a/doc/5/core-classes/memory-storage/lset/snippets/lset-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.lset('key', 2, 'bar', function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.lsetPromise('key', 2, 'bar') - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/ltrim/index.md b/doc/5/core-classes/memory-storage/ltrim/index.md deleted file mode 100644 index 0d8622dee..000000000 --- a/doc/5/core-classes/memory-storage/ltrim/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: ltrim -description: MemoryStorage:ltrim ---- - -# ltrim - -Trims an existing list so that it will contain only the specified range of elements specified. - -[[_Redis documentation_]](https://redis.io/commands/ltrim) - ---- - -## ltrim(key, start, stop, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------------- | -| `key` | string | Key identifier | -| `start` | int | Starting position of the range of items to keep (inclusive) | -| `stop` | int | Ending position of the range of items to keep (inclusive) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/ltrim-1.js diff --git a/doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js b/doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js deleted file mode 100644 index c71aa0893..000000000 --- a/doc/5/core-classes/memory-storage/ltrim/snippets/ltrim-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.ltrim('key', 1, 2, function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.ltrimPromise('key', 1, 2) - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/mget/index.md b/doc/5/core-classes/memory-storage/mget/index.md deleted file mode 100644 index 12214475f..000000000 --- a/doc/5/core-classes/memory-storage/mget/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: mget -description: MemoryStorage:mget ---- - -# mget - -Returns the values of the provided keys. - -[[_Redis documentation_]](https://redis.io/commands/mget) - ---- - -## mget(keys, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------ | -| `keys` | string | List of keys to retrieve | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of the specified keys' values. - -## Usage - -<<< ./snippets/mget-1.js - -> Callback response: - -```json -["key1's value", "key2's value", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/mget/snippets/mget-1.js b/doc/5/core-classes/memory-storage/mget/snippets/mget-1.js deleted file mode 100644 index 19c8fc02e..000000000 --- a/doc/5/core-classes/memory-storage/mget/snippets/mget-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.mget(['key1', 'key2', '...'], function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.mgetPromise(['key1', 'key2', '...']) - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/mget/snippets/mget-2.js b/doc/5/core-classes/memory-storage/mget/snippets/mget-2.js deleted file mode 100644 index dde14abc8..000000000 --- a/doc/5/core-classes/memory-storage/mget/snippets/mget-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "key1's value", - "key2's value", - "..." -] diff --git a/doc/5/core-classes/memory-storage/mset/index.md b/doc/5/core-classes/memory-storage/mset/index.md deleted file mode 100644 index e5dac6ff3..000000000 --- a/doc/5/core-classes/memory-storage/mset/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: mset -description: MemoryStorage:mset ---- - -# mset - -Sets the provided keys to their respective values. If a key does not exist, it is created. Otherwise, the key’s value is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/mset) - ---- - -## mset(entries, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `entries` | array | List of objects each containing the key identifier to add with its associated value.
Properties: `key` (key identifier), `value` (associated value) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/mset-1.js diff --git a/doc/5/core-classes/memory-storage/mset/snippets/mset-1.js b/doc/5/core-classes/memory-storage/mset/snippets/mset-1.js deleted file mode 100644 index b6fa0b3e0..000000000 --- a/doc/5/core-classes/memory-storage/mset/snippets/mset-1.js +++ /dev/null @@ -1,16 +0,0 @@ -var entries = [ - {key: 'key1', value: 'foo'}, - {key: 'key2', value: 'bar'}, - {key: '...', value: '...'} -]; - -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.mset(entries, function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.msetPromise(entries) - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/msetnx/index.md b/doc/5/core-classes/memory-storage/msetnx/index.md deleted file mode 100644 index bcf95432f..000000000 --- a/doc/5/core-classes/memory-storage/msetnx/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: msetnx -description: MemoryStorage:msetnx ---- - -# msetnx - -Sets the provided keys to their respective values, only if they do not exist. If a key exists, then the whole operation is aborted and no key is set. - -[[_Redis documentation_]](https://redis.io/commands/msetnx) - ---- - -## msetnx(entries, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `entries` | array | List of objects each containing the key identifier to add with its associated value.
Properties: `key` (key identifier), `value` (associated value) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/msetnx-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js b/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js deleted file mode 100644 index 76719e44b..000000000 --- a/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-1.js +++ /dev/null @@ -1,16 +0,0 @@ -var entries = [ - {key: 'key1', value: 'foo'}, - {key: 'key2', value: 'bar'}, - {key: '...', value: '...'} -]; - -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.msetnx(entries, function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.msetnxPromise(entries) - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js b/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/msetnx/snippets/msetnx-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/object/index.md b/doc/5/core-classes/memory-storage/object/index.md deleted file mode 100644 index 7d836228e..000000000 --- a/doc/5/core-classes/memory-storage/object/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: object -description: MemoryStorage:object ---- - -# object - -Inspects the low-level properties of a key. - -[[_Redis documentation_]](https://redis.io/commands/object) - ---- - -## object(key, subcommand, [options], callback) - -| Arguments | Type | Description | -| ------------ | ----------- | ------------------------------------------------------------------------------------------------- | -| `key` | string | Key identifier | -| `subcommand` | string | Name of the low-level property to inspect.
Allowed values: `refcount`, `encoding`, `idletime` | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the value of the inspected property. - -## Usage - -<<< ./snippets/object-1.js - -> Callback response: - -```json -"raw" -``` diff --git a/doc/5/core-classes/memory-storage/object/snippets/object-1.js b/doc/5/core-classes/memory-storage/object/snippets/object-1.js deleted file mode 100644 index eb7772c75..000000000 --- a/doc/5/core-classes/memory-storage/object/snippets/object-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.object('key', 'encoding', function (err, property) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.objectPromise('key', 'encoding') - .then(property => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/object/snippets/object-2.js b/doc/5/core-classes/memory-storage/object/snippets/object-2.js deleted file mode 100644 index 59e8899c6..000000000 --- a/doc/5/core-classes/memory-storage/object/snippets/object-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"raw" diff --git a/doc/5/core-classes/memory-storage/persist/index.md b/doc/5/core-classes/memory-storage/persist/index.md deleted file mode 100644 index 50d26e174..000000000 --- a/doc/5/core-classes/memory-storage/persist/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: persist -description: MemoryStorage:persist ---- - -# persist - -Removes the expiration delay or timestamp from a key, making it persistent. - -[[_Redis documentation_]](https://redis.io/commands/persist) - ---- - -## persist(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/persist-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/persist/snippets/persist-1.js b/doc/5/core-classes/memory-storage/persist/snippets/persist-1.js deleted file mode 100644 index 88143a266..000000000 --- a/doc/5/core-classes/memory-storage/persist/snippets/persist-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.persist('key', function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.persistPromise('key') - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/persist/snippets/persist-2.js b/doc/5/core-classes/memory-storage/persist/snippets/persist-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/persist/snippets/persist-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/pexpire/index.md b/doc/5/core-classes/memory-storage/pexpire/index.md deleted file mode 100644 index 57757e0b7..000000000 --- a/doc/5/core-classes/memory-storage/pexpire/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: pexpire -description: MemoryStorage:pexpire ---- - -# pexpire - -Sets a timeout (in milliseconds) on a key. After the timeout has expired, the key will automatically be deleted. - -[[_Redis documentation_]](https://redis.io/commands/pexpire) - ---- - -## pexpire(key, ttl, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------- | -| `key` | string | Key identifier | -| `ttl` | int | Time to live of the key, in milliseconds | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/pexpire-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js b/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js deleted file mode 100644 index 76c8a0ba4..000000000 --- a/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.pexpire('key', 42000, function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pexpirePromise('key', 42000) - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js b/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/pexpire/snippets/pexpire-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/pexpireat/index.md b/doc/5/core-classes/memory-storage/pexpireat/index.md deleted file mode 100644 index 584e13120..000000000 --- a/doc/5/core-classes/memory-storage/pexpireat/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: pexpireat -description: MemoryStorage:pexpireat ---- - -# pexpireat - -Sets an expiration timestamp on a key. After the timestamp has been reached, the key will automatically be deleted. -The `timestamp` parameter accepts an [Epoch time](https://en.wikipedia.org/wiki/Unix_time) value, in milliseconds. - -[[_Redis documentation_]](https://redis.io/commands/pexpireat) - ---- - -## pexpireat(key, timestamp, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `timestamp` | int | Key's expiration timestamp, in milliseconds | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/pexpireat-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js b/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js deleted file mode 100644 index 26c040991..000000000 --- a/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.pexpireat('key', 1488540242465, function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pexpireatPromise('key', 1488540242465) - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js b/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/pexpireat/snippets/pexpireat-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/pfadd/index.md b/doc/5/core-classes/memory-storage/pfadd/index.md deleted file mode 100644 index d1298f3e2..000000000 --- a/doc/5/core-classes/memory-storage/pfadd/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: pfadd -description: MemoryStorage:pfadd ---- - -# pfadd - -Adds elements to an [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure. - -[[_Redis documentation_]](https://redis.io/commands/pfadd) - ---- - -## pfadd(key, elements, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------- | -| `key` | string | Key identifier | -| `elements` | array | Elements to add to the HyperLogLog structure | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/pfadd-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js b/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js deleted file mode 100644 index 1d2e9e7d5..000000000 --- a/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.pfadd('key', ['foo', 'bar', 'baz'], function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pfaddPromise('key', ['foo', 'bar', 'baz']) - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js b/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/pfadd/snippets/pfadd-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/pfcount/index.md b/doc/5/core-classes/memory-storage/pfcount/index.md deleted file mode 100644 index 1d0e36b2c..000000000 --- a/doc/5/core-classes/memory-storage/pfcount/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: pfcount -description: MemoryStorage:pfcount ---- - -# pfcount - -Returns the probabilistic cardinality of a [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure, or of the merged HyperLogLog structures if more than 1 is provided (see [pfadd](/sdk/js/5/core-classes/memory-storage/pfadd)). - -[[_Redis documentation_]](https://redis.io/commands/pfcount) - ---- - -## pfcount(keys, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------- | -| `keys` | string | List of HyperLogLog key identifiers | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the aggregated probabilistic cardinality of HyperLogLog structures. - -## Usage - -<<< ./snippets/pfcount-1.js - -> Callback response: - -```json -42 -``` diff --git a/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js b/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js deleted file mode 100644 index 6ee5d9765..000000000 --- a/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.pfcount(['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pfcountPromise(['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js b/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js deleted file mode 100644 index 37c3eb98c..000000000 --- a/doc/5/core-classes/memory-storage/pfcount/snippets/pfcount-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -42 diff --git a/doc/5/core-classes/memory-storage/pfmerge/index.md b/doc/5/core-classes/memory-storage/pfmerge/index.md deleted file mode 100644 index cc0ba41a2..000000000 --- a/doc/5/core-classes/memory-storage/pfmerge/index.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -code: false -type: page -title: pfmerge -description: MemoryStorage:pfmerge ---- - -# pfmerge - -Merges multiple [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structures into an unique HyperLogLog structure stored at `key`, approximating the cardinality of the union of the source structures. - -[[_Redis documentation_]](https://redis.io/commands/pfmerge) - ---- - -## pfmerge(key, sources, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------ | -| `key` | string | Destination key identifier | -| `sources` | string | List of HyperLogLog source key identifiers | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/pfmerge-1.js diff --git a/doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js b/doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js deleted file mode 100644 index ef22a9359..000000000 --- a/doc/5/core-classes/memory-storage/pfmerge/snippets/pfmerge-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.pfmerge('key', ['key1', 'key2', '...'], function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pfmergePromise('key', ['key1', 'key2', '...']) - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/ping/index.md b/doc/5/core-classes/memory-storage/ping/index.md deleted file mode 100644 index 44ea61ff7..000000000 --- a/doc/5/core-classes/memory-storage/ping/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: ping -description: MemoryStorage:ping ---- - -# ping - -Pings the memory storage database. - -[[_Redis documentation_]](https://redis.io/commands/ping) - ---- - -## ping([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a simple "PONG" string. - -## Usage - -<<< ./snippets/ping-1.js - -> Callback response: - -```json -"PONG" -``` diff --git a/doc/5/core-classes/memory-storage/ping/snippets/ping-1.js b/doc/5/core-classes/memory-storage/ping/snippets/ping-1.js deleted file mode 100644 index 6f9f8e273..000000000 --- a/doc/5/core-classes/memory-storage/ping/snippets/ping-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.ping(function (err, response) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pingPromise() - .then(response => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/ping/snippets/ping-2.js b/doc/5/core-classes/memory-storage/ping/snippets/ping-2.js deleted file mode 100644 index ef9b43de6..000000000 --- a/doc/5/core-classes/memory-storage/ping/snippets/ping-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"PONG" diff --git a/doc/5/core-classes/memory-storage/psetex/index.md b/doc/5/core-classes/memory-storage/psetex/index.md deleted file mode 100644 index 1bbb33cb7..000000000 --- a/doc/5/core-classes/memory-storage/psetex/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: psetex -description: MemoryStorage:psetex ---- - -# psetex - -Sets a key with the provided value, and an expiration delay expressed in milliseconds. If the key does not exist, it is created beforehand. - -[[_Redis documentation_]](https://redis.io/commands/psetex) - ---- - -## psetex(key, value, ttl, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------- | -| `key` | string | Key identifier | -| `value` | string | Value to set | -| `ttl` | int | Time to live of the key, in milliseconds | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/psetex-1.js diff --git a/doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js b/doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js deleted file mode 100644 index 322d8d30c..000000000 --- a/doc/5/core-classes/memory-storage/psetex/snippets/psetex-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.psetex('key', 'value', 42000, function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.psetexPromise('key', 'value', 42000) - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/pttl/index.md b/doc/5/core-classes/memory-storage/pttl/index.md deleted file mode 100644 index 009463f8b..000000000 --- a/doc/5/core-classes/memory-storage/pttl/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: pttl -description: MemoryStorage:pttl ---- - -# pttl - -Returns the remaining time to live of a key, in milliseconds. - -[[_Redis documentation_]](https://redis.io/commands/pttl) - ---- - -## pttl(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the remaining time to live of the key, in milliseconds. - -## Usage - -<<< ./snippets/pttl-1.js - -> Callback response: - -```json -43159 -``` diff --git a/doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js b/doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js deleted file mode 100644 index b596c3544..000000000 --- a/doc/5/core-classes/memory-storage/pttl/snippets/pttl-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.pttl('key', function (err, ttl) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.pttlPromise('key') - .then(ttl => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js b/doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js deleted file mode 100644 index 839222ead..000000000 --- a/doc/5/core-classes/memory-storage/pttl/snippets/pttl-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -43159 diff --git a/doc/5/core-classes/memory-storage/randomkey/index.md b/doc/5/core-classes/memory-storage/randomkey/index.md deleted file mode 100644 index b3ccbfce6..000000000 --- a/doc/5/core-classes/memory-storage/randomkey/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: randomkey -description: MemoryStorage:randomkey ---- - -# randomkey - -Returns a random key from the memory storage. - -[[_Redis documentation_]](https://redis.io/commands/randomkey) - ---- - -## randomkey([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns one of the stored key names, at random. - -## Usage - -<<< ./snippets/randomkey-1.js - -> Callback response: - -```json -"key2" -``` diff --git a/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js b/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js deleted file mode 100644 index 0c2bb2d31..000000000 --- a/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.randomkey(function (err, key) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.randomkeyPromise() - .then(key => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js b/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js deleted file mode 100644 index 682be0988..000000000 --- a/doc/5/core-classes/memory-storage/randomkey/snippets/randomkey-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"key2" diff --git a/doc/5/core-classes/memory-storage/rename/index.md b/doc/5/core-classes/memory-storage/rename/index.md deleted file mode 100644 index 5d2e410f8..000000000 --- a/doc/5/core-classes/memory-storage/rename/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: rename -description: MemoryStorage:rename ---- - -# rename - -Renames a key to `newkey`. If `newkey` already exists, it is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/rename) - ---- - -## rename(key, newkey, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `newkey` | string | New key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/rename-1.js diff --git a/doc/5/core-classes/memory-storage/rename/snippets/rename-1.js b/doc/5/core-classes/memory-storage/rename/snippets/rename-1.js deleted file mode 100644 index ebd89d174..000000000 --- a/doc/5/core-classes/memory-storage/rename/snippets/rename-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.rename('key', 'newId', function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.renamePromise('key', 'newId') - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/renamenx/index.md b/doc/5/core-classes/memory-storage/renamenx/index.md deleted file mode 100644 index af2ad4dd0..000000000 --- a/doc/5/core-classes/memory-storage/renamenx/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: renamenx -description: MemoryStorage:renamenx ---- - -# renamenx - -Renames a key to `newkey`, only if `newkey` does not already exist. - -[[_Redis documentation_]](https://redis.io/commands/renamenx) - ---- - -## renamenx(key, newkey, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `newkey` | string | New key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/renamenx-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js b/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js deleted file mode 100644 index 24151ddf0..000000000 --- a/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.renamenx('key', 'newId', function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.renamenxPromise('key', 'newId') - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js b/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/renamenx/snippets/renamenx-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/rpop/index.md b/doc/5/core-classes/memory-storage/rpop/index.md deleted file mode 100644 index 0c18a7e88..000000000 --- a/doc/5/core-classes/memory-storage/rpop/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: rpop -description: MemoryStorage:rpop ---- - -# rpop - -Removes and returns the last element of a list. - -[[_Redis documentation_]](https://redis.io/commands/rpop) - ---- - -## rpop(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the value of the removed item. - -## Usage - -<<< ./snippets/rpop-1.js - -> Callback response: - -```json -"foo" -``` diff --git a/doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js b/doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js deleted file mode 100644 index b6a5fcd50..000000000 --- a/doc/5/core-classes/memory-storage/rpop/snippets/rpop-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.rpop('key', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.rpopPromise('key') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js b/doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js deleted file mode 100644 index f24302b01..000000000 --- a/doc/5/core-classes/memory-storage/rpop/snippets/rpop-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"foo" diff --git a/doc/5/core-classes/memory-storage/rpoplpush/index.md b/doc/5/core-classes/memory-storage/rpoplpush/index.md deleted file mode 100644 index 3afc95506..000000000 --- a/doc/5/core-classes/memory-storage/rpoplpush/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: rpoplpush -description: MemoryStorage:rpoplpush ---- - -# rpoplpush - -Removes the last element of the list at `source` and pushes it back at the start of the list at `destination`. - -[[_Redis documentation_]](https://redis.io/commands/rpoplpush) - ---- - -## rpoplpush(source, destination, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | -------------------------- | -| `source` | string | Source key identifier | -| `destination` | string | Destination key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns the value of the removed and pushed item. - -## Usage - -<<< ./snippets/rpoplpush-1.js - -> Callback response: - -```json -"foo" -``` diff --git a/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js b/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js deleted file mode 100644 index ca762bdab..000000000 --- a/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.rpoplpush('sourceKey', 'destKey', function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.rpoplpushPromise('sourceKey', 'destKey') - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js b/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js deleted file mode 100644 index f24302b01..000000000 --- a/doc/5/core-classes/memory-storage/rpoplpush/snippets/rpoplpush-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"foo" diff --git a/doc/5/core-classes/memory-storage/rpush/index.md b/doc/5/core-classes/memory-storage/rpush/index.md deleted file mode 100644 index 034ab8686..000000000 --- a/doc/5/core-classes/memory-storage/rpush/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: rpush -description: MemoryStorage:rpush ---- - -# rpush - -Appends the specified values at the end of a list. If the key does not exist, it is created holding an empty list before performing the operation. - -[[_Redis documentation_]](https://redis.io/commands/rpush) - ---- - -## rpush(key, values, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------ | -| `key` | string | Key identifier | -| `values` | array | Values to add at the end of the list | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated number of items in the list. - -## Usage - -<<< ./snippets/rpush-1.js - -> Callback response: - -```json -6 -``` diff --git a/doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js b/doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js deleted file mode 100644 index e1661871a..000000000 --- a/doc/5/core-classes/memory-storage/rpush/snippets/rpush-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.rpush('key', ['foo', 'bar', 'baz'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.rpushPromise('key', ['foo', 'bar', 'baz']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js b/doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js deleted file mode 100644 index eb054e2c9..000000000 --- a/doc/5/core-classes/memory-storage/rpush/snippets/rpush-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -6 diff --git a/doc/5/core-classes/memory-storage/rpushx/index.md b/doc/5/core-classes/memory-storage/rpushx/index.md deleted file mode 100644 index 5a16c6f9c..000000000 --- a/doc/5/core-classes/memory-storage/rpushx/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: rpushx -description: MemoryStorage:rpushx ---- - -# rpushx - -Appends the specified value at the end of a list, only if the key already exists and if it holds a list. - -[[_Redis documentation_]](https://redis.io/commands/rpushx) - ---- - -## rpushx(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------- | -| `key` | string | Key identifier | -| `value` | string | Value to add at the end of the list | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the updated number of items in the list. - -## Usage - -<<< ./snippets/rpushx-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js b/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js deleted file mode 100644 index 995e4a6bf..000000000 --- a/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.rpushx('key', 'foo', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.rpushxPromise('key', 'foo') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js b/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/rpushx/snippets/rpushx-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/sadd/index.md b/doc/5/core-classes/memory-storage/sadd/index.md deleted file mode 100644 index cd72c8e58..000000000 --- a/doc/5/core-classes/memory-storage/sadd/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: sadd -description: MemoryStorage:sadd ---- - -# sadd - -Adds members to a set of unique values stored at `key`. If the `key` does not exist, it is created beforehand. - -[[_Redis documentation_]](https://redis.io/commands/sadd) - ---- - -## sadd(key, members, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `members` | array | Members to add to the list of unique values | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of added elements to the set. - -## Usage - -<<< ./snippets/sadd-1.js - -> Callback response: - -```json -6 -``` diff --git a/doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js b/doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js deleted file mode 100644 index 72f38b802..000000000 --- a/doc/5/core-classes/memory-storage/sadd/snippets/sadd-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sadd('key', ['foo', 'bar', 'baz'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.saddPromise('key', ['foo', 'bar', 'baz']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js b/doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js deleted file mode 100644 index eb054e2c9..000000000 --- a/doc/5/core-classes/memory-storage/sadd/snippets/sadd-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -6 diff --git a/doc/5/core-classes/memory-storage/scan/index.md b/doc/5/core-classes/memory-storage/scan/index.md deleted file mode 100644 index 16c98f17a..000000000 --- a/doc/5/core-classes/memory-storage/scan/index.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -code: false -type: page -title: scan -description: MemoryStorage:scan ---- - -# scan - -Iterates incrementally over the set of keys in the database using a cursor. - -An iteration starts when the cursor is set to `0`. -To get the next page of results, simply re-send the identical request with the updated cursor position provided in the result set. -The scan terminates when the next position cursor returned by the server is `0`. - -[[_Redis documentation_]](https://redis.io/commands/scan) - ---- - -## scan(cursor, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | -| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------- | ------- | -| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | -| `match` | string | Search only for field names matching the provided pattern | `*` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a JSON object containing 2 entries: - -- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) -- a list of fetched keys - -## Usage - -<<< ./snippets/scan-1.js - -> Callback response: - -```json -{ - "cursor": 18, - "values": ["key1", "key2", "..."] -} -``` diff --git a/doc/5/core-classes/memory-storage/scan/snippets/scan-1.js b/doc/5/core-classes/memory-storage/scan/snippets/scan-1.js deleted file mode 100644 index fbede7508..000000000 --- a/doc/5/core-classes/memory-storage/scan/snippets/scan-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.scan(0, function (err, page) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.scanPromise(0) - .then(page => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/scan/snippets/scan-2.js b/doc/5/core-classes/memory-storage/scan/snippets/scan-2.js deleted file mode 100644 index a244e04b7..000000000 --- a/doc/5/core-classes/memory-storage/scan/snippets/scan-2.js +++ /dev/null @@ -1,9 +0,0 @@ -on -{ - "cursor": 18, - "values": [ - "key1", - "key2", - "..." - ] -} diff --git a/doc/5/core-classes/memory-storage/scard/index.md b/doc/5/core-classes/memory-storage/scard/index.md deleted file mode 100644 index a23f6cbe7..000000000 --- a/doc/5/core-classes/memory-storage/scard/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: scard -description: MemoryStorage:scard ---- - -# scard - -Returns the number of members stored in a set of unique values. - -[[_Redis documentation_]](https://redis.io/commands/scard) - ---- - -## scard(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of items in the set. - -## Usage - -<<< ./snippets/scard-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/scard/snippets/scard-1.js b/doc/5/core-classes/memory-storage/scard/snippets/scard-1.js deleted file mode 100644 index bf37bd413..000000000 --- a/doc/5/core-classes/memory-storage/scard/snippets/scard-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.scard('key', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.scardPromise('key') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/scard/snippets/scard-2.js b/doc/5/core-classes/memory-storage/scard/snippets/scard-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/scard/snippets/scard-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/sdiff/index.md b/doc/5/core-classes/memory-storage/sdiff/index.md deleted file mode 100644 index fdd23d0a3..000000000 --- a/doc/5/core-classes/memory-storage/sdiff/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: sdiff -description: MemoryStorage:sdiff ---- - -# sdiff - -Returns the difference between the set of unique values stored at `key` and the other provided sets. - -[[_Redis documentation_]](https://redis.io/commands/sdiff) - ---- - -## sdiff(key, keys, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------- | -| `key` | string | Key identifier to compare | -| `keys` | array | list of set keys to compare with the set stored at `key` | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of differences. - -## Usage - -<<< ./snippets/sdiff-1.js - -> Callback response: - -```json -["diff value1", "diff value2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js b/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js deleted file mode 100644 index c822d0c2b..000000000 --- a/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sdiff('key', ['key1', 'key2', '...'], function (err, diff) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sdiffPromise('key', ['key1', 'key2', '...']) - .then(diff => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js b/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js deleted file mode 100644 index 79759d7ea..000000000 --- a/doc/5/core-classes/memory-storage/sdiff/snippets/sdiff-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "diff value1", - "diff value2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/sdiffstore/index.md b/doc/5/core-classes/memory-storage/sdiffstore/index.md deleted file mode 100644 index 1c720b8e4..000000000 --- a/doc/5/core-classes/memory-storage/sdiffstore/index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -code: false -type: page -title: sdiffstore -description: MemoryStorage:sdiffstore ---- - -# sdiffstore - -Computes the difference between the set of unique values stored at `key` and the other provided sets, and stores the result in the key stored at `destination`. - -If the `destination` key already exists, it is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/sdiffstore) - ---- - -## sdiffstore(key, keys, destination, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | -------------------------------------------------------- | -| `key` | string | Key identifier to compare | -| `keys` | array | list of set keys to compare with the set stored at `key` | -| `destination` | string | Destination key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of stored elements. - -## Usage - -<<< ./snippets/sdiffstore-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js b/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js deleted file mode 100644 index 9bb9345be..000000000 --- a/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sdiffstore('key', ['key1', 'key2', '...'], 'destination', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sdiffstorePromise('key', ['key1', 'key2', '...'], 'destination') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js b/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/sdiffstore/snippets/sdiffstore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/set/index.md b/doc/5/core-classes/memory-storage/set/index.md deleted file mode 100644 index 8815f244a..000000000 --- a/doc/5/core-classes/memory-storage/set/index.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -code: false -type: page -title: set -description: MemoryStorage:set ---- - -# set - -Creates a key holding the provided value, or overwrites it if it already exists. - -[[_Redis documentation_]](https://redis.io/commands/set) - ---- - -## set(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `value` | string | Value to store | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------------------- | ------- | -| `ex` | int | Time to live of the key, in seconds | `0` | -| `nx` | boolean | Set the key only if it does not already exist | `false` | -| `px` | int | Time to live of the key, in milliseconds | `0` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `xx` | boolean | Set the key only if it already exists | `false` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/set-1.js diff --git a/doc/5/core-classes/memory-storage/set/snippets/set-1.js b/doc/5/core-classes/memory-storage/set/snippets/set-1.js deleted file mode 100644 index 77e4992ad..000000000 --- a/doc/5/core-classes/memory-storage/set/snippets/set-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.set('key', 'value', function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.setPromise('key', 'value') - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/setex/index.md b/doc/5/core-classes/memory-storage/setex/index.md deleted file mode 100644 index 57147ef96..000000000 --- a/doc/5/core-classes/memory-storage/setex/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: setex -description: MemoryStorage:setex ---- - -# setex - -Sets a key with the provided value, and an expiration delay expressed in seconds. If the key does not exist, it is created beforehand. - -[[_Redis documentation_]](https://redis.io/commands/setex) - ---- - -## setex(key, value, ttl, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------- | -| `key` | string | Key identifier | -| `value` | string | Value to set | -| `ttl` | int | Time to live of the key, in seconds | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns null if successful. - -## Usage - -<<< ./snippets/setex-1.js diff --git a/doc/5/core-classes/memory-storage/setex/snippets/setex-1.js b/doc/5/core-classes/memory-storage/setex/snippets/setex-1.js deleted file mode 100644 index a30ffec20..000000000 --- a/doc/5/core-classes/memory-storage/setex/snippets/setex-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.setex('key', 'value', 42, function (err) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.setexPromise('key', 'value', 42) - .then(() => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/setnx/index.md b/doc/5/core-classes/memory-storage/setnx/index.md deleted file mode 100644 index 91be4558d..000000000 --- a/doc/5/core-classes/memory-storage/setnx/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: setnx -description: MemoryStorage:setnx ---- - -# setnx - -Sets a value on a key, only if it does not already exist. - -[[_Redis documentation_]](https://redis.io/commands/setnx) - ---- - -## setnx(key, value, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `value` | string | Value to store | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/setnx-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js b/doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js deleted file mode 100644 index fa3b0ee98..000000000 --- a/doc/5/core-classes/memory-storage/setnx/snippets/setnx-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.setnx('key', 'value', function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.setnxPromise('key', 'value') - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js b/doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/setnx/snippets/setnx-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/sinter/index.md b/doc/5/core-classes/memory-storage/sinter/index.md deleted file mode 100644 index 90ceee157..000000000 --- a/doc/5/core-classes/memory-storage/sinter/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: sinter -description: MemoryStorage:sinter ---- - -# sinter - -Returns the intersection of the provided sets of unique values. - -[[_Redis documentation_]](https://redis.io/commands/sinter) - ---- - -## sinter(keys, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------ | -| `keys` | string | List of sets of unique values to intersect | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of values in the computed intersection. - -## Usage - -<<< ./snippets/sinter-1.js - -> Callback response: - -```json -["intersection value1", "intersection value2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js b/doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js deleted file mode 100644 index 4830f1e50..000000000 --- a/doc/5/core-classes/memory-storage/sinter/snippets/sinter-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sinter(['key1', 'key2', '...'], function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sinterPromise(['key1', 'key2', '...']) - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js b/doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js deleted file mode 100644 index f05b38176..000000000 --- a/doc/5/core-classes/memory-storage/sinter/snippets/sinter-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "intersection value1", - "intersection value2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/sinterstore/index.md b/doc/5/core-classes/memory-storage/sinterstore/index.md deleted file mode 100644 index 6b7242a96..000000000 --- a/doc/5/core-classes/memory-storage/sinterstore/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: sinterstore -description: MemoryStorage:sinterstore ---- - -# sinterstore - -Computes the intersection of the provided sets of unique values and stores the result in the `destination` key. - -If the destination key already exists, it is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/sinterstore) - ---- - -## sinterstore(destination, keys, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `destination` | string | Destination key identifier | -| `keys` | array | List of sets of unique values to intersect | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of elements in the stored intersection. - -## Usage - -<<< ./snippets/sinterstore-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js b/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js deleted file mode 100644 index ade6374b4..000000000 --- a/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sinterstore('destination', ['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sinterstorePromise('destination', ['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js b/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/sinterstore/snippets/sinterstore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/sismember/index.md b/doc/5/core-classes/memory-storage/sismember/index.md deleted file mode 100644 index 3141f1ac9..000000000 --- a/doc/5/core-classes/memory-storage/sismember/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: sismember -description: MemoryStorage:sismember ---- - -# sismember - -Checks if `member` is a member of the set of unique values stored at `key`. - -[[_Redis documentation_]](https://redis.io/commands/sismember) - ---- - -## sismember(key, member, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------- | -| `key` | string | Key identifier | -| `member` | string | Value tested against the set of unique values | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a boolean specifying if `member` is a member of the set or not. - -## Usage - -<<< ./snippets/sismember-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js b/doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js deleted file mode 100644 index ba27cd1d0..000000000 --- a/doc/5/core-classes/memory-storage/sismember/snippets/sismember-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sismember('key', 'member', function (err, isMember) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sismemberPromise('key', 'member') - .then(isMember => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js b/doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/sismember/snippets/sismember-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/smembers/index.md b/doc/5/core-classes/memory-storage/smembers/index.md deleted file mode 100644 index 8f9c77d38..000000000 --- a/doc/5/core-classes/memory-storage/smembers/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: smembers -description: MemoryStorage:smembers ---- - -# smembers - -Returns the members of a set of unique values. - -[[_Redis documentation_]](https://redis.io/commands/smembers) - ---- - -## smembers(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of values held by the provided set. - -## Usage - -<<< ./snippets/smembers-1.js - -> Callback response: - -```json -["member1", "member2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js b/doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js deleted file mode 100644 index 62c102e80..000000000 --- a/doc/5/core-classes/memory-storage/smembers/snippets/smembers-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.smembers('key', function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.smembersPromise('key') - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js b/doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js deleted file mode 100644 index 395de0670..000000000 --- a/doc/5/core-classes/memory-storage/smembers/snippets/smembers-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "member1", - "member2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/smove/index.md b/doc/5/core-classes/memory-storage/smove/index.md deleted file mode 100644 index 33f2b7b34..000000000 --- a/doc/5/core-classes/memory-storage/smove/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: smove -description: MemoryStorage:smove ---- - -# smove - -Moves a member from a set of unique values to another. - -[[_Redis documentation_]](https://redis.io/commands/smove) - ---- - -## smove(key, destination, member, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | -------------------------- | -| `key` | string | Source key identifier | -| `destination` | string | Destination key identifier | -| `member` | string | Member to be moved | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a boolean specifying if the operation was successful or not. - -## Usage - -<<< ./snippets/smove-1.js - -> Callback response: - -```json -true -``` diff --git a/doc/5/core-classes/memory-storage/smove/snippets/smove-1.js b/doc/5/core-classes/memory-storage/smove/snippets/smove-1.js deleted file mode 100644 index e3f85e36c..000000000 --- a/doc/5/core-classes/memory-storage/smove/snippets/smove-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.smove('key', 'destination', 'member', function (err, status) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.smovePromise('key', 'destination', 'member') - .then(status => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/smove/snippets/smove-2.js b/doc/5/core-classes/memory-storage/smove/snippets/smove-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/memory-storage/smove/snippets/smove-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/memory-storage/sort/index.md b/doc/5/core-classes/memory-storage/sort/index.md deleted file mode 100644 index afec34dbc..000000000 --- a/doc/5/core-classes/memory-storage/sort/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: sort -description: MemoryStorage:sort ---- - -# sort - -Sorts and returns elements contained in a list, a set of unique values or a sorted set. -By default, sorting is numeric and elements are compared by their value interpreted as double precision floating point number. - -
-While Kuzzle's API supports the "store" option for this command, Kuzzle SDK methods do not. To sort and store in the same process, use the [query method](/sdk/js/5/core-classes/kuzzle/query) -
- -[[_Redis documentation_]](https://redis.io/commands/sort) - -### sort(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `alpha` | boolean | Perform an alphanumerical sort instead of a numeric one | `false` | -| `by` | string | Instead of sorting the values stored at `key`, use them to complete the provided key pattern, and return the sorted list of values stored in those keys. | `null` | -| `direction` | string | Sort in ascendant (`ASC`) or descendant (`DESC`) order | `ASC` | -| `get` | array | Sort the values stored at `key` but, instead of returning these directly, return the values contained in external keys, using the provided array of patterns completed by the sorted values | `null` | -| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - -### Callback Response - -Returns an array of sorted values. - -## Usage - -<<< ./snippets/sort-1.js - -> Callback response: - -```json -["sorted element1", "sorted element2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/sort/snippets/sort-1.js b/doc/5/core-classes/memory-storage/sort/snippets/sort-1.js deleted file mode 100644 index 61c4b1ce9..000000000 --- a/doc/5/core-classes/memory-storage/sort/snippets/sort-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sort('key', function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sortPromise('key') - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sort/snippets/sort-2.js b/doc/5/core-classes/memory-storage/sort/snippets/sort-2.js deleted file mode 100644 index c864c8a17..000000000 --- a/doc/5/core-classes/memory-storage/sort/snippets/sort-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "sorted element1", - "sorted element2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/spop/index.md b/doc/5/core-classes/memory-storage/spop/index.md deleted file mode 100644 index a2a8687e9..000000000 --- a/doc/5/core-classes/memory-storage/spop/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: spop -description: MemoryStorage:spop ---- - -# spop - -Removes and returns one or more elements at random from a set of unique values. - -[[_Redis documentation_]](https://redis.io/commands/spop) - ---- - -## spop(key, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `count` | int | Number of elements to remove | `1` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of removed elements. - -## Usage - -<<< ./snippets/spop-1.js - -> Callback response: - -```json -["removed element"] -``` diff --git a/doc/5/core-classes/memory-storage/spop/snippets/spop-1.js b/doc/5/core-classes/memory-storage/spop/snippets/spop-1.js deleted file mode 100644 index 95bf62c3a..000000000 --- a/doc/5/core-classes/memory-storage/spop/snippets/spop-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.spop('key', function (err, elements) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.spopPromise('key') - .then(elements => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/spop/snippets/spop-2.js b/doc/5/core-classes/memory-storage/spop/snippets/spop-2.js deleted file mode 100644 index 781ac6cc2..000000000 --- a/doc/5/core-classes/memory-storage/spop/snippets/spop-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -[ "removed element" ] diff --git a/doc/5/core-classes/memory-storage/srandmember/index.md b/doc/5/core-classes/memory-storage/srandmember/index.md deleted file mode 100644 index e4dc0efb1..000000000 --- a/doc/5/core-classes/memory-storage/srandmember/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: srandmember -description: MemoryStorage:srandmember ---- - -# srandmember - -Returns one or more members of a set of unique values, at random. -If `count` is provided and is positive, the returned values are unique. If `count` is negative, a set member can be returned multiple times. - -[[_Redis documentation_]](https://redis.io/commands/srandmember) - ---- - -## srandmember(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `count` | int | Number of members to return. If set with a positive value, the returned values are unique. If `count` is negative, a set member can be returned multiple times | `1` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of members of a set of unique values. - -## Usage - -<<< ./snippets/srandmember-1.js - -> Callback response: - -```json -["member1", "member2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js b/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js deleted file mode 100644 index 0f798f5cc..000000000 --- a/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.srandmember('key', function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.srandmemberPromise('key') - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js b/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js deleted file mode 100644 index 395de0670..000000000 --- a/doc/5/core-classes/memory-storage/srandmember/snippets/srandmember-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "member1", - "member2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/srem/index.md b/doc/5/core-classes/memory-storage/srem/index.md deleted file mode 100644 index f99083caf..000000000 --- a/doc/5/core-classes/memory-storage/srem/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: srem -description: MemoryStorage:srem ---- - -# srem - -Removes members from a set of unique values. - -[[_Redis documentation_]](https://redis.io/commands/srem) - ---- - -## srem(key, members, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------- | -| `key` | string | Key identifier | -| `members` | array | List of members to remove from the set | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of removed elements. - -## Usage - -<<< ./snippets/srem-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/srem/snippets/srem-1.js b/doc/5/core-classes/memory-storage/srem/snippets/srem-1.js deleted file mode 100644 index 26c454584..000000000 --- a/doc/5/core-classes/memory-storage/srem/snippets/srem-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.srem('key', ['member1', 'member2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sremPromise('key', ['member1', 'member2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/srem/snippets/srem-2.js b/doc/5/core-classes/memory-storage/srem/snippets/srem-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/srem/snippets/srem-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/sscan/index.md b/doc/5/core-classes/memory-storage/sscan/index.md deleted file mode 100644 index e10263a64..000000000 --- a/doc/5/core-classes/memory-storage/sscan/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: sscan -description: MemoryStorage:sscan ---- - -# sscan - -Identical to [scan](/sdk/js/5/core-classes/memory-storage/scan), except that `sscan` iterates the members held by a set of unique values. - -[[_Redis documentation_]](https://redis.io/commands/sscan) - ---- - -## sscan(key, cursor, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | -| `key` | string | Key identifier | -| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------- | ------- | -| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | -| `match` | string | Search only for member values matching the provided pattern | `*` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a JSON array containing 2 entries: - -- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) -- an array of members - -## Usage - -<<< ./snippets/sscan-1.js - -> Callback response: - -```json -{ - "cursor": 18, - "values": ["member1", "member2", "..."] -} -``` diff --git a/doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js b/doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js deleted file mode 100644 index e547fda85..000000000 --- a/doc/5/core-classes/memory-storage/sscan/snippets/sscan-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sscan('key', 0, function (err, page) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sscanPromise('key', 0) - .then(page => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js b/doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js deleted file mode 100644 index 6cefe3d94..000000000 --- a/doc/5/core-classes/memory-storage/sscan/snippets/sscan-2.js +++ /dev/null @@ -1,9 +0,0 @@ -on -{ - "cursor": 18, - "values": [ - "member1", - "member2", - "..." - ] -} diff --git a/doc/5/core-classes/memory-storage/strlen/index.md b/doc/5/core-classes/memory-storage/strlen/index.md deleted file mode 100644 index 4613199fc..000000000 --- a/doc/5/core-classes/memory-storage/strlen/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: strlen -description: MemoryStorage:strlen ---- - -# strlen - -Returns the length of a value stored at `key`. - -[[_Redis documentation_]](https://redis.io/commands/strlen) - ---- - -## strlen(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the length of a value. - -## Usage - -<<< ./snippets/strlen-1.js - -> Callback response: - -```json -13 -``` diff --git a/doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js b/doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js deleted file mode 100644 index 758284a04..000000000 --- a/doc/5/core-classes/memory-storage/strlen/snippets/strlen-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.strlen('key', function (err, length) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.strlenPromise('key') - .then(length => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js b/doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js deleted file mode 100644 index f1b8f19fe..000000000 --- a/doc/5/core-classes/memory-storage/strlen/snippets/strlen-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -13 diff --git a/doc/5/core-classes/memory-storage/sunion/index.md b/doc/5/core-classes/memory-storage/sunion/index.md deleted file mode 100644 index 49300d91c..000000000 --- a/doc/5/core-classes/memory-storage/sunion/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: sunion -description: MemoryStorage:sunion ---- - -# sunion - -Returns the union of the provided sets of unique values. - -[[_Redis documentation_]](https://redis.io/commands/sunion) - ---- - -## sunion(keys, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------- | -| `keys` | string | List of sets of unique values | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of values in the computed union. - -## Usage - -<<< ./snippets/sunion-1.js - -> Callback response: - -```json -["union value1", "union value2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js b/doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js deleted file mode 100644 index 07c13c595..000000000 --- a/doc/5/core-classes/memory-storage/sunion/snippets/sunion-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sunion(['key1', 'key2', '...'], function (err, values) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sunionPromise(['key1', 'key2', '...']) - .then(values => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js b/doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js deleted file mode 100644 index 193bfbf2a..000000000 --- a/doc/5/core-classes/memory-storage/sunion/snippets/sunion-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "union value1", - "union value2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/sunionstore/index.md b/doc/5/core-classes/memory-storage/sunionstore/index.md deleted file mode 100644 index 2eb6ace32..000000000 --- a/doc/5/core-classes/memory-storage/sunionstore/index.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -code: false -type: page -title: sunionstore -description: MemoryStorage:sunionstore ---- - -# sunionstore - -Computes the union of the provided sets of unique values and stores the result in the `destination` key. - -If the destination key already exists, it is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/sunionstore) - ---- - -## sunionstore(destination, keys, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `destination` | string | Destination key identifier | -| `keys` | string | List of sets of unique values to intersect | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of elements in the stored union. - -## Usage - -<<< ./snippets/sunionstore-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js b/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js deleted file mode 100644 index 9a392200b..000000000 --- a/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.sunionstore('destination', ['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.sunionstorePromise('destination', ['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js b/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/sunionstore/snippets/sunionstore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/time/index.md b/doc/5/core-classes/memory-storage/time/index.md deleted file mode 100644 index c314b07b1..000000000 --- a/doc/5/core-classes/memory-storage/time/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: time -description: MemoryStorage:time ---- - -# time - -Returns the current server time. - -[[_Redis documentation_]](https://redis.io/commands/time) - ---- - -## time([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array containing the following two items, in this order: - -- a timestamp in [Epoch time](https://en.wikipedia.org/wiki/Unix_time) -- the number of microseconds already elapsed in the current second - -## Usage - -<<< ./snippets/time-1.js - -> Callback response: - -```json -[1488791347, 494938] -``` diff --git a/doc/5/core-classes/memory-storage/time/snippets/time-1.js b/doc/5/core-classes/memory-storage/time/snippets/time-1.js deleted file mode 100644 index 8a99b5f70..000000000 --- a/doc/5/core-classes/memory-storage/time/snippets/time-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.time(function (err, result) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.timePromise() - .then(result => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/time/snippets/time-2.js b/doc/5/core-classes/memory-storage/time/snippets/time-2.js deleted file mode 100644 index dcfc96b5c..000000000 --- a/doc/5/core-classes/memory-storage/time/snippets/time-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - 1488791347, - 494938 -] diff --git a/doc/5/core-classes/memory-storage/touch/index.md b/doc/5/core-classes/memory-storage/touch/index.md deleted file mode 100644 index 84394ff64..000000000 --- a/doc/5/core-classes/memory-storage/touch/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -code: false -type: page -title: touch -description: MemoryStorage:touch ---- - -# touch - -Alters the last access time of one or multiple keys. A key is ignored if it does not exist. - -[[_Redis documentation_]](https://redis.io/commands/touch) - ---- - -## touch(keys, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------- | -| `keys` | array | List of keys to alter | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of altered keys. - -## Usage - -<<< ./snippets/touch-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/touch/snippets/touch-1.js b/doc/5/core-classes/memory-storage/touch/snippets/touch-1.js deleted file mode 100644 index d88a95c02..000000000 --- a/doc/5/core-classes/memory-storage/touch/snippets/touch-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.touch(['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.touchPromise(['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/touch/snippets/touch-2.js b/doc/5/core-classes/memory-storage/touch/snippets/touch-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/touch/snippets/touch-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/ttl/index.md b/doc/5/core-classes/memory-storage/ttl/index.md deleted file mode 100644 index 6f5fd3aeb..000000000 --- a/doc/5/core-classes/memory-storage/ttl/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: ttl -description: MemoryStorage:ttl ---- - -# ttl - -Returns the remaining time to live of a key, in seconds, or a negative value if the key does not exist or if it is persistent. - -[[_Redis documentation_]](https://redis.io/commands/ttl) - ---- - -## ttl(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the remaining time to live of the key, in seconds. - -## Usage - -<<< ./snippets/ttl-1.js - -> Callback response: - -```json -42 -``` diff --git a/doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js b/doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js deleted file mode 100644 index c6b300fd5..000000000 --- a/doc/5/core-classes/memory-storage/ttl/snippets/ttl-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.ttl('key', function (err, ttl) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.ttlPromise('key') - .then(ttl => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js b/doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js deleted file mode 100644 index 37c3eb98c..000000000 --- a/doc/5/core-classes/memory-storage/ttl/snippets/ttl-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -42 diff --git a/doc/5/core-classes/memory-storage/type/index.md b/doc/5/core-classes/memory-storage/type/index.md deleted file mode 100644 index 08bdfdf23..000000000 --- a/doc/5/core-classes/memory-storage/type/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: type -description: MemoryStorage:type ---- - -# type - -Returns the type of the value held by a key. - -[[_Redis documentation_]](https://redis.io/commands/type) - ---- - -## type(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns one of the following values: `hash`, `list`, `set`, `string`, `zset`. - -## Usage - -<<< ./snippets/type-1.js - -> Callback response: - -```json -"zset" -``` diff --git a/doc/5/core-classes/memory-storage/type/snippets/type-1.js b/doc/5/core-classes/memory-storage/type/snippets/type-1.js deleted file mode 100644 index eba024d6f..000000000 --- a/doc/5/core-classes/memory-storage/type/snippets/type-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.type('key', function (err, type) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.typePromise('key') - .then(type => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/type/snippets/type-2.js b/doc/5/core-classes/memory-storage/type/snippets/type-2.js deleted file mode 100644 index 31d71e164..000000000 --- a/doc/5/core-classes/memory-storage/type/snippets/type-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"zset" diff --git a/doc/5/core-classes/memory-storage/zadd/index.md b/doc/5/core-classes/memory-storage/zadd/index.md deleted file mode 100644 index 6cc639388..000000000 --- a/doc/5/core-classes/memory-storage/zadd/index.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -code: false -type: page -title: zadd -description: MemoryStorage:zadd ---- - -# zadd - -Adds the specified elements to the sorted set stored at `key`. If the key does not exist, it is created, holding an empty sorted set. If it already exists and does not hold a sorted set, an error is returned. - -Scores are expressed as floating point numbers. - -If a member to insert is already in the sorted set, its score is updated and the member is reinserted at the right position in the set. - -[[_Redis documentation_]](https://redis.io/commands/zadd) - ---- - -## zadd(key, elements, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `key` | string | Key identifier | -| `elements` | array | List of JSON objects detailing the element to add to the sorted set.
Properties: `score` (element's score, `double`), `member` (element's value, `string`) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `ch` | boolean | Instead of returning the number of added allements, return the total number of changes performed (including updates) | `false` | -| `incr` | boolean | Instead of adding elements, increment the existing member with the provided `score` value. Only one score+element pair can be specified if this option is set | `false` | -| `nx` | boolean | Only add new elements, do not update existing ones | `false` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `xx` | boolean | Never add new elements, update only exiting ones | `false` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of elements added to the sorted set. - -## Usage - -<<< ./snippets/zadd-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js b/doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js deleted file mode 100644 index 664f564ed..000000000 --- a/doc/5/core-classes/memory-storage/zadd/snippets/zadd-1.js +++ /dev/null @@ -1,16 +0,0 @@ -var elements = [ - {'score': 1, 'member': 'foo'}, - {'score': 2, 'member': 'bar'}, - {'score': 3, 'member': 'baz'} -]; - -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zadd('key', elements, function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zaddPromise('key', elements) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js b/doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/zadd/snippets/zadd-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/zcard/index.md b/doc/5/core-classes/memory-storage/zcard/index.md deleted file mode 100644 index 47621abac..000000000 --- a/doc/5/core-classes/memory-storage/zcard/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: zcard -description: MemoryStorage:zcard ---- - -# zcard - -Returns the number of elements held by a sorted set. - -[[_Redis documentation_]](https://redis.io/commands/zcard) - ---- - -## zcard(key, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of elements in a sorted set. - -## Usage - -<<< ./snippets/zcard-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js b/doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js deleted file mode 100644 index c899ebc01..000000000 --- a/doc/5/core-classes/memory-storage/zcard/snippets/zcard-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zcard('key', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zcardPromise('key') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js b/doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/zcard/snippets/zcard-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/zcount/index.md b/doc/5/core-classes/memory-storage/zcount/index.md deleted file mode 100644 index 8d591f9af..000000000 --- a/doc/5/core-classes/memory-storage/zcount/index.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -code: false -type: page -title: zcount -description: MemoryStorage:zcount ---- - -# zcount - -Returns the number of elements held by a sorted set with a score between the provided `min` and `max` values. - -By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYSCORE](https://redis.io/commands/zrangebyscore) documentation. - -[[_Redis documentation_]](https://redis.io/commands/zcount) - ---- - -## zcount(key, min, max, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------ | -| `key` | string | Key identifier | -| `min` | int | Minimum score (inclusive by default) | -| `max` | int | Maximum score (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of elements in the provided score range. - -## Usage - -<<< ./snippets/zcount-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js b/doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js deleted file mode 100644 index bf8f41c1e..000000000 --- a/doc/5/core-classes/memory-storage/zcount/snippets/zcount-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zcount('key', 2, 3, function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zcountPromise('key', 2, 3) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js b/doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/zcount/snippets/zcount-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/zincrby/index.md b/doc/5/core-classes/memory-storage/zincrby/index.md deleted file mode 100644 index f53708851..000000000 --- a/doc/5/core-classes/memory-storage/zincrby/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: zincrby -description: MemoryStorage:zincrby ---- - -# zincrby - -Increments the score of a `member` in a sorted set by the provided `value`. - -[[_Redis documentation_]](https://redis.io/commands/zincrby) - ---- - -## zincrby(key, member, increment, [options], [callback]) - -| Arguments | Type | Description | -| ----------- | ----------- | --------------------------- | -| `key` | string | Key identifier | -| `member` | string | Member element to increment | -| `increment` | double | Increment value | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns a double containing the updated member's score in the sorted set. - -## Usage - -<<< ./snippets/zincrby-1.js - -> Callback response: - -```json -4.14159 -``` diff --git a/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js b/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js deleted file mode 100644 index 692cec1fb..000000000 --- a/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zincrby('key', 'foo', 3.14159, function (err, value) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zincrbyPromise('key', 'foo', 3.14159) - .then(value => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js b/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js deleted file mode 100644 index fa1491d6b..000000000 --- a/doc/5/core-classes/memory-storage/zincrby/snippets/zincrby-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4.14159 diff --git a/doc/5/core-classes/memory-storage/zinterstore/index.md b/doc/5/core-classes/memory-storage/zinterstore/index.md deleted file mode 100644 index 3fa1f0673..000000000 --- a/doc/5/core-classes/memory-storage/zinterstore/index.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -code: false -type: page -title: zinterstore -description: MemoryStorage:zinterstore ---- - -# zinterstore - -Computes the intersection of the provided sorted sets and stores the result in the `destination` key. - -If the destination key already exists, it is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/zinterstore) - ---- - -## zinterstore(destination, keys, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | -------------------------------- | -| `destination` | string | Destination key identifier | -| `keys` | string | List of sorted sets to intersect | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------- | ------- | ----------------------------------------------------------------------------------------------------------- | ------- | -| `aggregate` | string | Specify how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | `sum` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `weights` | array | Specify a multiplication factor for each input sorted set | `[1]` | - ---- - -## Callback Response - -Returns an integer containing the number of members in the stored intersection. - -## Usage - -<<< ./snippets/zinterstore-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js b/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js deleted file mode 100644 index 66c56622f..000000000 --- a/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zinterstore('destination', ['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zinterstorePromise('destination', ['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js b/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/zinterstore/snippets/zinterstore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/memory-storage/zlexcount/index.md b/doc/5/core-classes/memory-storage/zlexcount/index.md deleted file mode 100644 index c4e514aef..000000000 --- a/doc/5/core-classes/memory-storage/zlexcount/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: zlexcount -description: MemoryStorage:zlexcount ---- - -# zlexcount - -Counts elements in a sorted set where all members have equal score, using lexicographical ordering. The `min` and `max` values are inclusive by default. To change this behavior, please check the syntax detailed in the [Redis documentation](https://redis.io/commands/zrangebylex). - -[[_Redis documentation_]](https://redis.io/commands/zlexcount) - ---- - -## zlexcount(key, min, max, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `min` | string | Minimum member value (inclusive by default) | -| `max` | string | Maximum member value (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the number of elements in the provided lexicographical value range. - -## Usage - -<<< ./snippets/zlexcount-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js b/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js deleted file mode 100644 index ddefd255e..000000000 --- a/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zlexcount('key', '[b', '[f' function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zlexcountPromise('key', '[b', '[f') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js b/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/zlexcount/snippets/zlexcount-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/zrange/index.md b/doc/5/core-classes/memory-storage/zrange/index.md deleted file mode 100644 index c773a4128..000000000 --- a/doc/5/core-classes/memory-storage/zrange/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -code: false -type: page -title: zrange -description: MemoryStorage:zrange ---- - -# zrange - -Returns elements from a sorted set depending on their position in the set, from a `start` position index to a `stop` position index (inclusives). -First position starts at `0`. - -[[_Redis documentation_]](https://redis.io/commands/zrange) - ---- - -## zrange(key, start, stop, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------- | -| `key` | string | Key identifier | -| `start` | int | Start position in the set (index starts at position `0`) | -| `stop` | int | End position in the set | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of objects, each containing the following properties: - -- `member`: member value in the sorted set -- `score`: member associated score - -## Usage - -<<< ./snippets/zrange-1.js - -> Callback response: - -```json -[ - { "member": "foo", "score": 1 }, - { "member": "bar", "score": 2 }, - { "member": "baz", "score": 3 } -] -``` diff --git a/doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js b/doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js deleted file mode 100644 index 935941814..000000000 --- a/doc/5/core-classes/memory-storage/zrange/snippets/zrange-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrange('key', 0, -1, function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrangePromise('key', 0, -1) - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js b/doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js deleted file mode 100644 index 08faf171a..000000000 --- a/doc/5/core-classes/memory-storage/zrange/snippets/zrange-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - { "member": "foo", "score": 1 }, - { "member": "bar", "score": 2 }, - { "member": "baz", "score": 3 } -] diff --git a/doc/5/core-classes/memory-storage/zrangebylex/index.md b/doc/5/core-classes/memory-storage/zrangebylex/index.md deleted file mode 100644 index 3fadf336c..000000000 --- a/doc/5/core-classes/memory-storage/zrangebylex/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: zrangebylex -description: MemoryStorage:zrangebylex ---- - -# zrangebylex - -Returns elements in a sorted set where all members have equal score, using lexicographical ordering. The `min` and `max` values are inclusive by default. To change this behavior, please check the full documentation. - -[[_Redis documentation_]](https://redis.io/commands/zrangebylex) - ---- - -## zrangebylex(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `min` | string | Minimum member value (inclusive by default) | -| `max` | string | Maximum member value (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of matching members. - -## Usage - -<<< ./snippets/zrangebylex-1.js - -> Callback response: - -```json -["member1", "member2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js b/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js deleted file mode 100644 index c2c909aca..000000000 --- a/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrangebylex('key', '-', '(g', function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrangebylexPromise('key', '-', '(g') - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js b/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js deleted file mode 100644 index 395de0670..000000000 --- a/doc/5/core-classes/memory-storage/zrangebylex/snippets/zrangebylex-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "member1", - "member2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/zrangebyscore/index.md b/doc/5/core-classes/memory-storage/zrangebyscore/index.md deleted file mode 100644 index 5d8000759..000000000 --- a/doc/5/core-classes/memory-storage/zrangebyscore/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: zrangebyscore -description: MemoryStorage:zrangebyscore ---- - -# zrangebyscore - -Returns all the elements in the sorted set at key with a score between `min` and `max` (inclusive). The elements are considered to be ordered from low to high scores. - -[[_Redis documentation_]](https://redis.io/commands/zrangebyscore) - ---- - -## zrangebyscore(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------ | -| `key` | string | Key identifier | -| `min` | double | Minimum score value (inclusive by default) | -| `max` | double | Maximum score value (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of matching members. - -## Usage - -<<< ./snippets/zrangebyscore-1.js - -> Callback response: - -```json -[ - { "member": "foo", "score": 1 }, - { "member": "bar", "score": 2 }, - { "member": "baz", "score": 3 } -] -``` diff --git a/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js b/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js deleted file mode 100644 index ed837921d..000000000 --- a/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrangebyscore('key', 2, 3, function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrangebyscorePromise('key', 2, 3) - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js b/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js deleted file mode 100644 index 08faf171a..000000000 --- a/doc/5/core-classes/memory-storage/zrangebyscore/snippets/zrangebyscore-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - { "member": "foo", "score": 1 }, - { "member": "bar", "score": 2 }, - { "member": "baz", "score": 3 } -] diff --git a/doc/5/core-classes/memory-storage/zrank/index.md b/doc/5/core-classes/memory-storage/zrank/index.md deleted file mode 100644 index ce1078102..000000000 --- a/doc/5/core-classes/memory-storage/zrank/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: zrank -description: MemoryStorage:zrank ---- - -# zrank - -Returns the position of an element in a sorted set, with scores in ascending order. The index returned is 0-based (the lowest score member has an index of 0). - -[[_Redis documentation_]](https://redis.io/commands/zrank) - ---- - -## zrank(key, member, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------ | -| `key` | string | Key identifier | -| `member` | string | Member of the sorted set | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the member's position in the sorted set. - -## Usage - -<<< ./snippets/zrank-1.js - -> Callback response: - -```json -0 -``` diff --git a/doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js b/doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js deleted file mode 100644 index 2e4ac99e4..000000000 --- a/doc/5/core-classes/memory-storage/zrank/snippets/zrank-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrank('key', 'foo', function (err, position) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrankPromise('key', 'foo') - .then(position => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js b/doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js deleted file mode 100644 index 41199acf8..000000000 --- a/doc/5/core-classes/memory-storage/zrank/snippets/zrank-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -0 diff --git a/doc/5/core-classes/memory-storage/zrem/index.md b/doc/5/core-classes/memory-storage/zrem/index.md deleted file mode 100644 index bc7d356c9..000000000 --- a/doc/5/core-classes/memory-storage/zrem/index.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -code: false -type: page -title: zrem -description: MemoryStorage:zrem ---- - -# zrem - -Removes members from a sorted set. - -[[_Redis documentation_]](https://redis.io/commands/zrem) - ---- - -## zrem(key, members, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------- | -| `key` | string | Key identifier | -| `members` | array | List of members to remove | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of members removed from the sorted set. - -## Usage - -<<< ./snippets/zrem-1.js - -> Callback response: - -```json -3 -``` diff --git a/doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js b/doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js deleted file mode 100644 index a4aa48ce2..000000000 --- a/doc/5/core-classes/memory-storage/zrem/snippets/zrem-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrem('key', ['foo', 'bar', 'baz'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zremPromise('key', ['foo', 'bar', 'baz']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js b/doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js deleted file mode 100644 index de250b6fb..000000000 --- a/doc/5/core-classes/memory-storage/zrem/snippets/zrem-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -3 diff --git a/doc/5/core-classes/memory-storage/zremrangebylex/index.md b/doc/5/core-classes/memory-storage/zremrangebylex/index.md deleted file mode 100644 index e234fd01a..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebylex/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: zremrangebylex -description: MemoryStorage:zremrangebylex ---- - -# zremrangebylex - -Removes members from a sorted set where all elements have the same score, using lexicographical ordering. The `min` and `max` interval are inclusive, see the [Redis documentation](https://redis.io/commands/zrangebylex) to change this behavior. - -[[_Redis documentation_]](https://redis.io/commands/zremrangebylex) - ---- - -## zremrangebylex(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `min` | string | Minimum member value (inclusive by default) | -| `max` | string | Maximum member value (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of removed members from the sorted set. - -## Usage - -<<< ./snippets/zremrangebylex-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js b/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js deleted file mode 100644 index db4af6a12..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zremrangebylex('key', '[b', '(f', function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zremrangebylexPromise('key', '[b', '(f') - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js b/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebylex/snippets/zremrangebylex-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/zremrangebyrank/index.md b/doc/5/core-classes/memory-storage/zremrangebyrank/index.md deleted file mode 100644 index 12a0a9f18..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebyrank/index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -code: false -type: page -title: zremrangebyrank -description: MemoryStorage:zremrangebyrank ---- - -# zremrangebyrank - -Removes members from a sorted set with their position in the set between `start` and `stop` (inclusive). - -Positions are 0-based, meaning the first member of the set has a position of 0. - -[[_Redis documentation_]](https://redis.io/commands/zremrangebyrank) - ---- - -## zremrangebyrank(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------------- | -| `key` | string | Key identifier | -| `min` | int | Minimum position index (inclusive by default) | -| `max` | int | Maximum position index (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of removed members from the sorted set. - -## Usage - -<<< ./snippets/zremrangebyrank-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js b/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js deleted file mode 100644 index 5df66b95f..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zremrangebyrank('key', 1, 2, function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zremrangebyrankPromise('key', 1, 2) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js b/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebyrank/snippets/zremrangebyrank-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/zremrangebyscore/index.md b/doc/5/core-classes/memory-storage/zremrangebyscore/index.md deleted file mode 100644 index 91a285e25..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebyscore/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: zremrangebyscore -description: MemoryStorage:zremrangebyscore ---- - -# zremrangebyscore - -Removes members from a sorted set with a score between `min` and `max` (inclusive by default). - -[[_Redis documentation_]](https://redis.io/commands/zremrangebyscore) - ---- - -## zremrangebyscore(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------ | -| `key` | string | Key identifier | -| `min` | double | Minimum score (inclusive by default) | -| `max` | double | Maximum score (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an integer containing the number of removed members from the sorted set. - -## Usage - -<<< ./snippets/zremrangebyscore-1.js - -> Callback response: - -```json -2 -``` diff --git a/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js b/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js deleted file mode 100644 index 0e895e264..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zremrangebyscore('key', 1, 2, function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zremrangebyscorePromise('key', 1, 2) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js b/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js deleted file mode 100644 index 056219890..000000000 --- a/doc/5/core-classes/memory-storage/zremrangebyscore/snippets/zremrangebyscore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -2 diff --git a/doc/5/core-classes/memory-storage/zrevrange/index.md b/doc/5/core-classes/memory-storage/zrevrange/index.md deleted file mode 100644 index 70babe86c..000000000 --- a/doc/5/core-classes/memory-storage/zrevrange/index.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -code: false -type: page -title: zrevrange -description: MemoryStorage:zrevrange ---- - -# zrevrange - -Identical to [zrange](/sdk/js/5/core-classes/memory-storage/zrange), except that the sorted set is traversed in descending order. - -[[_Redis documentation_]](https://redis.io/commands/zrevrange) - ---- - -## zrevrange(key, start, stop, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------- | -| `key` | string | Key identifier | -| `start` | int | Start position in the set (index starts at position `0`) | -| `stop` | int | End position in the set | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of objects, each containing the following properties: - -- `member`: member value in the sorted set -- `score`: member associated score - -## Usage - -<<< ./snippets/zrevrange-1.js - -> Callback response: - -```json -[ - { "member": "baz", "score": 3 }, - { "member": "bar", "score": 2 }, - { "member": "foo", "score": 1 } -] -``` diff --git a/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js b/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js deleted file mode 100644 index ff66e90a5..000000000 --- a/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrevrange('key', 0, -1, function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrevrangePromise('key', 0, -1) - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js b/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js deleted file mode 100644 index ed901f110..000000000 --- a/doc/5/core-classes/memory-storage/zrevrange/snippets/zrevrange-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - { "member": "baz", "score": 3 }, - { "member": "bar", "score": 2 }, - { "member": "foo", "score": 1 } -] diff --git a/doc/5/core-classes/memory-storage/zrevrangebylex/index.md b/doc/5/core-classes/memory-storage/zrevrangebylex/index.md deleted file mode 100644 index 2c6b5f3ec..000000000 --- a/doc/5/core-classes/memory-storage/zrevrangebylex/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: zrevrangebylex -description: MemoryStorage:zrevrangebylex ---- - -# zrevrangebylex - -Identical to [zrangebylex](/sdk/js/5/core-classes/memory-storage/zrangebylex) except that the sorted set is traversed in descending order. - -[[_Redis documentation_]](https://redis.io/commands/zrevrangebylex) - ---- - -## zrevrangebylex(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------- | -| `key` | string | Key identifier | -| `min` | string | Minimum member value (inclusive by default) | -| `max` | string | Maximum member value (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of matching members. - -## Usage - -<<< ./snippets/zrevrangebylex-1.js - -> Callback response: - -```json -["member1", "member2", "..."] -``` diff --git a/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js b/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js deleted file mode 100644 index d9cf3c70f..000000000 --- a/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrevrangebylex('key', '-', '(g', function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrevrangebylexPromise('key', '-', '(g') - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js b/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js deleted file mode 100644 index 395de0670..000000000 --- a/doc/5/core-classes/memory-storage/zrevrangebylex/snippets/zrevrangebylex-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - "member1", - "member2", - "..." -] diff --git a/doc/5/core-classes/memory-storage/zrevrangebyscore/index.md b/doc/5/core-classes/memory-storage/zrevrangebyscore/index.md deleted file mode 100644 index c65f767c6..000000000 --- a/doc/5/core-classes/memory-storage/zrevrangebyscore/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: zrevrangebyscore -description: MemoryStorage:zrevrangebyscore ---- - -# zrevrangebyscore - -Identical to [zrangebyscore](/sdk/js/5/core-classes/memory-storage/zrangebyscore) except that the sorted set is traversed in descending order. - -[[_Redis documentation_]](https://redis.io/commands/zrevrangebyscore) - ---- - -## zrevrangebyscore(key, min, max, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------ | -| `key` | string | Key identifier | -| `min` | double | Minimum score value (inclusive by default) | -| `max` | double | Maximum score value (inclusive by default) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `limit` | array | Limit the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | `null` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return value - -Returns the `MemoryStorage` object to allow chaining. - ---- - -## Callback Response - -Returns an array of matching members. - -## Usage - -<<< ./snippets/zrevrangebyscore-1.js - -> Callback response: - -```json -[ - { "member": "baz", "score": 3 }, - { "member": "bar", "score": 2 }, - { "member": "foo", "score": 1 } -] -``` diff --git a/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js b/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js deleted file mode 100644 index 916424993..000000000 --- a/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrevrangebyscore('key', 2, 3, function (err, members) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrevrangebyscorePromise('key', 2, 3) - .then(members => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js b/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js deleted file mode 100644 index ed901f110..000000000 --- a/doc/5/core-classes/memory-storage/zrevrangebyscore/snippets/zrevrangebyscore-2.js +++ /dev/null @@ -1,6 +0,0 @@ -on -[ - { "member": "baz", "score": 3 }, - { "member": "bar", "score": 2 }, - { "member": "foo", "score": 1 } -] diff --git a/doc/5/core-classes/memory-storage/zrevrank/index.md b/doc/5/core-classes/memory-storage/zrevrank/index.md deleted file mode 100644 index 587e91946..000000000 --- a/doc/5/core-classes/memory-storage/zrevrank/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: zrevrank -description: MemoryStorage:zrevrank ---- - -# zrevrank - -Returns the position of an element in a sorted set, with scores in descending order. The index returned is 0-based (the lowest score member has an index of 0). - -[[_Redis documentation_]](https://redis.io/commands/zrevrank) - ---- - -## zrevrank(key, member, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------ | -| `key` | string | Key identifier | -| `member` | string | Member of the sorted set | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an integer containing the member's position in the sorted set. - -## Usage - -<<< ./snippets/zrevrank-1.js - -> Callback response: - -```json -0 -``` diff --git a/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js b/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js deleted file mode 100644 index 5bf19eff0..000000000 --- a/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zrevrank('key', 'foo', function (err, position) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zrevrankPromise('key', 'foo') - .then(position => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js b/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js deleted file mode 100644 index 41199acf8..000000000 --- a/doc/5/core-classes/memory-storage/zrevrank/snippets/zrevrank-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -0 diff --git a/doc/5/core-classes/memory-storage/zscan/index.md b/doc/5/core-classes/memory-storage/zscan/index.md deleted file mode 100644 index 5155f1212..000000000 --- a/doc/5/core-classes/memory-storage/zscan/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: zscan -description: MemoryStorage:zscan ---- - -# zscan - -Identical to [scan](/sdk/js/5/core-classes/memory-storage/scan), except that `zscan` iterates the members held by a sorted set. - -[[_Redis documentation_]](https://redis.io/commands/zscan) - ---- - -## zscan(key, cursor, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------------------------------------------------------------------- | -| `key` | string | Key identifier | -| `cursor` | int | Page number (iteration starts with a cursor value of `0`, and ends when the next cursor position is `0`) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------- | ------- | -| `count` | int | Return the _approximate_ `count` number of items per result page | `10` | -| `match` | string | Search only for member values matching the provided pattern | `*` | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a JSON array containing 2 entries: - -- the cursor position for the next page of results (a next position of `0` indicates the end of the scan) -- an array of sorted set members and their associated scores - -## Usage - -<<< ./snippets/zscan-1.js - -> Callback response: - -```json -{ - "cursor": 18, - "values": ["member1", "member1's score", "member2", "member2's score", "..."] -} -``` diff --git a/doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js b/doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js deleted file mode 100644 index b0c839d3b..000000000 --- a/doc/5/core-classes/memory-storage/zscan/snippets/zscan-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zscan('key', 0, function (err, page) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zscanPromise('key', 0) - .then(page => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js b/doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js deleted file mode 100644 index 740f694e0..000000000 --- a/doc/5/core-classes/memory-storage/zscan/snippets/zscan-2.js +++ /dev/null @@ -1,11 +0,0 @@ -on -{ - "cursor": 18, - "values": [ - "member1", - "member1's score", - "member2", - "member2's score", - "..." - ] -} diff --git a/doc/5/core-classes/memory-storage/zscore/index.md b/doc/5/core-classes/memory-storage/zscore/index.md deleted file mode 100644 index 8f6e6e691..000000000 --- a/doc/5/core-classes/memory-storage/zscore/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: zscore -description: MemoryStorage:zscore ---- - -# zscore - -Returns the score of a member in a sorted set. - -[[_Redis documentation_]](https://redis.io/commands/zscore) - ---- - -## zscore(key, member, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------- | -| `key` | string | Key identifier | -| `member` | string | Sorted set member | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a floating point number containing the searched member's score. - -## Usage - -<<< ./snippets/zscore-1.js - -> Callback response: - -```json -1 -``` diff --git a/doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js b/doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js deleted file mode 100644 index d596b397b..000000000 --- a/doc/5/core-classes/memory-storage/zscore/snippets/zscore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zscore('key', 'bar', function (err, score) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zscorePromise('key', 'bar') - .then(score => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js b/doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js deleted file mode 100644 index b52a3a5b9..000000000 --- a/doc/5/core-classes/memory-storage/zscore/snippets/zscore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -1 diff --git a/doc/5/core-classes/memory-storage/zunionstore/index.md b/doc/5/core-classes/memory-storage/zunionstore/index.md deleted file mode 100644 index f519990cc..000000000 --- a/doc/5/core-classes/memory-storage/zunionstore/index.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -code: false -type: page -title: zunionstore -description: MemoryStorage:zunionstore ---- - -# zunionstore - -Computes the union of the provided sorted sets and stores the result in the `destination` key. - -If the destination key already exists, it is overwritten. - -[[_Redis documentation_]](https://redis.io/commands/zunionstore) - ---- - -## zunionstore(destination, keys, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | -------------------------------- | -| `destination` | string | Destination key identifier | -| `keys` | string | List of sorted sets to intersect | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------- | ------- | ----------------------------------------------------------------------------------------------------------- | ------- | -| `aggregate` | string | Specify how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | `sum` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `weights` | array | Specify a multiplication factor for each input sorted set | `[1]` | - ---- - -## Callback Response - -Returns an integer containing the number of members in the stored union. - -## Usage - -<<< ./snippets/zunionstore-1.js - -> Callback response: - -```json -4 -``` diff --git a/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js b/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js deleted file mode 100644 index b330b9639..000000000 --- a/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle.memoryStorage.zunionstore('destination', ['key1', 'key2', '...'], function (err, count) { - // callback called once the action has completed -}); - -// Using promises (NodeJS only) -kuzzle.memoryStorage.zunionstorePromise('destination', ['key1', 'key2', '...']) - .then(count => { - // resolved once the action has completed - }); diff --git a/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js b/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js deleted file mode 100644 index e3cd69f7e..000000000 --- a/doc/5/core-classes/memory-storage/zunionstore/snippets/zunionstore-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -4 diff --git a/doc/5/core-classes/profile/add-policy/index.md b/doc/5/core-classes/profile/add-policy/index.md deleted file mode 100644 index 9af94b2ed..000000000 --- a/doc/5/core-classes/profile/add-policy/index.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -code: false -type: page -title: addPolicy -description: Profile:addPolicy ---- - -# addPolicy - -Adds a role to the security profile. - -
-Updating a security profile will have no impact until the [save](/sdk/js/5/core-classes/profile/save) method is called -
- ---- - -## addPolicy(id) - -| Arguments | Type | Description | -| --------- | ------ | -------------------------------------- | -| `id` | string | Unique id of the new role to associate | - ---- - -## addPolicy(policy) - -| Arguments | Type | Description | -| --------- | ----------- | ----------------------------------------------------------------------------- | -| `policy` | JSON Object | policy instance corresponding to the new associated role and its restrictions | - ---- - -## Return Value - -Returns the `Profile` object to allow chaining calls. - -## Usage - -<<< ./snippets/add-policy-1.js diff --git a/doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js b/doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js deleted file mode 100644 index eae8ad5d3..000000000 --- a/doc/5/core-classes/profile/add-policy/snippets/add-policy-1.js +++ /dev/null @@ -1,4 +0,0 @@ -profile.addPolicy({ - 'roleId': 'some role id', - 'restrictedTo': [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] -}); diff --git a/doc/5/core-classes/profile/constructor/index.md b/doc/5/core-classes/profile/constructor/index.md deleted file mode 100644 index 0d402491f..000000000 --- a/doc/5/core-classes/profile/constructor/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: constructor -description: Profile:constructor -order: 1 ---- - -# Constructors - -Instantiates a new `Profile` object, representing a security [profile](/core/1/guides/essentials/security/#users-profiles-and-roles), which is a set of one or many [Role](/sdk/js/5/core-classes/role) objects. - ---- - -## Profile(Security, id, content, [meta]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------- | -| `Security` | Security | An instantiated [Security](/sdk/js/5/core-classes/security) object | -| `id` | string | Unique profile identifier | -| `content` | JSON Object | Profile content | -| `meta` | JSON Object | Profile metadata | - -**Note:** this constructor won't make any call to Kuzzle. - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ------------- | ----------- | ------------------------- | ------- | -| `content` | JSON object | Raw profile content | get | -| `id` | string | Unique profile identifier | get | -| `meta` | JSON object | Profile metadata | get | - ---- - -## Return Value - -Returns to the `Profile` object. - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/profile/constructor/snippets/constructor-1.js b/doc/5/core-classes/profile/constructor/snippets/constructor-1.js deleted file mode 100644 index 0c02c9990..000000000 --- a/doc/5/core-classes/profile/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - Constructors are not exposed in the JS/Node SDK. - Profile objects are returned by Security.profile method: - */ -var profileDefinition = { - policies: [ - {roleId: 'myrole'}, - {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } - ] -}; - -var profile = kuzzle.security.profile('myprofile', profileDefinition); diff --git a/doc/5/core-classes/profile/delete/index.md b/doc/5/core-classes/profile/delete/index.md deleted file mode 100644 index 7b49565b3..000000000 --- a/doc/5/core-classes/profile/delete/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: delete -description: Profile:delete ---- - -# delete - -Deletes this security profile from Kuzzle. - ---- - -## delete([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the ID of the deleted profile. - -## Usage - -<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/profile/delete/snippets/delete-1.js b/doc/5/core-classes/profile/delete/snippets/delete-1.js deleted file mode 100644 index 245b441bb..000000000 --- a/doc/5/core-classes/profile/delete/snippets/delete-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -profile - .delete(function(error, result) { - // result is the id of deleted profile - }); - -// Using promises (NodeJS) -profile - .deletePromise() - .then((result) => { - // result is the id of deleted profile - }); diff --git a/doc/5/core-classes/profile/get-policies/index.md b/doc/5/core-classes/profile/get-policies/index.md deleted file mode 100644 index 1912f317b..000000000 --- a/doc/5/core-classes/profile/get-policies/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: getPolicies -description: Profile:getPolicies ---- - -# getPolicies - -Returns roles associated to this security policy. - ---- - -## Return Value - -Returns an array of roles linked to this security policy. - -## Usage - -<<< ./snippets/get-policies-1.js - -> Callback response - -```json -[ - { - "roleId": "", - "restrictedTo": { - "index": "", - "collections": ["", "", "<...>"] - } - }, - { - "roleId": "" - }, - { - "roleId": "", - "restrictedTo": { - "index": "", - "collections": [""] - } - } -] -``` diff --git a/doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js b/doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js deleted file mode 100644 index 1886ed970..000000000 --- a/doc/5/core-classes/profile/get-policies/snippets/get-policies-1.js +++ /dev/null @@ -1,3 +0,0 @@ -for (policy of profile.getPolicies()) { - // policy is a JSON object -} diff --git a/doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js b/doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js deleted file mode 100644 index e49d1b500..000000000 --- a/doc/5/core-classes/profile/get-policies/snippets/get-policies-2.js +++ /dev/null @@ -1,20 +0,0 @@ -on -[ - { - "roleId": "", - "restrictedTo": { - "index": "", - "collections": ["", "", "<...>"] - } - }, - { - "roleId": "" - }, - { - "roleId": "", - "restrictedTo": { - "index": "", - "collections": [""] - } - } -] diff --git a/doc/5/core-classes/profile/index.md b/doc/5/core-classes/profile/index.md deleted file mode 100644 index 124efa45f..000000000 --- a/doc/5/core-classes/profile/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: Profile -description: Profile documentation ---- diff --git a/doc/5/core-classes/profile/save/index.md b/doc/5/core-classes/profile/save/index.md deleted file mode 100644 index ee5bfc099..000000000 --- a/doc/5/core-classes/profile/save/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: save -description: Profile:save ---- - -# save - -Creates or replaces the profile in Kuzzle. - -
-Saving the object will return an error if the linked roles have not been previously created in Kuzzle. -
- ---- - -## save([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Profile` object to allow chaining. - ---- - -## Callback Response - -Returns a `Profile` object. - -## Usage - -<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/profile/save/snippets/save-1.js b/doc/5/core-classes/profile/save/snippets/save-1.js deleted file mode 100644 index 08fa095d0..000000000 --- a/doc/5/core-classes/profile/save/snippets/save-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var profileDefinition = { - policies: [ - {roleId: 'myrole'}, - {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } - ] -}; - -var profile = kuzzle.security.profile('myprofile', profileDefinition); - -// Using callbacks (NodeJS or Web Browser) -profile - .save(function(error, result) { - // result is a Profile object - }); - -// Using promises (NodeJS) -profile - .savePromise() - .then(result => { - // result is a Profile object - }); diff --git a/doc/5/core-classes/profile/set-content/index.md b/doc/5/core-classes/profile/set-content/index.md deleted file mode 100644 index 6caa5bbed..000000000 --- a/doc/5/core-classes/profile/set-content/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -code: false -type: page -title: setContent -description: Profile:setContent ---- - -# setContent - -Replaces the content of the `Profile` object. - -
-Updating a profile will have no impact until the save method is called -
- ---- - -## setContent(data) - -| Arguments | Type | Description | -| --------- | ----------- | --------------- | -| `data` | JSON Object | Profile content | - ---- - -## Return Value - -Returns the `Profile` object. - -## Usage - -<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/profile/set-content/snippets/set-content-1.js b/doc/5/core-classes/profile/set-content/snippets/set-content-1.js deleted file mode 100644 index 8fdc7e81c..000000000 --- a/doc/5/core-classes/profile/set-content/snippets/set-content-1.js +++ /dev/null @@ -1,9 +0,0 @@ -var profile = kuzzle.security.fetchProfile('myprofile'); -var profileDefinition = { - policies: [ - {roleId: 'myrole'}, - {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } - ] -}; - -profile = profile.setContent(profileDefinition); diff --git a/doc/5/core-classes/profile/set-policies/index.md b/doc/5/core-classes/profile/set-policies/index.md deleted file mode 100644 index c649e9db5..000000000 --- a/doc/5/core-classes/profile/set-policies/index.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -code: false -type: page -title: setPolicies -description: Profile:setPolicies ---- - -# setPolicies - -Replaces the roles associated with this security profile. - ---- - -## `setPolicies(Array policyIDs)` - -| Arguments | Type | Description | -| ----------- | ---------------- | ----------------- | -| `policyIDs` | array of strings | Policy IDs to add | - ---- - -## `setPolicies(Array policyDefinitions)` - -| Arguments | Type | Description | -| ------------------- | --------------------- | ------------------------- | -| `policyDefinitions` | array of JSON objects | Policy definitions to add | - ---- - -## Return Value - -Returns the `Profile` object. - -
-Updating a profile will have no impact until the save method is called -
- -## Usage - -<<< ./snippets/set-policies-1.js diff --git a/doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js b/doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js deleted file mode 100644 index c96155ce9..000000000 --- a/doc/5/core-classes/profile/set-policies/snippets/set-policies-1.js +++ /dev/null @@ -1,4 +0,0 @@ -policy = { "roleId": "roleId" }; - -// Replaces the profile policies set with the given entry. -profile.setPolicies([policy]); diff --git a/doc/5/core-classes/profile/update/index.md b/doc/5/core-classes/profile/update/index.md deleted file mode 100644 index 79b8ebb53..000000000 --- a/doc/5/core-classes/profile/update/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: update -description: Profile:update ---- - -# update - -Performs a partial content update on this object. - ---- - -## update(content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------- | -| `content` | JSON Object | Profile content | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Profile` object to allow chaining. - ---- - -## Callback Response - -Returns the updated version of this object. - -## Usage - -<<< ./snippets/update-1.js diff --git a/doc/5/core-classes/profile/update/snippets/update-1.js b/doc/5/core-classes/profile/update/snippets/update-1.js deleted file mode 100644 index 07efac4ef..000000000 --- a/doc/5/core-classes/profile/update/snippets/update-1.js +++ /dev/null @@ -1,17 +0,0 @@ -var updateContent = { - policies: [ - {roleId: 'myrole'}, - ] -}; - -// Using callbacks (NodeJS or Web Browser) -profile.update(updateContent, function(err, updatedProfile) { - // the updatedProfile variable is the updated Profile object -}) - -// Using promises (NodeJS) -profile - .updatePromise(updateContent) - .then(updatedProfile => { - // the updatedProfile variable is the updated Profile object - }); diff --git a/doc/5/core-classes/role/constructor/index.md b/doc/5/core-classes/role/constructor/index.md deleted file mode 100644 index 4a9122931..000000000 --- a/doc/5/core-classes/role/constructor/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: constructor -description: Role:constructor -order: 1 ---- - -# Constructors - -Instantiates a new `Role` object, which defines a set of right policies. - ---- - -## Role(Security, id, content, [meta]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------- | -| `Security` | Security | An instantiated [Security](/sdk/js/5/core-classes/security) object | -| `id` | string | Unique role identifier | -| `content` | JSON Object | Role content | -| `meta` | JSON Object | Role metadata | - -**Note:** this constructor won't make any call to Kuzzle. - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ------------- | ----------- | ------------------------- | ------- | -| `content` | JSON object | Raw role content | get | -| `id` | string | Unique profile identifier | get | -| `meta` | JSON object | Role metadata | get | - ---- - -## Return Value - -Returns the `Role` object. - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/role/constructor/snippets/constructor-1.js b/doc/5/core-classes/role/constructor/snippets/constructor-1.js deleted file mode 100644 index 07863226c..000000000 --- a/doc/5/core-classes/role/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - Constructors are not exposed in the JS/Node SDK. - Role objects are returned by Security.role method: - */ -var roleDefinition = { - controllers: { - "*": { - actions: { - "*": true - } - } - } -}; - -var role = kuzzle.security.role('myrole', roleDefinition); diff --git a/doc/5/core-classes/role/delete/index.md b/doc/5/core-classes/role/delete/index.md deleted file mode 100644 index 69703689c..000000000 --- a/doc/5/core-classes/role/delete/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: delete -description: Role:delete ---- - -# delete - -Deletes the role from Kuzzle. - ---- - -## delete([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the ID of the deleted role. - -## Usage - -<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/role/delete/snippets/delete-1.js b/doc/5/core-classes/role/delete/snippets/delete-1.js deleted file mode 100644 index b0f4e2bb1..000000000 --- a/doc/5/core-classes/role/delete/snippets/delete-1.js +++ /dev/null @@ -1,10 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -role.delete(function(error, deletedId) { - // ... -}); - -// Using promises (NodeJS) -role.deletePromise() - .then(deletedId => { - // ... - }); diff --git a/doc/5/core-classes/role/index.md b/doc/5/core-classes/role/index.md deleted file mode 100644 index 72aa06500..000000000 --- a/doc/5/core-classes/role/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: Role -description: Role documentation ---- diff --git a/doc/5/core-classes/role/save/index.md b/doc/5/core-classes/role/save/index.md deleted file mode 100644 index 8acf77aa5..000000000 --- a/doc/5/core-classes/role/save/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: save -description: Role:save ---- - -# save - -Creates or replaces the role in Kuzzle's database layer. - ---- - -## save([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Role` object to allow chaining. - ---- - -## Callback Response - -Returns a `Role` object. - -## Usage - -<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/role/save/snippets/save-1.js b/doc/5/core-classes/role/save/snippets/save-1.js deleted file mode 100644 index 0a8dded98..000000000 --- a/doc/5/core-classes/role/save/snippets/save-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -role - .save(function(error, result) { - // result is a Role object - }); - -// Using promises (NodeJS) -role - .savePromise() - .then((result) => { - // result is a Role object - }); diff --git a/doc/5/core-classes/role/set-content/index.md b/doc/5/core-classes/role/set-content/index.md deleted file mode 100644 index 44d05dd69..000000000 --- a/doc/5/core-classes/role/set-content/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -code: false -type: page -title: setContent -description: Role:setContent ---- - -# setContent - -Replaces the content of the `Role` object. - -
-Updating a role content will have no impact until the [save](/sdk/js/5/core-classes/role/save) method is called -
- ---- - -## setContent(data) - -| Arguments | Type | Description | -| --------- | ----------- | ------------ | -| `data` | JSON Object | Role content | - ---- - -## Return Value - -Returns the `Role` object. - -## Usage - -<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/role/set-content/snippets/set-content-1.js b/doc/5/core-classes/role/set-content/snippets/set-content-1.js deleted file mode 100644 index 349d4c954..000000000 --- a/doc/5/core-classes/role/set-content/snippets/set-content-1.js +++ /dev/null @@ -1,11 +0,0 @@ -var roleDefinition = { - controllers: { - "*": { - actions: { - "*": true - } - } - } -}; - -role = role.setContent(roleDefinition); diff --git a/doc/5/core-classes/role/update/index.md b/doc/5/core-classes/role/update/index.md deleted file mode 100644 index f7f422ff0..000000000 --- a/doc/5/core-classes/role/update/index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -code: false -type: page -title: update -description: Role:update ---- - -# update - -Updates the role object in Kuzzle. - -
-

- Unlike a regular document update, this method will replace the whole role definition under the indexes node with the updateContent parameter.
- In other words, you always need to provide the complete role definition in the updateContent object. -

-

- This method has the same effect as calling [`setContent`](/sdk/js/5/core-classes/role/set-content) followed by the [`save`](/sdk/js/5/core-classes/role/save) method. -

-
- -To get more information about Kuzzle permissions, please refer to our [permissions guide](/core/1/guides/essentials/security/#user-permissions). - ---- - -## update(content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------- | -| `content` | JSON Object | New role content | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `Role` object to allow chaining. - ---- - -## Callback Response - -Returns the updated version of this object. - -## Usage - -<<< ./snippets/update-1.js diff --git a/doc/5/core-classes/role/update/snippets/update-1.js b/doc/5/core-classes/role/update/snippets/update-1.js deleted file mode 100644 index e166c0a6a..000000000 --- a/doc/5/core-classes/role/update/snippets/update-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var updateContent = { - controllers: { - "document": { - actions: { - "get": true - } - } - } -}; - -// Using callbacks (NodeJS or Web Browser) -role.update(updateContent, function(err, updatedRole) { - // the updatedRole variable is the updated Role object -}) - -// Using promises (NodeJS) -role - .updatePromise(updateContent) - .then(updatedRole => { - // the updatedRole variable is the updated Role object - }); diff --git a/doc/5/core-classes/room/constructor/index.md b/doc/5/core-classes/room/constructor/index.md deleted file mode 100644 index d8d783a57..000000000 --- a/doc/5/core-classes/room/constructor/index.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -code: false -type: page -title: constructor -description: Room:constructor -order: 1 ---- - -# Constructors - -The `Room` object is the result of a subscription request, allowing you to manipulate the subscription itself. - ---- - -## Room(Collection, [options]) - -| Arguments | Type | Description | -| ------------ | ------ | ---------------------------------------- | -| `Collection` | object | an instantiated Kuzzle Collection object | -| `options` | object | Optional subscription configuration | - ---- - -## Options - -| Option | Type | Description | Default | -| ----------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `volatile` | JSON Object | Additional information passed to notifications to other users | `null` | -| `scope` | string | Filter [document notifications](/sdk/js/5/essentials/realtime-notifications/#document-notification) depending on their scope status. You may receive entering documents (scope: `in`), leaving documents (scope: `out`), all documents changes (scope: `all`) or filter these notifications completely (scope: `none`). This filter does not affect pub/sub messages or user events. | `all` | -| `state` | string | Filter [document notifications](/sdk/js/5/essentials/realtime-notifications/#document-notification) depending on the state of the modifying request. You may receive real-time notifications when a document is about to be changed (state: `pending`), or be notified when the change has been fully written in the database (state: `done`), or both (state: `all`). This filter does not affect pub/sub messages or user events. | `done` | -| `subscribeToSelf` | boolean | (Don't) subscribe to notifications fired as a consequence of our own queries | `true` | -| `users` | string | Filter [user notifications](/sdk/js/5/essentials/realtime-notifications/#user-notification) triggered upon a user entering the room (user: `in`), leaving the room (user: `out`), or both (user: `all`). Setting this variable to `none` prevents receiving these notifications | `none` | - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ----------------- | ----------- | ---------------------------------------------------------------------------- | ------- | -| `collection` | string | The subscribed collection | get | -| `filters` | JSON object | The current set of filters of this room | get/set | -| `headers` | JSON Object | Common headers for all sent documents. | get/set | -| `volatile` | JSON Object | Additional information passed to notifications to other users | get/set | -| `subscribeToSelf` | boolean | (Don't) subscribe to notifications fired as a consequence of our own queries | get/set | -| `roomId` | string | Unique room identifier | get | - -**Notes:** - -- the `headers` property is inherited from the provided `Collection` object and can be overridden -- updating the `volatile` property takes effect only after the subscription is renewed -- by default, the global `volatile` properties are sent along with the subscription request. If a `volatile` option is provided during subscription, it will be merged with the global `volatile` for the subscription only. In case of conflicts, subscription `volatile` data takes priority over the global `volatile` ones. - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/room/constructor/snippets/constructor-1.js b/doc/5/core-classes/room/constructor/snippets/constructor-1.js deleted file mode 100644 index 54f4b6c10..000000000 --- a/doc/5/core-classes/room/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - Constructors are not exposed in the JS/Node SDK. - Room objects are returned by Collection.subscribe and - Document.subscribe methods. - - You may also use the Collection.room() method: - */ -var room = kuzzle.collection('collection', 'index').room(); - -room = kuzzle - .collection('collection', 'index') - .room({subscribeToSelf: false}); diff --git a/doc/5/core-classes/room/count/index.md b/doc/5/core-classes/room/count/index.md deleted file mode 100644 index f1c4bf8c2..000000000 --- a/doc/5/core-classes/room/count/index.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -code: false -type: page -title: count -description: Room:count ---- - -# count - -Returns the number of subscribers in the room. - ---- - -## count(callback) - -| Arguments | Type | Description | -| ---------- | -------- | ------------------------------ | -| `callback` | function | Callback handling the response | - ---- - -## Callback Response - -Returns an `integer` containing the number of users subscribing to this room. - -## Usage - -<<< ./snippets/count-1.js - -> Callback response - -```json -1 -``` diff --git a/doc/5/core-classes/room/count/snippets/count-1.js b/doc/5/core-classes/room/count/snippets/count-1.js deleted file mode 100644 index ceef59935..000000000 --- a/doc/5/core-classes/room/count/snippets/count-1.js +++ /dev/null @@ -1,9 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -room.count(function (error, result) { - // ... -}); - -// Using promises (NodeJS) -room.countPromise().then(result => { - // ... -}); diff --git a/doc/5/core-classes/room/count/snippets/count-2.js b/doc/5/core-classes/room/count/snippets/count-2.js deleted file mode 100644 index b52a3a5b9..000000000 --- a/doc/5/core-classes/room/count/snippets/count-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -1 diff --git a/doc/5/core-classes/room/index.md b/doc/5/core-classes/room/index.md deleted file mode 100644 index c450019a9..000000000 --- a/doc/5/core-classes/room/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: Room -description: Room documentation ---- diff --git a/doc/5/core-classes/room/renew/index.md b/doc/5/core-classes/room/renew/index.md deleted file mode 100644 index ed9752c51..000000000 --- a/doc/5/core-classes/room/renew/index.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -code: false -type: page -title: renew -description: Room:renew ---- - -# renew - -Renew the subscription. Force a new subscription using the same filters if no new ones are provided. - -Unsubscribes first if this `Room` object was already listening to events. - ---- - -## renew([filters], notificationCallback, subscriptionCallback) - -| Arguments | Type | Description | -| ---------------------- | ----------- | ------------------------------------------------------------------------------- | -| `filters` | JSON Object | [Filters](/core/1/koncorde) | -| `notificationCallback` | function | Function called each time a [notification](/sdk/js/5/essentials/realtime-notifications) is received | -| `subscriptionCallback` | function | Function called with the subscription result | - -## Usage - -<<< ./snippets/renew-1.js diff --git a/doc/5/core-classes/room/renew/snippets/renew-1.js b/doc/5/core-classes/room/renew/snippets/renew-1.js deleted file mode 100644 index 739d0f7f2..000000000 --- a/doc/5/core-classes/room/renew/snippets/renew-1.js +++ /dev/null @@ -1,8 +0,0 @@ -room.renew({in: {field: ['some', 'new', 'filter']}}, function (err, res) { - // called each time a change is detected on documents matching this filter - - // check the Room/Notifications section of this documentation - // to get notification examples -}, function (err, res) { - // handles the subscription result -}); diff --git a/doc/5/core-classes/room/set-headers/index.md b/doc/5/core-classes/room/set-headers/index.md deleted file mode 100644 index d3a7e1577..000000000 --- a/doc/5/core-classes/room/set-headers/index.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -code: false -type: page -title: setHeaders -description: Room:setHeaders ---- - -# setHeaders - -> Returns itself - -This is a helper function returning itself, allowing to easily chain calls. - ---- - -## setHeaders(content, [replace]) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------------------------------------------------------- | -| `content` | JSON Object | New content | -| `replace` | boolean | true: replace the current content with the provided data, false: merge it | - -**Note:** by default, the `replace` argument is set to `false` - ---- - -## Return value - -Returns this `Room` object to allow chaining. - -## Usage - -<<< ./snippets/set-headers-1.js diff --git a/doc/5/core-classes/room/set-headers/snippets/set-headers-1.js b/doc/5/core-classes/room/set-headers/snippets/set-headers-1.js deleted file mode 100644 index 967926079..000000000 --- a/doc/5/core-classes/room/set-headers/snippets/set-headers-1.js +++ /dev/null @@ -1 +0,0 @@ -room.setHeaders({someContent: 'someValue'}, true); diff --git a/doc/5/core-classes/room/unsubscribe/index.md b/doc/5/core-classes/room/unsubscribe/index.md deleted file mode 100644 index 9babd9141..000000000 --- a/doc/5/core-classes/room/unsubscribe/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: unsubscribe -description: Room:unsubscribe ---- - -# unsubscribe - -Cancels the current subscription. - ---- - -## Return value - -Returns this `Room` object to allow chaining. - -## Usage - -<<< ./snippets/unsubscribe-1.js diff --git a/doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js b/doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js deleted file mode 100644 index 94f6dddfe..000000000 --- a/doc/5/core-classes/room/unsubscribe/snippets/unsubscribe-1.js +++ /dev/null @@ -1 +0,0 @@ -room.unsubscribe(); diff --git a/doc/5/core-classes/search-result/constructor/index.md b/doc/5/core-classes/search-result/constructor/index.md deleted file mode 100644 index e62662d70..000000000 --- a/doc/5/core-classes/search-result/constructor/index.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -code: false -type: page -title: constructor -description: SearchResult:constructor -order: 1 ---- - -# Constructor - -This object can only be instantiated internally by this SDK, and is an easy-to-use representation of a paginated result from a [search](/sdk/js/5/core-classes/collection/search) or a [scroll](/sdk/js/5/core-classes/collection/scroll) request. - ---- - -## Properties - -| Property name | Type | Description | get/set | -| -------------- | ---------- | --------------------------------------------------------- | ------- | -| `aggregations` | object | The result of an aggregation produced by a search request | get | -| `collection` | Collection | The collection associated to this document | get | -| `documents` | Document[] | An array of instantiated Document objects | get | -| `fetched` | number | The number of fetched documents so far | get/set | -| `options` | object | The arguments of the search/scroll request | get | -| `filters` | object | The filters of the search request | get | -| `total` | integer | The total number of results that can be fetched | get | - ---- diff --git a/doc/5/core-classes/search-result/fetch-next/index.md b/doc/5/core-classes/search-result/fetch-next/index.md deleted file mode 100644 index 9af55f41c..000000000 --- a/doc/5/core-classes/search-result/fetch-next/index.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -code: false -type: page -title: fetchNext -description: SearchResult:fetchNext ---- - -# fetchNext - -Fetches the next SearchResult, by triggering a new search/scroll request depending on the options and filters of the SearchResult. - -If the previous request was a search or a scroll action which provided a `scroll` argument, -`fetchNext` will use the `scrollId` retrieved from the current result to make a new scroll request. - -If the previous request was a search action which provided `size` argument and `sort` filtering, -`fetchNext` will use Elasticsearch's [`search_after`](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-search-after.html) mechanism, which can efficiently search through a large volume of documents, bypassing internal hard limits\[1\], -but at the cost of reflecting the latest changes of the index, as opposed to using scroll. - -If the previous request was a search action which provided `from` and `size` arguments, -`fetchNext` will add `size` to `from` and make a new search request. - ---- - -## How to process every document of a collection - -The safest way to process all documents in a collection is to fetch them as a batch in order to avoid memory exhaustion and possibly hitting some hard limits\[1\] on the database layer. - -
Make sure your first search request includes size and scroll parameters
- -
\[1\] Elasticsearch limits the number of documents inside a single page to [10,000 by default](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/index-modules.html#dynamic-index-settings).
- -## Usage - -<<< ./snippets/fetch-next-1.js - -<<< ./snippets/fetch-next-2.js diff --git a/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js b/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js deleted file mode 100644 index d7a6fcf01..000000000 --- a/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -searchResult.fetchNext(function (error, nextSearchResult) { - // called once the fetchNext action has been completed - // nextSearchResult is an instantiated SearchResult object -}); - -// Using promises (NodeJS) -searchResult.fetchNextPromise() - .then(nextSearchResult => { - // called once the fetchNext action has been completed - // nextSearchResult is an instantiated SearchResult object - }); diff --git a/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js b/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js deleted file mode 100644 index 4efe620de..000000000 --- a/doc/5/core-classes/search-result/fetch-next/snippets/fetch-next-2.js +++ /dev/null @@ -1,22 +0,0 @@ -var processDocument = function (document) { - // do something with the document -}; - -kuzzle - .collection('collection', 'index') - .search({ - from: 0, - size: 1000, - scroll: '30s', - query: {} - }, function getMoreUntilDone (error, searchResult) { - if (searchResult === null) { - return; - } - - searchResult.documents.forEach(function (document) { - processDocument(document); - }); - - searchResult.fetchNext(getMoreUntilDone); - }); diff --git a/doc/5/core-classes/search-result/index.md b/doc/5/core-classes/search-result/index.md deleted file mode 100644 index 11ca3f724..000000000 --- a/doc/5/core-classes/search-result/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: SearchResult -description: SearchResult documentation ---- diff --git a/doc/5/core-classes/security/constructor/index.md b/doc/5/core-classes/security/constructor/index.md deleted file mode 100644 index e455d5e6d..000000000 --- a/doc/5/core-classes/security/constructor/index.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -code: false -type: page -title: constructor -description: Security:constructor -order: 1 ---- - -# Constructor - -The Security component lets you handle user permissions in Kuzzle. - -Please refer to our [permissions guide](/core/1/guides/essentials/security/#user-permissions) for more information. - ---- - -## Security - -| Arguments | Type | Description | -| --------- | ------ | ------------------------------------------------- | -| `Kuzzle` | object | An instantiated [Kuzzle](/sdk/js/5/core-classes/kuzzle) object | - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/security/constructor/snippets/constructor-1.js b/doc/5/core-classes/security/constructor/snippets/constructor-1.js deleted file mode 100644 index 31cbcbdff..000000000 --- a/doc/5/core-classes/security/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - Constructor is not exposed in the JS/Node SDK. You may get the instantiated - Security object by calling Kuzzle.security - */ -var kuzzleSecurity = kuzzle.security; diff --git a/doc/5/core-classes/security/create-credentials/index.md b/doc/5/core-classes/security/create-credentials/index.md deleted file mode 100644 index 5530985c2..000000000 --- a/doc/5/core-classes/security/create-credentials/index.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -code: false -type: page -title: createCredentials -description: Security:createCredentials ---- - -# createCredentials - -Create credentials of user with `kuid` for the specified `strategy`. - ---- - -## createCredentials(strategy, kuid, credentials, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `strategy` | string | Strategy you want to create credentials in | -| `kuid` | string | User's kuid | -| `credentials` | JSON object | The credentials | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the created credentials. - -## Usage - -<<< ./snippets/create-credentials-1.js - -> Callback response - -```json -{ - "username": "foo", - "kuid": "" -} -``` diff --git a/doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js b/doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js deleted file mode 100644 index 147500fed..000000000 --- a/doc/5/core-classes/security/create-credentials/snippets/create-credentials-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.createCredentials('local', 'kuid', {'username': 'foo'}, function (error, credentials) { - -}); - -// Using promises (node.js) -kuzzle - .security - .createCredentialsPromise('local', 'kuid', {'username': 'foo'}) - .then(credentials => { - - }); diff --git a/doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js b/doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js deleted file mode 100644 index 04d9e0fd4..000000000 --- a/doc/5/core-classes/security/create-credentials/snippets/create-credentials-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "username": "foo", - "kuid": "" -} diff --git a/doc/5/core-classes/security/create-profile/index.md b/doc/5/core-classes/security/create-profile/index.md deleted file mode 100644 index 633db2ed5..000000000 --- a/doc/5/core-classes/security/create-profile/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: createProfile -description: Security:createProfile ---- - -# createProfile - -Create a new profile in Kuzzle. - -
-There is a small delay between profile creation and its availability in our search layer (usually a couple of seconds). -That means that a profile that was just created might not be returned by the searchProfiles function at first. -
- ---- - -## createProfile(id, content, [options], callback) - -| Arguments | Type | Description | -| ---------- | --------------------- | ----------------------------------------- | -| `id` | string | Unique profile identifier | -| `policies` | array of JSON objects | List of policies to apply to this profile | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `replaceIfExist` | boolean | If the same profile already exists: throw an error if sets to false. Replace the existing profile otherwise | `false` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Callback Response - -Returns a security [Profile](/sdk/js/5/core-classes/profile) object. - -## Usage - -<<< ./snippets/create-profile-1.js diff --git a/doc/5/core-classes/security/create-profile/snippets/create-profile-1.js b/doc/5/core-classes/security/create-profile/snippets/create-profile-1.js deleted file mode 100644 index 1bdd99904..000000000 --- a/doc/5/core-classes/security/create-profile/snippets/create-profile-1.js +++ /dev/null @@ -1,30 +0,0 @@ -var policies = [ - {roleId: 'myrole'}, - { - roleId: 'default', - restrictedTo: [ - {index: 'index1'}, - {index: 'index2', collections: ['foo', 'bar'] } - ] - } -]; - -// You can chose to replace the given profile if already exists -var options = { - replaceIfExist: true -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .createProfile('myprofile', policies, options, function(error, profile) { - - }); - -// Using promises (NodeJS) -kuzzle - .security - .createProfilePromise('myprofile', policies, options) - .then(profile => { - - }); diff --git a/doc/5/core-classes/security/create-restricted-user/index.md b/doc/5/core-classes/security/create-restricted-user/index.md deleted file mode 100644 index 236e6f60e..000000000 --- a/doc/5/core-classes/security/create-restricted-user/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: createRestrictedUser -description: Security:createRestrictedUser ---- - -# createRestrictedUser - -Create a new restricted user in Kuzzle. -This function allows anonymous users to create a "restricted" user with predefined rights. - -
-There is a small delay between user creation and its availability in our search layer (usually a couple of seconds). -That means that a user that was just created may not be returned by the searchUsers function at first. -
- ---- - -## createRestrictedUser(id, content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------ | -| `id` | string | Unique user identifier, will be used as username | -| `content` | JSON Object | A plain JSON object representing the user | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Callback response - -Resolves to a [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/create-restricted-user-1.js diff --git a/doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js b/doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js deleted file mode 100644 index dff21b95c..000000000 --- a/doc/5/core-classes/security/create-restricted-user/snippets/create-restricted-user-1.js +++ /dev/null @@ -1,27 +0,0 @@ -var userContent = { - content: { - }, - credentials: { - local: { - // The "local" authentication strategy requires a password - password: 'secretPassword', - lastLoggedIn: 1494411803 - } - } -}; - - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .createRestrictedUser('myuser', userContent, options, function(error, response) { - // result is a User object - }); - -// Using promises (NodeJS) -kuzzle - .security - .createRestrictedUserPromise('myuser', userContent, options) - .then((response) => { - // result is a User object - }); diff --git a/doc/5/core-classes/security/create-role/index.md b/doc/5/core-classes/security/create-role/index.md deleted file mode 100644 index 676962a94..000000000 --- a/doc/5/core-classes/security/create-role/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: createRole -description: Security:createRole ---- - -# createRole - -Create a new role in Kuzzle. - -
-There is a small delay between role creation and its availability in our search layer (usually a couple of seconds). -That means that a role that was just created may not be returned by the searchRole function at first. -
---- - -## createRole(id, content, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `id` | string | Unique role identifier | -| `content` | JSON Object | A plain JSON object representing the role | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `replaceIfExist` | boolean | If the same role already exists: throw an error if sets to false. Replace the existing role otherwise | `false` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Callback Response - -Returns a [Role](/sdk/js/5/core-classes/role) object. - -## Usage - -<<< ./snippets/create-role-1.js diff --git a/doc/5/core-classes/security/create-role/snippets/create-role-1.js b/doc/5/core-classes/security/create-role/snippets/create-role-1.js deleted file mode 100644 index 10a3e13f8..000000000 --- a/doc/5/core-classes/security/create-role/snippets/create-role-1.js +++ /dev/null @@ -1,29 +0,0 @@ -var roleDefinition = { - controllers: { - "*": { - actions: { - "*": true - } - } - } -}; - -// You can chose to replace the given role if already exists -var options = { - replaceIfExist: true -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .createRole('myrole', roleDefinition, options, function(error, response) { - // result is a Role object - }); - -// Using promises (NodeJS) -kuzzle - .security - .createRolePromise('myrole', roleDefinition, options) - .then((response) => { - // result is a Role object - }); diff --git a/doc/5/core-classes/security/create-user/index.md b/doc/5/core-classes/security/create-user/index.md deleted file mode 100644 index afdbb46e8..000000000 --- a/doc/5/core-classes/security/create-user/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -code: false -type: page -title: createUser -description: Security:createUser ---- - -# createUser - -Create a new user in Kuzzle. - -
-There is a small delay between user creation and its availability in our search layer (usually a couple of seconds). -That means that a user that was just created may not be returned by the searchUsers function at first. -
- ---- - -## createUser(id, user, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `id` | string | [Unique user identifier](/core/1/guides/essentials/user-authentication/#kuzzle-user-identifier-kuid) | -| `user` | JSON Object | A plain JSON object representing the user (see below) | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | Callback handling the response | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - -The `user` object to provide must have the following properties: - -- `content` (JSON object): user global properties - - This object must contain a `profileIds` properties, an array of strings listing the security [profiles](/core/1/guides/essentials/security/#users-profiles-and-roles) to be attached to the new user - - Any other property will be copied as additional global user information -- `credentials` (JSON object): a description of how the new user can identify themselves on Kuzzle - - Any number of credentials can be added, each one being an object with name equal to the [authentication strategy](/core/1/plugins/guides/strategies/#exposing-authentication-strategies) used to authenticate the user, and with the login data as content. - - If this object is left empty, the user will be created in Kuzzle but the will not be able to login. - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/create-user-1.js diff --git a/doc/5/core-classes/security/create-user/snippets/create-user-1.js b/doc/5/core-classes/security/create-user/snippets/create-user-1.js deleted file mode 100644 index 47f5460f4..000000000 --- a/doc/5/core-classes/security/create-user/snippets/create-user-1.js +++ /dev/null @@ -1,37 +0,0 @@ -var user = { - content: { - // A "profileIds" field is required to bind a user to existing profiles - profileIds: ['admin'], - - // Additional information may be provided - firstname: 'John', - lastname: 'Doe' - }, - credentials: { - // Authentication strategy to use - "local": { - // The necessary information to provide vary, - // depending on the chosen authentication strategy - "username": "jdoe", - "password": "secret password" - } - } -}; - -var options = {}; - - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .createUser('myuser', user, options, function(error, response) { - // result is a User object - }); - -// Using promises (NodeJS) -kuzzle - .security - .createUserPromise('myuser', user, options) - .then(response => { - // result is a User object - }); diff --git a/doc/5/core-classes/security/delete-credentials/index.md b/doc/5/core-classes/security/delete-credentials/index.md deleted file mode 100644 index fb309cd5f..000000000 --- a/doc/5/core-classes/security/delete-credentials/index.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -code: false -type: page -title: deleteCredentials -description: Security:deleteCredentials ---- - -# deleteCredentials - -Delete current user's credentials for the specified `strategy`. - ---- - -## deleteCredentials(strategy, kuid, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | -------------------------------------------- | -| `strategy` | string | Strategy you want to delete credentials from | -| `kuid` | string | User's kuid | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object reflecting the query status. - -## Usage - -<<< ./snippets/delete-credentials-1.js - -> Callback response - -```json -{ - "acknowledged": true -} -``` diff --git a/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js b/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js deleted file mode 100644 index a7a334331..000000000 --- a/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.deleteCredentials('local', 'kuid', function (error, result) { - -}); - -// Using promises (node.js) -kuzzle - .security - .deleteCredentialsPromise('local', 'kuid') - .then(result => { - - }); diff --git a/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js b/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js deleted file mode 100644 index 02d519956..000000000 --- a/doc/5/core-classes/security/delete-credentials/snippets/delete-credentials-2.js +++ /dev/null @@ -1,4 +0,0 @@ -on -{ - "acknowledged": true -} diff --git a/doc/5/core-classes/security/delete-profile/index.md b/doc/5/core-classes/security/delete-profile/index.md deleted file mode 100644 index 3dd29542c..000000000 --- a/doc/5/core-classes/security/delete-profile/index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -code: false -type: page -title: deleteProfile -description: Security:deleteProfile ---- - -# deleteProfile - -Delete the provided profile. - -
-There is a small delay between the time a profile is deleted and it being reflected in the search layer (usually a couple of seconds). -That means that a profile that was just deleted may still be returned by the searchProfiles function at first. -
- ---- - -## deleteProfile(id, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `id` | string | Unique profile identifier to delete | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Returns the ID of the security profile that has been deleted. - -## Usage - -<<< ./snippets/delete-profile-1.js - -> Callback response - -```json -"deleted profile identifier" -``` diff --git a/doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js b/doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js deleted file mode 100644 index 6f2131096..000000000 --- a/doc/5/core-classes/security/delete-profile/snippets/delete-profile-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .deleteProfile('myprofile', function(error, result) { - - }); - -// Using promises (NodeJS) -kuzzle - .security - .deleteProfilePromise('myprofile') - .then((result) => { - - }); diff --git a/doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js b/doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js deleted file mode 100644 index a10da12ab..000000000 --- a/doc/5/core-classes/security/delete-profile/snippets/delete-profile-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"deleted profile identifier" diff --git a/doc/5/core-classes/security/delete-role/index.md b/doc/5/core-classes/security/delete-role/index.md deleted file mode 100644 index d9412bfd3..000000000 --- a/doc/5/core-classes/security/delete-role/index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -code: false -type: page -title: deleteRole -description: Security:deleteRole ---- - -# deleteRole - -Delete the provided role. - -
-There is a small delay between the time a role is deleted and it being reflected in the search layer (usually a couple of seconds). -That means that a role that was just deleted may still be returned by the searchRoles function at first. -
- ---- - -## deleteRole(id, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `id` | string | Unique role identifier to delete | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Returns the id of the rold that has been deleted. - -## Usage - -<<< ./snippets/delete-role-1.js - -> Callback response - -```json -"deleted role identifier" -``` diff --git a/doc/5/core-classes/security/delete-role/snippets/delete-role-1.js b/doc/5/core-classes/security/delete-role/snippets/delete-role-1.js deleted file mode 100644 index fac5e1673..000000000 --- a/doc/5/core-classes/security/delete-role/snippets/delete-role-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .deleteRole('myrole', function(error, result) { - - }); - -// Using promises (NodeJS) -kuzzle - .security - .deleteRolePromise('myrole') - .then((result) => { - - }); diff --git a/doc/5/core-classes/security/delete-role/snippets/delete-role-2.js b/doc/5/core-classes/security/delete-role/snippets/delete-role-2.js deleted file mode 100644 index 5fb1655b2..000000000 --- a/doc/5/core-classes/security/delete-role/snippets/delete-role-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"deleted role identifier" diff --git a/doc/5/core-classes/security/delete-user/index.md b/doc/5/core-classes/security/delete-user/index.md deleted file mode 100644 index 14e4f0f7c..000000000 --- a/doc/5/core-classes/security/delete-user/index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -code: false -type: page -title: deleteUser -description: Security:deleteUser ---- - -# deleteUser - -Delete the provided user. - -
-There is a small delay between the time a user is deleted and it being reflected in the search layer (usually a couple of seconds). -That means that a user that has just been deleted may still be returned by the searchUsers function at first. -
- ---- - -## deleteUser(id, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `id` | string | Unique user identifier to delete | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Return the id of the user that has been deleted. - -## Usage - -<<< ./snippets/delete-user-1.js - -> Callback response - -```json -"deleted user identifier" -``` diff --git a/doc/5/core-classes/security/delete-user/snippets/delete-user-1.js b/doc/5/core-classes/security/delete-user/snippets/delete-user-1.js deleted file mode 100644 index ee5ff4457..000000000 --- a/doc/5/core-classes/security/delete-user/snippets/delete-user-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .deleteUser('myuser', function(error, result) { - - }); - -// Using promises (NodeJS) -kuzzle - .security - .deleteUserPromise('myuser') - .then((result) => { - - }); diff --git a/doc/5/core-classes/security/delete-user/snippets/delete-user-2.js b/doc/5/core-classes/security/delete-user/snippets/delete-user-2.js deleted file mode 100644 index e99606eb7..000000000 --- a/doc/5/core-classes/security/delete-user/snippets/delete-user-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -"deleted user identifier" diff --git a/doc/5/core-classes/security/fetch-profile/index.md b/doc/5/core-classes/security/fetch-profile/index.md deleted file mode 100644 index 10b4fda6c..000000000 --- a/doc/5/core-classes/security/fetch-profile/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: fetchProfile -description: Security:fetchProfile ---- - -# fetchProfile - -Fetches a single stored profile using its unique ID. - ---- - -## fetchProfile(id, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `id` | string | Unique profile identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a security [Profile](/sdk/js/5/core-classes/profile) object. - -## Usage - -<<< ./snippets/fetch-profile-1.js diff --git a/doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js b/doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js deleted file mode 100644 index 12fecd744..000000000 --- a/doc/5/core-classes/security/fetch-profile/snippets/fetch-profile-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .fetchProfile('myprofile', function(error, result) { - // result is a Profile object - }); - -// Using promises (NodeJS) -kuzzle - .security - .fetchProfilePromise('myprofile') - .then((result) => { - // result is a Profile object - }); diff --git a/doc/5/core-classes/security/fetch-role/index.md b/doc/5/core-classes/security/fetch-role/index.md deleted file mode 100644 index 20f9f08ba..000000000 --- a/doc/5/core-classes/security/fetch-role/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: fetchRole -description: Security:fetchRole ---- - -# fetchRole - -Fetches a single stored role using its unique ID. - ---- - -## fetchRole(id, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `id` | string | Unique role identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a [Role](/sdk/js/5/core-classes/role) object. - -## Usage - -<<< ./snippets/fetch-role-1.js diff --git a/doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js b/doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js deleted file mode 100644 index da2ccb699..000000000 --- a/doc/5/core-classes/security/fetch-role/snippets/fetch-role-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .fetchRole('myrole', function(error, result) { - // result is a Role object - }); - -// Using promises (NodeJS) -kuzzle - .security - .fetchRolePromise('myrole') - .then((result) => { - // result is a Role object - }); diff --git a/doc/5/core-classes/security/fetch-user/index.md b/doc/5/core-classes/security/fetch-user/index.md deleted file mode 100644 index 41d59fdba..000000000 --- a/doc/5/core-classes/security/fetch-user/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: fetchUser -description: Security:fetchUser ---- - -# fetchUser - -Fetches a single stored user using its unique ID. - ---- - -## fetchUser(id, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `id` | string | Unique user identifier | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/fetch-user-1.js diff --git a/doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js b/doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js deleted file mode 100644 index 9399bad96..000000000 --- a/doc/5/core-classes/security/fetch-user/snippets/fetch-user-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .fetchUser('myuser', function(error, result) { - // result is a User object - }) - -// Using promises (NodeJS) -kuzzle - .security - .fetchUserPromise('myuser') - .then((result) => { - // result is a User object - }) diff --git a/doc/5/core-classes/security/get-all-credential-fields/index.md b/doc/5/core-classes/security/get-all-credential-fields/index.md deleted file mode 100644 index 8a5a2ec4e..000000000 --- a/doc/5/core-classes/security/get-all-credential-fields/index.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -code: false -type: page -title: getAllCredentialFields -description: Security:getAllCredentialFields ---- - -# getAllCredentialFields - -Fetches a list of accepted fields per authentication strategy. - ---- - -## getAllCredentialFields([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the credential fields. - -## Usage - -<<< ./snippets/get-all-credential-fields-1.js - -> Callback response: - -```json -{ - "local": ["kuid", "username"] -} -``` diff --git a/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js b/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js deleted file mode 100644 index f08182ca5..000000000 --- a/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.getAllCredentialFields(function (error, strategies) { - -}); - -// Using promises (node.js) -kuzzle - .security - .getAllCredentialFieldsPromise() - .then(strategies => { - - }); diff --git a/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js b/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js deleted file mode 100644 index f50f02528..000000000 --- a/doc/5/core-classes/security/get-all-credential-fields/snippets/get-all-credential-fields-2.js +++ /dev/null @@ -1,7 +0,0 @@ -on -{ - "local": [ - "kuid", - "username" - ] -} diff --git a/doc/5/core-classes/security/get-credentials-fields/index.md b/doc/5/core-classes/security/get-credentials-fields/index.md deleted file mode 100644 index 9453ea1c1..000000000 --- a/doc/5/core-classes/security/get-credentials-fields/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: getCredentialsFields -description: Security:getCredentialsFields ---- - -# getCredentialFields - -Get credential information for the specified `strategy`. - ---- - -## getCredentialFields(strategy, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `strategy` | string | Strategy you want to get credentials from | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -The result is a an array of credential fields. - -## Usage - -<<< ./snippets/get-credentials-fields-1.js - -> Callback response: - -```json -["kuid", "username"] -``` diff --git a/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js b/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js deleted file mode 100644 index 7d667d282..000000000 --- a/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.getCredentialFields('local', function (error, fields) { - -}); - -// Using promises (node.js) -kuzzle - .security - .getCredentialFieldsPromise('local') - .then(fields => { - - }); diff --git a/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js b/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js deleted file mode 100644 index 516f634a5..000000000 --- a/doc/5/core-classes/security/get-credentials-fields/snippets/get-credentials-fields-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -[ - "kuid", - "username" -] diff --git a/doc/5/core-classes/security/get-credentials/index.md b/doc/5/core-classes/security/get-credentials/index.md deleted file mode 100644 index 06aaa9141..000000000 --- a/doc/5/core-classes/security/get-credentials/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: getCredentials -description: Security:getCredentials ---- - -# getCredentials - -Get credential information of user with `kuid` for the specified `strategy`. - ---- - -## getCredentials(strategy, kuid, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `strategy` | string | Strategy you want to get credentials from | -| `kuid` | string | User's kuid | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -The result is a an object with the credentials. - -## Usage - -<<< ./snippets/get-credentials-1.js - -> Callback response - -```json -{ - "username": "foo", - "kuid": "" -} -``` diff --git a/doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js b/doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js deleted file mode 100644 index 8d9970493..000000000 --- a/doc/5/core-classes/security/get-credentials/snippets/get-credentials-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.getCredentials('local', 'kuid', function (error, credentials) { - -}); - -// Using promises (node.js) -kuzzle - .security - .getCredentialsPromise('local', 'kuid') - .then(credentials => { - - }); diff --git a/doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js b/doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js deleted file mode 100644 index c7a4a27bf..000000000 --- a/doc/5/core-classes/security/get-credentials/snippets/get-credentials-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "username": "foo", - "kuid": "" -} diff --git a/doc/5/core-classes/security/get-user-rights/index.md b/doc/5/core-classes/security/get-user-rights/index.md deleted file mode 100644 index 3c8ad7764..000000000 --- a/doc/5/core-classes/security/get-user-rights/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: getUserRights -description: Security:getUserRights ---- - -# getUserRights - -> Callback response example - -```json -[ - { - "controller": "my-controller", - "action": "my-action", - "index": "*", - "collection": "*", - "value": "allowed" - }, - { - "controller": "another-controller", - "action": "*", - "index": "my-index", - "collection": "*", - "value": "conditional" - } -] -``` - -Given a Kuzzle user id (`kuid`), retrieves the list of permissions granted to that user. - ---- - -### getUserRights(id, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------- | -| `kuid` | String | [Kuzzle User Unique Identifier](/core/1/guides/essentials/user-authentication/#kuzzle-user-identifier-kuid) | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -### Callback Response - -Returns an array of objects. - -## Usage - -<<< ./snippets/get-user-rights-1.js diff --git a/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js b/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js deleted file mode 100644 index 9df2ba532..000000000 --- a/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-1.js +++ /dev/null @@ -1,14 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .getUserRights('kuid', function(error, rights) { - - });reflecting - -// Using promises (NodeJS) -kuzzle - .security - .getUserRightsPromise('kuid') - .then(rights => { - - }); diff --git a/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js b/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js deleted file mode 100644 index 8e46b95c0..000000000 --- a/doc/5/core-classes/security/get-user-rights/snippets/get-user-rights-2.js +++ /dev/null @@ -1,17 +0,0 @@ -on -[ - { - "controller": "my-controller", - "action": "my-action", - "index": "*", - "collection": "*", - "value": "allowed" - }, - { - "controller": "another-controller", - "action": "*", - "index": "my-index", - "collection": "*", - "value": "conditional" - } -] diff --git a/doc/5/core-classes/security/has-credentials/index.md b/doc/5/core-classes/security/has-credentials/index.md deleted file mode 100644 index 71d2c114b..000000000 --- a/doc/5/core-classes/security/has-credentials/index.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -code: false -type: page -title: hasCredentials -description: Security:hasCredentials ---- - -# hasCredentials - -Checks if a user has credentials for the provided strategy. - ---- - -## hasCredentials(strategy, kuid, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------- | -| `strategy` | string | Strategy to check for credentials | -| `kuid` | JSON object | User's kuid | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a boolean value. - -## Usage - -<<< ./snippets/has-credentials-1.js diff --git a/doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js b/doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js deleted file mode 100644 index 966d18d94..000000000 --- a/doc/5/core-classes/security/has-credentials/snippets/has-credentials-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.hasCredentials('local', 'kuid', function (error, result) { - -}); - -// Using promises (node.js) -kuzzle - .security - .hasCredentialsPromise('local', 'kuid') - .then(result => { - - }); diff --git a/doc/5/core-classes/security/index.md b/doc/5/core-classes/security/index.md deleted file mode 100644 index ba1823f24..000000000 --- a/doc/5/core-classes/security/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: Security -description: Security documentation ---- diff --git a/doc/5/core-classes/security/is-action-allowed/index.md b/doc/5/core-classes/security/is-action-allowed/index.md deleted file mode 100644 index 9cc5fb963..000000000 --- a/doc/5/core-classes/security/is-action-allowed/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -code: false -type: page -title: isActionAllowed -description: Security:isActionAllowed ---- - -# isActionAllowed - -Specifies if an action is allowed, denied or conditional based on the rights provided as the first argument: - -- `allowed` is returned when an action is authorized without condition -- `conditional` is returned when the authorization depends on a closure -- `denied` is returned when the action is forbidden - -An action is defined as a pair of action and controller (mandatory), plus an index and a collection(optional). - -
-You can get the rights from Kuzzle by using [`Security.getUserRights`](/sdk/js/5/core-classes/security/get-user-rights) and [`Kuzzle.getMyRights`](/sdk/js/5/core-classes/kuzzle/get-my-rights). -
- ---- - -## isActionAllowed(rights, controller, action, index, collection) - -| Arguments | Type | Description | -| ------------ | ---------- | -------------- | -| `rights` | JSON array | Rights list | -| `controller` | String | The controller | -| `action` | String | The action | -| `index` | String | The index | -| `collection` | String | The collection | - ---- - -## Return Value - -Returns either `allowed`, `denied` or `conditional`. - -## Usage - -<<< ./snippets/is-action-allowed-1.js diff --git a/doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js b/doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js deleted file mode 100644 index ee672cb13..000000000 --- a/doc/5/core-classes/security/is-action-allowed/snippets/is-action-allowed-1.js +++ /dev/null @@ -1,6 +0,0 @@ -kuzzle.security.getMyRights((err, rights) => { - if (!err) { - // returns either "allowed", "denied" or "conditional" - var allowed = kuzzle.security.isActionAllowed(rights, 'read', 'get', 'index1', 'collection1'); - } -}); diff --git a/doc/5/core-classes/security/profile/index.md b/doc/5/core-classes/security/profile/index.md deleted file mode 100644 index cdf331731..000000000 --- a/doc/5/core-classes/security/profile/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: profile -description: Security:profile ---- - -# profile - -Instantiate a new security [Profile](/sdk/js/5/core-classes/profile) object. - ---- - -## profile(id, content) - -| Arguments | Type | Description | -| --------- | ----------- | ------------------------- | -| `id` | string | Unique profile identifier | -| `content` | JSON Object | Profile content | - ---- - -## Return Value - -Returns the new security [Profile](/sdk/js/5/core-classes/profile) object. - -## Usage - -<<< ./snippets/profile-1.js diff --git a/doc/5/core-classes/security/profile/snippets/profile-1.js b/doc/5/core-classes/security/profile/snippets/profile-1.js deleted file mode 100644 index 9852833cf..000000000 --- a/doc/5/core-classes/security/profile/snippets/profile-1.js +++ /dev/null @@ -1,8 +0,0 @@ -var profileDefinition = { - policies: [ - {roleId: 'myrole'}, - {roleId: 'default', restrictedTo: [{index: 'index1'}, {index: 'index2', collections: ['foo', 'bar'] } ] } - ] -}; - -var profile = kuzzle.security.profile('myprofile', profileDefinition); diff --git a/doc/5/core-classes/security/replace-user/index.md b/doc/5/core-classes/security/replace-user/index.md deleted file mode 100644 index acc6a38dc..000000000 --- a/doc/5/core-classes/security/replace-user/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: replaceUser -description: Security:replaceUser ---- - -# replaceUser - -Replaces an existing user. - ---- - -## replaceUser(id, content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------------------------------------------------------------------ | -| `id` | string | Unique user identifier | -| `content` | JSON Object | A plain JSON object representing the user, should contain the mandatory `profileIds` field | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Returns a [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/replace-user-1.js diff --git a/doc/5/core-classes/security/replace-user/snippets/replace-user-1.js b/doc/5/core-classes/security/replace-user/snippets/replace-user-1.js deleted file mode 100644 index 0f886ac3c..000000000 --- a/doc/5/core-classes/security/replace-user/snippets/replace-user-1.js +++ /dev/null @@ -1,13 +0,0 @@ -var newContent = { - profileIds: ['admin'], - firstname: 'My Name Is', - lastname: 'Jonas' -}; - - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .replaceUser("User ID", newContent, function (err, replacedUser) { - // "replacedUser" is an instance of a User object - }); diff --git a/doc/5/core-classes/security/role/index.md b/doc/5/core-classes/security/role/index.md deleted file mode 100644 index 2f4f08715..000000000 --- a/doc/5/core-classes/security/role/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: role -description: Security:role ---- - -# role - -Instantiate a new [Role](/sdk/js/5/core-classes/role) object. - ---- - -## role(id, content) - -| Arguments | Type | Description | -| --------- | ----------- | ---------------------- | -| `id` | string | Unique role identifier | -| `content` | JSON Object | Role content | - ---- - -## Return Value - -Returns the new [Role](/sdk/js/5/core-classes/role) object. - -## Usage - -<<< ./snippets/role-1.js diff --git a/doc/5/core-classes/security/role/snippets/role-1.js b/doc/5/core-classes/security/role/snippets/role-1.js deleted file mode 100644 index 6255003d8..000000000 --- a/doc/5/core-classes/security/role/snippets/role-1.js +++ /dev/null @@ -1,11 +0,0 @@ -var roleDefinition = { - controllers: { - "*": { - actions: { - "*": true - } - } - } -}; - -var role = kuzzle.security.role('role', roleDefinition); diff --git a/doc/5/core-classes/security/scroll-profiles/index.md b/doc/5/core-classes/security/scroll-profiles/index.md deleted file mode 100644 index 7ed5b64ed..000000000 --- a/doc/5/core-classes/security/scroll-profiles/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: scrollProfiles -description: Security:scrollProfiles ---- - -# scrollProfiles - -Scrolls on stored profiles using the provided scroll ID. - ---- - -## scrollProfiles(scrollId, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------- | -| `scrollId` | string | Scroll identifier retrieved from a search query | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the list of fetched security profiles according to the scroll parameters (offset, limit etc.). - -## Usage - -<<< ./snippets/scroll-profiles-1.js diff --git a/doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js b/doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js deleted file mode 100644 index 3994748cf..000000000 --- a/doc/5/core-classes/security/scroll-profiles/snippets/scroll-profiles-1.js +++ /dev/null @@ -1,6 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .scrollProfiles(scrollId, options, function(error, result) { - // called once the scroll action has been completed - }); diff --git a/doc/5/core-classes/security/scroll-users/index.md b/doc/5/core-classes/security/scroll-users/index.md deleted file mode 100644 index 530b6ed8b..000000000 --- a/doc/5/core-classes/security/scroll-users/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -code: false -type: page -title: scrollUsers -description: Security:scrollUsers ---- - -# scrollUsers - -Scrolls on stored users using the provided scroll ID. - ---- - -## scrollUsers(scrollId, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------- | -| `scrollId` | string | Scroll identifier retrieved from a search query | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns the list of fetched users according to the scroll parameters (offset, limit etc.). - -## Usage - -<<< ./snippets/scroll-users-1.js diff --git a/doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js b/doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js deleted file mode 100644 index 35e47bf69..000000000 --- a/doc/5/core-classes/security/scroll-users/snippets/scroll-users-1.js +++ /dev/null @@ -1,6 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .scrollUsers(scrollId, options, function(error, result) { - // called once the scroll action has been completed - }); diff --git a/doc/5/core-classes/security/search-profiles/index.md b/doc/5/core-classes/security/search-profiles/index.md deleted file mode 100644 index d6442499f..000000000 --- a/doc/5/core-classes/security/search-profiles/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -code: false -type: page -title: searchProfiles -description: Security:searchProfiles ---- - -# searchProfiles - -Search for security profiles, optionally returning only those linked to the provided list of security roles. - ---- - -## searchProfiles(filters, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `filters` | JSON Object | Search query | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `from` | number | Starting offset | `0` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | -| `size` | integer | Number of hits to return per page | `10` | - ---- - -## Filters - -| Filter | Type | Description | Default | -| ------- | ----- | ------------------------------------------------ | ------- | -| `roles` | array | Contains an array `roles` with a list of role id | `[]` | - ---- - -## Callback Response - -Returns a JSON Object - -## Usage - -<<< ./snippets/search-profiles-1.js - -> Callback response: - -```json -{ - "total": 124, - "profiles": [ - // array of Profile objects - ], - // only if a scroll parameter has been provided - "scrollId": "" -} -``` diff --git a/doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js b/doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js deleted file mode 100644 index cb3ab7690..000000000 --- a/doc/5/core-classes/security/search-profiles/snippets/search-profiles-1.js +++ /dev/null @@ -1,36 +0,0 @@ -// optional: search only for profiles referring the listed roles -const filters = { - roles: ['myrole', 'admin'] -}; - -// optional: result pagination configuration -const options = { - from: 0, - size: 10, - scroll: '1m' -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .searchProfiles(filters, options, function (error, result) { - // result is a JSON Object with the following properties: - // { - // total: , - // profiles: [, , ...], - // scrollId: "" - // } - }); - -// Using promises (NodeJS) -kuzzle - .security - .searchProfilesPromise(filters, options) - .then(result => { - // result is a JSON Object with the following properties: - // { - // total: , - // profiles: [, , ...], - // scrollId: "" - // } - }); diff --git a/doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js b/doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js deleted file mode 100644 index a5ae820a7..000000000 --- a/doc/5/core-classes/security/search-profiles/snippets/search-profiles-2.js +++ /dev/null @@ -1,9 +0,0 @@ -on -{ - "total": 124, - "profiles": [ - // array of Profile objects - ], - // only if a scroll parameter has been provided - "scrollId": "" -} diff --git a/doc/5/core-classes/security/search-roles/index.md b/doc/5/core-classes/security/search-roles/index.md deleted file mode 100644 index dcba26240..000000000 --- a/doc/5/core-classes/security/search-roles/index.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -code: false -type: page -title: searchRoles -description: Security:searchRoles ---- - -# searchRoles - -Search for security roles, optionally returning only the roles giving access to the provided controller names. - ---- - -## searchRoles(filters, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ---------------------------------------------------------------------------------------------------- | -| `filters` | JSON Object | Optionally contains a "controllers" array listing the controller names used to filter searched roles | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Filters - -| Filter | Type | Description | Default | -| ------------- | ----- | --------------------------------------------------------- | ------- | -| `controllers` | array | retrieve only roles allowing access to the provided names | `[]` | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ---------------------------------- | ------- | -| `from` | number | Starting offset | `0` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `size` | number |  Number of hits to return per page | `10` | - ---- - -## Callback Response - -Return a JSON Object - -## Usage - -<<< ./snippets/search-roles-1.js - -> Callback response: - -```json -{ - "total": 124, - "roles": [ - // array of Role - ] -} -``` diff --git a/doc/5/core-classes/security/search-roles/snippets/search-roles-1.js b/doc/5/core-classes/security/search-roles/snippets/search-roles-1.js deleted file mode 100644 index d162b8c5d..000000000 --- a/doc/5/core-classes/security/search-roles/snippets/search-roles-1.js +++ /dev/null @@ -1,34 +0,0 @@ -// optional: retrieve only roles allowing access to the -// provided controller names -const filters = { - controllers: ['document'] -}; - -// optional result pagination configuration -const options = { - from: 0, - size: 10 -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .searchRoles(filters, options, function(error, result) { - // result is a JSON Object with the following properties: - // { - // total: , - // roles: [, , ...] - // } - }); - -// Using promises (NodeJS) -kuzzle - .security - .searchRolesPromise(filters, options) - .then(result => { - // result is a JSON Object with the following properties: - // { - // total: , - // roles: [, , ...] - // } - }); diff --git a/doc/5/core-classes/security/search-roles/snippets/search-roles-2.js b/doc/5/core-classes/security/search-roles/snippets/search-roles-2.js deleted file mode 100644 index 9d306fa04..000000000 --- a/doc/5/core-classes/security/search-roles/snippets/search-roles-2.js +++ /dev/null @@ -1,7 +0,0 @@ -on -{ - "total": 124, - "roles": [ - // array of Role - ] -} diff --git a/doc/5/core-classes/security/search-users/index.md b/doc/5/core-classes/security/search-users/index.md deleted file mode 100644 index 75d9fa02a..000000000 --- a/doc/5/core-classes/security/search-users/index.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -code: false -type: page -title: searchUsers -description: Security:searchUsers ---- - -# searchUsers - -Return users matching the given filter. - ---- - -## searchUsers(filters, [options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| `filters` | JSON Object | Filter in [Elasticsearch's Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/query-filter-context.html) format | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `from` | number | Starting offset | `0` | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `scroll` | string | Start a scroll session, with a time to live equals to this parameter's value following the [Elastisearch time format](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/common-options.html#time-units) | `undefined` | -| `size` | number |  Number of hits to return per result page | `10` | - -
- To get more information about scroll sessions, please refer to the [API reference documentation](/core/1/api/controllers/document/search/). -
- ---- - -## Callback Response - -Return a JSON Object - -## Usage - -<<< ./snippets/search-users-1.js - -> Callback response: - -```json -{ - "total": 124, - "users": [ - // array of User objects - ], - // only if a scroll parameter has been provided - "scrollId": "" -} -``` diff --git a/doc/5/core-classes/security/search-users/snippets/search-users-1.js b/doc/5/core-classes/security/search-users/snippets/search-users-1.js deleted file mode 100644 index 73da2aa12..000000000 --- a/doc/5/core-classes/security/search-users/snippets/search-users-1.js +++ /dev/null @@ -1,52 +0,0 @@ -const filter = { - bool: { - must: [ - { - terms: { - profileIds: ['anonymous', 'default'] - } - }, - { - geo_distance: { - distance: '10km', - pos: { - lat: 48.8566140, - lon: 2.352222 - } - } - } - ] - } -}; - -// optional: result pagination configuration -const options = { - from: 0, - size: 10, - scroll: '1m' -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .searchUsers(filters, options, function(error, result) { - // result is a JSON Object with the following properties: - // { - // total: , - // users: [, , ...], - // scrollId: "" - // } - }); - -// Using promises (NodeJS) -kuzzle - .security - .searchUsersPromise(filters, options) - .then(result => { - // result is a JSON Object with the following properties: - // { - // total: , - // users: [, , ...], - // scrollId: "" - // } - }); diff --git a/doc/5/core-classes/security/search-users/snippets/search-users-2.js b/doc/5/core-classes/security/search-users/snippets/search-users-2.js deleted file mode 100644 index 11c0790f8..000000000 --- a/doc/5/core-classes/security/search-users/snippets/search-users-2.js +++ /dev/null @@ -1,9 +0,0 @@ -on -{ - "total": 124, - "users": [ - // array of User objects - ], - // only if a scroll parameter has been provided - "scrollId": "" -} diff --git a/doc/5/core-classes/security/update-credentials/index.md b/doc/5/core-classes/security/update-credentials/index.md deleted file mode 100644 index 947b42ed8..000000000 --- a/doc/5/core-classes/security/update-credentials/index.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -code: false -type: page -title: updateCredentials -description: Security:updateCredentials ---- - -# updateCredentials - -Update the current user's credentials for the specified ``. The credentials to send depend on the authentication plugin and the strategy. - ---- - -## updateCredentials(strategy, kuid, credentials, [options], [callback]) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `strategy` | string | Strategy you want to create credentials in | -| `kuid` | JSON object | User's kuid | -| `credentials` | JSON object | The credentials | -| `options` | JSON object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an object with the updated credentials. - -## Usage - -<<< ./snippets/update-credentials-1.js - -> Callback response - -```json -{ - "username": "foo", - "kuid": "" -} -``` diff --git a/doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js b/doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js deleted file mode 100644 index 07899e16a..000000000 --- a/doc/5/core-classes/security/update-credentials/snippets/update-credentials-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.updateCredentials('local', 'kuid', {'username': 'foo'}, function (error, updatedCredentials) { - -}); - -// Using promises (node.js) -kuzzle - .security - .updateCredentialsPromise('local', 'kuid', {'username': 'foo'}) - .then(updatedCredentials => { - - }); diff --git a/doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js b/doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js deleted file mode 100644 index 6e7d085e7..000000000 --- a/doc/5/core-classes/security/update-credentials/snippets/update-credentials-2.js +++ /dev/null @@ -1,5 +0,0 @@ -on -{ - "username": "foo", - "kuid": "" -} diff --git a/doc/5/core-classes/security/update-profile/index.md b/doc/5/core-classes/security/update-profile/index.md deleted file mode 100644 index 81591ce56..000000000 --- a/doc/5/core-classes/security/update-profile/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: updateProfile -description: Security:updateProfile ---- - -# updateProfile - -Performs a partial update on an existing profile. - ---- - -## updateProfile(id, content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ---------------- | ----------------------------------------- | -| `id` | string | Unique role identifier | -| `policies` | array of objects | List of policies to apply to this profile | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Return an updated [Profile](/sdk/js/5/core-classes/profile) object. - -## Usage - -<<< ./snippets/update-profile-1.js diff --git a/doc/5/core-classes/security/update-profile/snippets/update-profile-1.js b/doc/5/core-classes/security/update-profile/snippets/update-profile-1.js deleted file mode 100644 index 331df7889..000000000 --- a/doc/5/core-classes/security/update-profile/snippets/update-profile-1.js +++ /dev/null @@ -1,25 +0,0 @@ -var policies = [ - {roleId: 'myrole'}, - { - roleId: 'default', - restrictedTo: [ - {index: 'index1'}, - {index: 'index2', collections: ['foo', 'bar'] } - ] - } -]; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .updateProfile("profile ID", policies, function (err, updatedProfile) { - - }); - -// Using promises (NodeJS) -kuzzle - .security - .updateProfilePromise("profile ID", policies) - .then(updatedProfile => { - - }); diff --git a/doc/5/core-classes/security/update-role/index.md b/doc/5/core-classes/security/update-role/index.md deleted file mode 100644 index db58fb15e..000000000 --- a/doc/5/core-classes/security/update-role/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: updateRole -description: Security:updateRole ---- - -# updateRole - -Performs a partial update on an existing role. - ---- - -## updateRole(id, content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `id` | string | Unique role identifier | -| `content` | JSON Object | A plain JSON object representing the role | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Returns an updated [Role](/sdk/js/5/core-classes/role) object. - -## Usage - -<<< ./snippets/update-role-1.js diff --git a/doc/5/core-classes/security/update-role/snippets/update-role-1.js b/doc/5/core-classes/security/update-role/snippets/update-role-1.js deleted file mode 100644 index c6ef25ca1..000000000 --- a/doc/5/core-classes/security/update-role/snippets/update-role-1.js +++ /dev/null @@ -1,24 +0,0 @@ -var roleDefinition = { - controllers: { - "read": { - actions: { - "get": true - } - } - } -}; - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .updateRole("role ID", roleDefinition, function (err, updatedRole) { - // "updatedRole" is an instance of a Role object - }); - -// Using promises (NodeJS) -kuzzle - .security - .updateRolePromise("profile ID", roleDefinition) - .then(updatedRole => { - // "updatedRole" is an instance of a Role object - }); diff --git a/doc/5/core-classes/security/update-user/index.md b/doc/5/core-classes/security/update-user/index.md deleted file mode 100644 index 87f691dbb..000000000 --- a/doc/5/core-classes/security/update-user/index.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -code: false -type: page -title: updateUser -description: Security:updateUser ---- - -# updateUser - -Performs a partial update on an existing user. - ---- - -## updateUser(id, content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `id` | string | Unique user identifier | -| `content` | JSON Object | A plain JSON object representing the user | -| `options` | string | (Optional) Optional arguments | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Filter | Type | Description | Default | -| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `queuable` | boolean | Make this request queuable or not | `true` | -| `refresh` | string | If set to `wait_for`, Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | `undefined` | - ---- - -## Return Value - -Returns the `Security` object to allow chaining. - ---- - -## Callback Response - -Returns an updated [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/update-user-1.js diff --git a/doc/5/core-classes/security/update-user/snippets/update-user-1.js b/doc/5/core-classes/security/update-user/snippets/update-user-1.js deleted file mode 100644 index 0c2acd841..000000000 --- a/doc/5/core-classes/security/update-user/snippets/update-user-1.js +++ /dev/null @@ -1,20 +0,0 @@ -var newContent = { - firstname: 'My Name Is', - lastname: 'Jonas' -}; - - -// Using callbacks (NodeJS or Web Browser) -kuzzle - .security - .updateUser("User ID", newContent, function (err, updatedUser) { - // "updatedUser" is an instance of a User object - }); - -// Using promises (NodeJS) -kuzzle - .security - .updateUserPromise("User ID", newContent) - .then(updatedUser => { - // "updatedUser" is an instance of a User object - }); diff --git a/doc/5/core-classes/security/user/index.md b/doc/5/core-classes/security/user/index.md deleted file mode 100644 index b11e78b08..000000000 --- a/doc/5/core-classes/security/user/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: user -description: Security:user ---- - -# user - -Instantiates a new [User](/sdk/js/5/core-classes/user) object. - ---- - -## user(id, content) - -| Arguments | Type | Description | -| --------- | ----------- | ---------------------- | -| `id` | string | Unique user identifier | -| `content` | JSON Object | User content | - ---- - -## Return value - -Returns the new [User](/sdk/js/5/core-classes/user) object. - -## Usage - -<<< ./snippets/user-1.js diff --git a/doc/5/core-classes/security/user/snippets/user-1.js b/doc/5/core-classes/security/user/snippets/user-1.js deleted file mode 100644 index 8b12c15c6..000000000 --- a/doc/5/core-classes/security/user/snippets/user-1.js +++ /dev/null @@ -1,13 +0,0 @@ -var userContent = { - // A "profileIds" field is required to bind a user to an existing profile - profileIds: ['some profile'], - - // The "local" authentication strategy requires a password - password: 'secretPassword', - - // You can also set custom fields to your user - firstname: 'John', - lastname: 'Doe' -}; - -var user = kuzzle.security.user('myuser', userContent); diff --git a/doc/5/core-classes/security/validate-credentials/index.md b/doc/5/core-classes/security/validate-credentials/index.md deleted file mode 100644 index 9f320c68b..000000000 --- a/doc/5/core-classes/security/validate-credentials/index.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -code: false -type: page -title: validateCredentials -description: Security:validateCredentials ---- - -# validateCredentials - -> - -Validate credentials of user with `kuid` for the specified `strategy`. Resolves to an error if the credentials are invalid. - ---- - -## validateCredentials(strategy, credentials, [options], callback) - -| Arguments | Type | Description | -| ------------- | ----------- | ------------------------------------------ | -| `strategy` | string | Strategy you want to create credentials in | -| `kuid` | JSON object | User's kuid | -| `credentials` | JSON object | The credentials | -| `options` | JSON object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a boolean value if the credentials are valid, otherwise returns an error. - -## Usage - -<<< ./snippets/validate-credentials-1.js - -> Callback response - -```json -true -``` diff --git a/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js b/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js deleted file mode 100644 index 509cb2cec..000000000 --- a/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (node.js or browser) -kuzzle.security.validateCredentials('local', 'kuid', {'username': 'foo'}, function (error, result) { - -}); - -// Using promises (node.js) -kuzzle - .security - .validateCredentialsPromise('local', 'kuid', {'username': 'foo'}) - .then(() => { - - }); diff --git a/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js b/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js deleted file mode 100644 index eeb544a8d..000000000 --- a/doc/5/core-classes/security/validate-credentials/snippets/validate-credentials-2.js +++ /dev/null @@ -1,2 +0,0 @@ -on -true diff --git a/doc/5/core-classes/user/add-profile/index.md b/doc/5/core-classes/user/add-profile/index.md deleted file mode 100644 index ff3eaf5c6..000000000 --- a/doc/5/core-classes/user/add-profile/index.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -code: false -type: page -title: addProfile -description: User:addProfile ---- - -# addProfile - -Replaces the security profile associated with the user. - -
-Updating a user will have no impact until the [`create`](/sdk/js/5/core-classes/user/create) or [`replace`](/sdk/js/5/core-classes/user/replace) method is called -
- ---- - -## addProfile(profileId) - -| Arguments | Type | Description | -| ----------- | ------ | ----------- | -| `profileId` | string | Profile ID | - ---- - -## addProfile(profile) - -| Arguments | Type | Description | -| --------- | ------- | --------------------------------------------------- | -| `profile` | Profile | An instantiated [Profile](/sdk/js/5/core-classes/profile) object | - ---- - -## Return Value - -Returns the `User` object. - -## Usage - -<<< ./snippets/add-profile-1.js diff --git a/doc/5/core-classes/user/add-profile/snippets/add-profile-1.js b/doc/5/core-classes/user/add-profile/snippets/add-profile-1.js deleted file mode 100644 index f882abcf3..000000000 --- a/doc/5/core-classes/user/add-profile/snippets/add-profile-1.js +++ /dev/null @@ -1,7 +0,0 @@ -var profile = kuzzle.security.fetchProfile('myprofile', function(error, profile) { - // Can add a profile directly with a Profile object - user.addProfile(profile); -}); - -// Or by passing an id -user.addProfile('myprofile'); diff --git a/doc/5/core-classes/user/constructor/index.md b/doc/5/core-classes/user/constructor/index.md deleted file mode 100644 index cd365054b..000000000 --- a/doc/5/core-classes/user/constructor/index.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -code: false -type: page -title: constructor -description: User:constructor -order: 1 ---- - -# Constructors - -## Instantiates a new User object, which is a representation of a Kuzzle user and is linked to a security [Profile](/sdk/js/5/core-classes/profile). - -## User(Security, id, content, [meta]) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------- | -| `Security` | Security | An instantiated Security object | -| `id` | string | Unique user identifier | -| `content` | JSON Object | User content | -| `meta` | JSON Object | User metadata | - -**Note:** this constructor won't make any call to Kuzzle. - ---- - -## Properties - -| Property name | Type | Description | get/set | -| ------------- | ----------- | ------------------------- | ------- | -| `content` | JSON object | Raw user content | get | -| `id` | string | Unique profile identifier | get | -| `meta` | JSON object | User metadata | get | - ---- - -## Return Value - -Returns the `User` object. - -## Usage - -<<< ./snippets/constructor-1.js diff --git a/doc/5/core-classes/user/constructor/snippets/constructor-1.js b/doc/5/core-classes/user/constructor/snippets/constructor-1.js deleted file mode 100644 index f0b675942..000000000 --- a/doc/5/core-classes/user/constructor/snippets/constructor-1.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - Constructors are not exposed in the JS/Node SDK. - User objects are returned by Security.user method: - */ - var userContent = { - // A "profile" field is required to bind a user to an existing profile - profileIds: ['admin'], - - // The "local" authentication strategy requires a password - password: 'secretPassword', - - // You can also set custom fields to your user - firstname: 'John', - lastname: 'Doe' - }; - -var user = kuzzle.security.user('myuser', userContent); diff --git a/doc/5/core-classes/user/create/index.md b/doc/5/core-classes/user/create/index.md deleted file mode 100644 index c519b8f60..000000000 --- a/doc/5/core-classes/user/create/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: create -description: User:create ---- - -# create - -Create the user in Kuzzle. Credentials can be created during the process by using [setCredentials](/sdk/js/5/core-classes/user/set-credentials) beforehand. - ---- - -## create([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `User` object to allow chaining. - ---- - -## Callback Response - -Returns a `User` object. - -## Usage - -<<< ./snippets/create-1.js diff --git a/doc/5/core-classes/user/create/snippets/create-1.js b/doc/5/core-classes/user/create/snippets/create-1.js deleted file mode 100644 index 474e9dfa8..000000000 --- a/doc/5/core-classes/user/create/snippets/create-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -user - .create(function(error, result) { - // result is a User object - }); - -// Using promises (NodeJS) -user - .createPromise() - .then(result => { - // result is a User object - }); diff --git a/doc/5/core-classes/user/delete/index.md b/doc/5/core-classes/user/delete/index.md deleted file mode 100644 index 56d932ef7..000000000 --- a/doc/5/core-classes/user/delete/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: delete -description: User:delete ---- - -# delete - -Deletes the user in Kuzzle. - ---- - -## delete([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns a `String` containing the id of the deleted user. - -## Usage - -<<< ./snippets/delete-1.js diff --git a/doc/5/core-classes/user/delete/snippets/delete-1.js b/doc/5/core-classes/user/delete/snippets/delete-1.js deleted file mode 100644 index bc17cc541..000000000 --- a/doc/5/core-classes/user/delete/snippets/delete-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -user - .delete(function(error, result) { - // result is the id of deleted user - }); - -// Using promises (NodeJS) -user - .deletePromise() - .then(result => { - // result is the id of deleted user - }); diff --git a/doc/5/core-classes/user/get-profileids/index.md b/doc/5/core-classes/user/get-profileids/index.md deleted file mode 100644 index 23e4e8644..000000000 --- a/doc/5/core-classes/user/get-profileids/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -code: false -type: page -title: getProfileids -description: User:getProfileids ---- - -# getProfileIds - -Returns the list of profile identifiers associated with this user. - ---- - -## Return Value - -Returns an array of strings, each a profile identifier associated with this user. - -## Usage - -<<< ./snippets/get-profileids-1.js diff --git a/doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js b/doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js deleted file mode 100644 index 187c61b47..000000000 --- a/doc/5/core-classes/user/get-profileids/snippets/get-profileids-1.js +++ /dev/null @@ -1,3 +0,0 @@ -for (profileId of user.getProfileIds()) { - -} diff --git a/doc/5/core-classes/user/get-profiles/index.md b/doc/5/core-classes/user/get-profiles/index.md deleted file mode 100644 index 750056293..000000000 --- a/doc/5/core-classes/user/get-profiles/index.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -code: false -type: page -title: getProfiles -description: User:getProfiles ---- - -# getProfiles - -Gets the security [Profile](/sdk/js/5/core-classes/profile) instances linked to the user from Kuzzle's API. - ---- - -## getProfiles([options], callback) - -| Arguments | Type | Description | -| ---------- | ----------- | ------------------------------ | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Callback Response - -Returns an array of security [Profile](/sdk/js/5/core-classes/profile) objects. - -## Usage - -<<< ./snippets/get-profiles-1.js diff --git a/doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js b/doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js deleted file mode 100644 index fa6e3679a..000000000 --- a/doc/5/core-classes/user/get-profiles/snippets/get-profiles-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -user - .getProfiles(function(error, profiles) { - // result is an array of Profile objects - }); - -// Using promises (NodeJS) -user - .getProfilesPromise() - .then(profiles => { - // profiles is an array of Profile objects - }); diff --git a/doc/5/core-classes/user/index.md b/doc/5/core-classes/user/index.md deleted file mode 100644 index f06de06f3..000000000 --- a/doc/5/core-classes/user/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -code: false -type: branch -title: User -description: User documentation ---- diff --git a/doc/5/core-classes/user/replace/index.md b/doc/5/core-classes/user/replace/index.md deleted file mode 100644 index bfbcc38f8..000000000 --- a/doc/5/core-classes/user/replace/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: replace -description: User:replace ---- - -# replace - -Replaces the user in Kuzzle. - ---- - -## replace([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `User` object to allow chaining. - ---- - -## Callback Response - -Returns a `User` object. - -## Usage - -<<< ./snippets/replace-1.js diff --git a/doc/5/core-classes/user/replace/snippets/replace-1.js b/doc/5/core-classes/user/replace/snippets/replace-1.js deleted file mode 100644 index 4093bb6c7..000000000 --- a/doc/5/core-classes/user/replace/snippets/replace-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -user - .replace(function(error, result) { - // result is a User object - }); - -// Using promises (NodeJS) -user - .replacePromise() - .then(result => { - // result is a User object - }); diff --git a/doc/5/core-classes/user/save-restricted/index.md b/doc/5/core-classes/user/save-restricted/index.md deleted file mode 100644 index d4953f7ac..000000000 --- a/doc/5/core-classes/user/save-restricted/index.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -code: false -type: page -title: saveRestricted -description: User:saveRestricted ---- - -# saveRestricted - -## Saves this user as restricted in Kuzzle. - -## saveRestricted([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `User` object to allow chaining. - ---- - -## Callback Response - -Returns a `User` object. - -## Usage - -<<< ./snippets/save-restricted-1.js diff --git a/doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js b/doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js deleted file mode 100644 index 93207cd65..000000000 --- a/doc/5/core-classes/user/save-restricted/snippets/save-restricted-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -user - .saveRestricted(function(error, result) { - // result is a User object - }); - -// Using promises (NodeJS) -user - .saveRestrictedPromise() - .then(result => { - // result is a User object - }); diff --git a/doc/5/core-classes/user/save/index.md b/doc/5/core-classes/user/save/index.md deleted file mode 100644 index 02c865bff..000000000 --- a/doc/5/core-classes/user/save/index.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -code: false -type: page -title: save -description: User:save ---- - -# save - -Creates or replaces this user in Kuzzle. - ---- - -## save([options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | ----------------------------------------- | -| `options` | JSON Object | Optional parameters | -| `callback` | function | (Optional) Callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `User` object to allow chaining. - ---- - -## Callback Response - -Returns a `User` object. - -## Usage - -<<< ./snippets/save-1.js diff --git a/doc/5/core-classes/user/save/snippets/save-1.js b/doc/5/core-classes/user/save/snippets/save-1.js deleted file mode 100644 index b70ec6709..000000000 --- a/doc/5/core-classes/user/save/snippets/save-1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Using callbacks (NodeJS or Web Browser) -user - .save(function(error, result) { - // result is a User object - }); - -// Using promises (NodeJS) -user - .savePromise() - .then((result) => { - // result is a User object - }); diff --git a/doc/5/core-classes/user/set-content/index.md b/doc/5/core-classes/user/set-content/index.md deleted file mode 100644 index 474cefb4e..000000000 --- a/doc/5/core-classes/user/set-content/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -code: false -type: page -title: setContent -description: User:setContent ---- - -# setContent - -Replaces the content of User. - -
-Updating a user will have no impact until the [`create`](/sdk/js/5/core-classes/user/create) or [`replace`](/sdk/js/5/core-classes/user/replace) method is called -
- ---- - -## setContent(data) - -| Arguments | Type | Description | -| --------- | ----------- | ------------ | -| `data` | JSON Object | User content | - ---- - -## Return Value - -Returns the `User` object. - -## Usage - -<<< ./snippets/set-content-1.js diff --git a/doc/5/core-classes/user/set-content/snippets/set-content-1.js b/doc/5/core-classes/user/set-content/snippets/set-content-1.js deleted file mode 100644 index 94d9af616..000000000 --- a/doc/5/core-classes/user/set-content/snippets/set-content-1.js +++ /dev/null @@ -1,6 +0,0 @@ -var user = kuzzle.security.fetchUser('myuser'); -var userContent = { - profileIds: ['profileId'] -}; - -user = user.setContent(userContent); diff --git a/doc/5/core-classes/user/set-credentials/index.md b/doc/5/core-classes/user/set-credentials/index.md deleted file mode 100644 index 682d40af1..000000000 --- a/doc/5/core-classes/user/set-credentials/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -code: false -type: page -title: setCredentials -description: User:setCredentials ---- - -# setCredentials - -Sets the user's credentials. - -
- Updating user credentials will have no impact until the [`create`](/sdk/js/5/core-classes/user/create) method is called.
- The credentials to send depend on the authentication plugin and the strategy you want to create credentials for. -
---- - -## setCredentials(credentials) - -| Arguments | Type | Description | -| ------------- | ------ | --------------------------------------------------------------------------------- | -| `credentials` | object | An object containing an attribute for each strategy you want to link the user to. | - ---- - -## Return Value - -Returns the `User` object. - -## Usage - -<<< ./snippets/set-credentials-1.js diff --git a/doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js b/doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js deleted file mode 100644 index 648f18a50..000000000 --- a/doc/5/core-classes/user/set-credentials/snippets/set-credentials-1.js +++ /dev/null @@ -1,5 +0,0 @@ -user.setCredentials({ - '': { - some: 'credentials' - } -}); diff --git a/doc/5/core-classes/user/set-profiles/index.md b/doc/5/core-classes/user/set-profiles/index.md deleted file mode 100644 index fad58dd12..000000000 --- a/doc/5/core-classes/user/set-profiles/index.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -code: false -type: page -title: setProfiles -description: User:setProfiles ---- - -# setProfiles - -Replaces the security profiles linked to the user. - -
-Updating a user will have no impact until the create or replace method is called -
---- - -## setProfiles(profileIds) - -| Arguments | Type | Description | -| ------------ | ---------------- | ------------------- | -| `profileIds` | array of strings | List of profile IDs | - ---- - -## setProfiles(profiles) - -| Arguments | Type | Description | -| ---------- | ------------------------ | ------------------------------------------------------------- | -| `profiles` | array of Profile objects | An array of instantiated [Profile](/sdk/js/5/core-classes/profile) objects | - ---- - -## Return Value - -Returns the `User` object. - -## Usage - -<<< ./snippets/set-profiles-1.js diff --git a/doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js b/doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js deleted file mode 100644 index 7e5610396..000000000 --- a/doc/5/core-classes/user/set-profiles/snippets/set-profiles-1.js +++ /dev/null @@ -1,7 +0,0 @@ -var profile = kuzzle.security.fetchProfile('myprofile', function(error, profile) { - // Can set the profiles directly with a Profile object - user.setProfiles([profile]); -}); - -// Or by passing their ids -user.setProfiles(['myprofile']); diff --git a/doc/5/core-classes/user/update/index.md b/doc/5/core-classes/user/update/index.md deleted file mode 100644 index b062488d8..000000000 --- a/doc/5/core-classes/user/update/index.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -code: false -type: page -title: update -description: User:update ---- - -# update - -Performs a partial content update on this object. - ---- - -## update(content, [options], [callback]) - -| Arguments | Type | Description | -| ---------- | ----------- | --------------------------------------- | -| `content` | JSON Object | User content | -| `options` | JSON Object | Optional parameters | -| `callback` | function | Optional callback handling the response | - ---- - -## Options - -| Option | Type | Description | Default | -| ---------- | ------- | --------------------------------- | ------- | -| `queuable` | boolean | Make this request queuable or not | `true` | - ---- - -## Return Value - -Returns the `User` object to allow chaining. - ---- - -## Callback Response - -Returns the updated version of this object. - -## Usage - -<<< ./snippets/update-1.js diff --git a/doc/5/core-classes/user/update/snippets/update-1.js b/doc/5/core-classes/user/update/snippets/update-1.js deleted file mode 100644 index ff26c05cd..000000000 --- a/doc/5/core-classes/user/update/snippets/update-1.js +++ /dev/null @@ -1,16 +0,0 @@ -var updateContent = { - firstname: 'My Name Is', - lastname: 'Jonas' -}; - -// Using callbacks (NodeJS or Web Browser) -user.update(updateContent, function(err, updatedUser) { - // the updatedUser variable is the updated User object -}); - -// Using promises (NodeJS) -role - .updatePromise(updateContent) - .then(updatedUser => { - // the updatedUser variable is the updated User object - }); diff --git a/doc/5/essentials/error-handling/index.md b/doc/5/essentials/error-handling/index.md deleted file mode 100644 index efbe6e24c..000000000 --- a/doc/5/essentials/error-handling/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -code: false -type: page -title: Error Handling -order: 100 ---- - -# Error Handling - -<<< ./snippets/handling-errors-1.js -All methods that accept a callback as an argument can return an error. The error can be generated directly by the SDK, or by Kuzzle and included in the response to a request. - -All errors generated by Kuzzle contain the following properties: - -- `message`: the error message -- `status`: an error code following the [HTTP standard](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) diff --git a/doc/5/essentials/error-handling/snippets/handling-errors-1.js b/doc/5/essentials/error-handling/snippets/handling-errors-1.js deleted file mode 100644 index a73b9b8e7..000000000 --- a/doc/5/essentials/error-handling/snippets/handling-errors-1.js +++ /dev/null @@ -1,19 +0,0 @@ -// Any API request method behave the same way - -// Using callbacks (NodeJS or Web Browser) -kuzzle.checkToken(token, function (err, res) { - if (err) { - console.error(err.status, ': ', err.message); - return; - } -}); - -// Using promises (NodeJS only) -kuzzle.checkTokenPromise(token) - .then(res => { - // ... - }) - .catch(err => { - console.error(err.status, ': ', err.message); - return Promise.reject(err); - }); diff --git a/doc/5/essentials/events/index.md b/doc/5/essentials/events/index.md deleted file mode 100644 index 9f90667a3..000000000 --- a/doc/5/essentials/events/index.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -code: false -type: page -title: Events -order: 200 ---- - -# Events - -The [Kuzzle instance](/sdk/js/5/core-classes/kuzzle/) periodically emits named events that provide useful updates about the state of the Kuzzle client. To subscribe to these events, use the [addListener](/sdk/js/5/core-classes/kuzzle/add-listener) function and specify the event name and the callback function that will be executed when the event is emitted. To unsubscribe to an event, use the [removeListener](/sdk/js/5/core-classes/kuzzle/remove-listener) function, specifying the name of the event to remove. - ---- - -## Emitted Events - -| Event Name | Callback arguments | Description | -| ------------------ | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | -| `connected` | _(none)_ | Triggered when the SDK has successfully connected to Kuzzle | -| `discarded` | `error` (object) | Triggered when Kuzzle rejects a request (e.g. request can't be parsed, request too large, ...) | -| `disconnected` | _(none)_ | Triggered when the current session has been unexpectedly disconnected | -| `loginAttempt` | `{ "success": , "error": "" }` | Triggered when a login attempt completes, either with a success or a failure result | -| `networkError` | `error` (object) | Triggered when the SDK has failed to connect to Kuzzle. Does not trigger offline mode. | -| `offlineQueuePop` | `query` (object) | Triggered whenever a request is removed from the offline queue. | -| `offlineQueuePush` | `{ "query": , "cb": }` | Triggered whenever a request is added to the offline queue | -| `queryError` | `error` (object), `query` (object) | Triggered whenever Kuzzle responds with an error | -| `reconnected` | _(none)_ | Triggered when the current session has reconnected to Kuzzle after a disconnection, and only if `autoReconnect` is set to `true` | -| `tokenExpired` | _(none)_ | Triggered when Kuzzle rejected a request because the authentication token expired | - -**Note:** listeners are called in the order of their insertion. diff --git a/doc/5/essentials/index.md b/doc/5/essentials/index.md deleted file mode 100644 index 20d0cd882..000000000 --- a/doc/5/essentials/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -code: false -type: branch -order: 0 -title: Essentials -description: Javascript SDK v5.x essential notions ---- diff --git a/doc/5/essentials/offline-tools/index.md b/doc/5/essentials/offline-tools/index.md deleted file mode 100644 index d43066a1e..000000000 --- a/doc/5/essentials/offline-tools/index.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -code: false -type: page -title: Offline Tools -order: 400 ---- - -# Offline Tools - -When using an unstable network connection, an application must maintain a normal behavior when it is disconnected. Our goal is to provide the right toolkit to handle such situations. - ---- - -## Handling a Network Disconnect - -There are two ways to handle a network disconnect: - -- Automatically reconnect to Kuzzle when possible, and enter _offline mode_ in the meantime. This is the default behavior. -- Stop all further communication with Kuzzle and invalidate the current instance and all its children. The application will have to manually reconnect once the network is available. To do so, simply set the `autoReconnect` option to `false` when creating the SDK instance. - -_Offline mode_ refers to the time between a `disconnected` and a `reconnected` event (see [Events](/sdk/js/5/essentials/events)). - ---- - -## Subscriptions - -A subscription opens a permanent pipe between the client and Kuzzle. Whenever a real-time message or a modified document matches a subscription filter, a notification is sent by Kuzzle to the client (for instance, see the [Collection.subscribe](/sdk/js/5/core-classes/collection/subscribe) method). - -While in offline mode, the Kuzzle SDK client maintains all subscriptions configurations and, by default, when Kuzzle SDK client reconnects, all subscriptions are renewed. This behavior can be changed by setting the `autoResubscribe` to `false`, in which case, each subscription will have to be renewed manually using the `Room.renew` method. - ---- - -## API Requests - -While in offline mode, API requests can be queued, and then executed once the network connection has been reestablished. -By default, there is no request queuing. - -- Queue all requests automatically when going offline by setting the `autoQueue` option to `true` (see [Kuzzle SDK constructor](/sdk/js/5/core-classes/kuzzle)) -- Start and stop queuing manually, by using the [startQueuing](/sdk/js/5/core-classes/kuzzle/start-queuing) and [stopQueuing](/sdk/js/5/core-classes/kuzzle/stop-queuing) methods - -The queue itself can be configured using the `queueTTL` and `queueMaxSize` options. - ---- - -## Filtering Requests to be Queued - -By default, when queuing is first activated, all requests are queued. - -However, you can choose to omit certain request by using the [`queueFilter`](/sdk/js/5/core-classes/kuzzle#properties) property. This property can be set to a function that accepts the request as an input value and returns a boolean result which indicates whether or not the request should be queud. - -Additionally, almost all request methods accept a `queuable` option, which when set to `false`, will cause the request to be discarded if the Kuzzle SDK is disconnected. This option overrides the `queueFilter` property. - ---- - -## Handling Network Reconnect - -
-Setting autoReplay to true when using user authentication should generally be avoided.
-When leaving offline-mode, the JWT validity is verified. If it has expired, the token will be removed and a tokenExpired event will be triggered.
-If autoReplay is set, then all pending requests will be automatically played as an anonymous user. -
- -Once a `reconnected` event is fired, you may replay the content of the queue with the `playQueue` method. Or you can let the Kuzzle SDK replay it automatically upon reconnection by setting the `autoReplay` option to `true`. - -Requests are sent to Kuzzle with a `replayInterval` delay between each call. - -Any request made while the client is processing the queue will be delayed until the queue is empty. This ensures that all requests are played in the right order. - ---- - -## Taking Control of the Offline Queue - -You can be notified about what's going on in the offline queue, by using the [`offlineQueuePush`](/sdk/js/5/essentials/events) and the [`offlineQueuePop`](/sdk/js/5/essentials/events) events. - -The `offlineQueuePush` event is fired whenever a request is queued. It will emit an object containing a `query` property, describing the queued request, and an optional `cb` property containing the corresponding callback, if any. - -The `offlineQueuePop` event is fired whenever a request has been removed from the queue, either because the queue limits have been reached, or because the request has been replayed. It provides the removed request to its listeners. - -The `offlineQueueLoader` property of the Kuzzle SDK instance loads requests to the queue, **before any previously queued request**. It is invoked every time the Kuzzle SDK starts dequeuing requests. -This property must be set with a function that returns an array of objects with the following accessible properties: - -- a `query` property, containing the request to be replayed -- an optional `cb` property pointing to the callback to invoke after the completion of the request - -Finally, if the provided methods don't give you enough control over the offline queue, you can access and edit the queue directly using the `offlineQueue` property. - ---- - -## Automatic Offline-Mode - -You can set the `offlineMode` option to `auto` when instantiating the [Kuzzle SDK instance](/sdk/js/5/core-classes/kuzzle). This sets the offline mode configuration to the following presets: - -- `autoReconnect` = `true` -- `autoQueue` = `true` -- `autoReplay` = `true` -- `autoResubscribe` = `true` diff --git a/doc/5/essentials/realtime-notifications/index.md b/doc/5/essentials/realtime-notifications/index.md deleted file mode 100644 index 88c80c90f..000000000 --- a/doc/5/essentials/realtime-notifications/index.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -code: false -type: page -title: Realtime Notifications -order: 300 ---- - -# Realtime Notifications - -With Kuzzle, you don't [subscribe](/sdk/js/5/core-classes/collection/subscribe) to a room or a topic but, instead, you subscribe to documents. -This means, that when you want to subscribe you must provide a set of filter definitions, using [Koncorde](/core/1/koncorde), that tell Kuzzle what documents should trigger a notification. Then, any time a document matches the defined filters, Kuzzle will send a notification to the subscriber. - -You can also provide an empty set of filters, which will tell Kuzzle that you want to listen to any change occurring on a collection, emulating the behavior of a traditional topic. - -To subscribe, you must provide a callback that will be called each time a new notification is received. - -Once you have subscribed, depending on the subscription configuration you provided, you may receive a notification when: - -- a pub/sub message matches your criteria (real-time) -- a matching document is about to be created or deleted in real-time (deactivated by default) -- a matching document is created, updated or deleted (once the change is effective in the database) -- a user enters or leaves the room (deactivated by default) - -You may subscribe multiple times to the same room, with identical or different subscription parameters, and with different callbacks. This allows you to dispatch notifications to dedicated processes of your application, instead of maintaining a single all-purpose notification consumer (but you can do that too I you want). - ---- - -<<< ./snippets/notifications-1.js - -<<< ./snippets/notifications-2.js - -<<< ./snippets/notifications-3.js - -## Document Notification - -| Notification field | Type | Description | Possible values | -| ------------------ | ------------------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------- | -| `document` | [Document](/sdk/js/5/core-classes/document/) | Content of the document or real-time message that generated the notification | | -| `scope` | string | Indicates if the document enters or exits the subscription scope | `in`, `out` | -| `state` | string | Shows if the document is about to be changed, or if the change is done | `pending`, `done` | -| `type` | string | Notification type | `document` | - -#### Example - -```json -{ - "status": 200, - "requestId": "bc41ced6-38fc-42b9-8fd5-22ae0774aac2", - "controller": "name of the controller that generated the notification", - "action": "name of the action that generated the notification", - "collection": "collection name", - "index": "index name", - "volatile": {}, - "state": "done", - "scope": "in", - "type": "document", - "document": { - "content": { - "content": "document content example" - }, - "id": "" - } -} -``` - ---- - -## User notification - -| Notification field | Type | Description | Possible values | -| ------------------ | ----------- | -------------------------------------------------------------------------- | --------------- | -| `user` | string | Indicates if the user enters or leaves the subscribed room | `in`, `out` | -| `volatile` | JSON object | If provided during subscription, contains application specific information | | -| `result.count` | integer | Updated number of users subscribing to this room | | -| `type` | string | Notification type | `user` | - -#### Example - -```json -{ - "status": 200, - "roomId": "ID of the room concerned by this notification", - "requestId": "5897cd2f-a8a2-40b2-aa43-b31898172008", - "controller": "subscribe", - "user": "in", - "protocol": "protocol used by the notifying user", - "timestamp": 1453193069592, - "volatile": { - "optional": "user information" - }, - "type": "user", - "result": { - "count": 42 - } -} -``` diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-1.js b/doc/5/essentials/realtime-notifications/snippets/notifications-1.js deleted file mode 100644 index 2147d5612..000000000 --- a/doc/5/essentials/realtime-notifications/snippets/notifications-1.js +++ /dev/null @@ -1,21 +0,0 @@ -var2 - collection = kuzzle.collection('foo', 'bar'), - filters = {equals: {foo: 'bar'}}, - room; - -/* -* Use case 1 : Simple subscription to document changes with default scope/state options -*/ -room = collection.subscribe(filters, function(data) { - if (data.scope === 'in') { - console.log('New document within the scope: ', data.document); - } else if (data.scope === 'out') { - console.log('Document moved from the scope: ', data.document); - } -}).onDone(function(err, res) { - if (err) { - console.error('Error while subscribing to the room: ', err); - } else { - console.log('Subscription ready'); - } -}); diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-2.js b/doc/5/essentials/realtime-notifications/snippets/notifications-2.js deleted file mode 100644 index 8e24cefb7..000000000 --- a/doc/5/essentials/realtime-notifications/snippets/notifications-2.js +++ /dev/null @@ -1,17 +0,0 @@ -var - collection = kuzzle.collection('foo', 'bar'), - filters = {equals: {foo: 'bar'}}, - room; - -/* -* Use case 2 : Subscribe only to documents leaving the scope -*/ -room = collection.subscribe(filters, {scope: 'out'}, function(data) { - console.log('Document moved from the scope: ', data.document); -}).onDone(function(err, res) { - if (err) { - console.error('Error while subscribing to the room: ', err); - } else { - console.log('Subscription ready'); - } -}); diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-3.js b/doc/5/essentials/realtime-notifications/snippets/notifications-3.js deleted file mode 100644 index 79d582071..000000000 --- a/doc/5/essentials/realtime-notifications/snippets/notifications-3.js +++ /dev/null @@ -1,46 +0,0 @@ -var - collection = kuzzle.collection('foo', 'bar'), - filters = {equals: {foo: 'bar'}}, - room; - -/* -* Use case 3 : Create a Room with custom options and add some listeners to it -*/ - -// create the room: -room = collection.room( - filters, - {state: 'all', scope: 'in', users: 'all', subscribeToSelf: false} -); - -// listen to notifications about new documents: -room.on('document', function(data) { - if (data.state === 'done') { - console.log('New document within the scope: ', data.document); - } -}); - -// listen to notifications about other users subscribing to the same room: -room.on('user', function(data) { - if (data.user === 'in') { - console.log('A user has joigned the room', data.volatile); - console.log('Number of listening users: ', data.result.count); - } -}); - -// listen to notifications about other users leaving the same room: -room.on('user', function(data) { - if (data.user == 'out') { - console.log('A user has leaved the room', data.volatile); - console.log('Number of listening users: ', data.result.count); - } -}); - -// subscribe to the room: -room.subscribe(function(err, res) { - if (err) { - console.error('Error while subscribing to the room: ', err); - } else { - console.log('Subscription ready'); - } -}); diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-4.js b/doc/5/essentials/realtime-notifications/snippets/notifications-4.js deleted file mode 100644 index 57b2ac829..000000000 --- a/doc/5/essentials/realtime-notifications/snippets/notifications-4.js +++ /dev/null @@ -1,19 +0,0 @@ -on -{ - "status": 200, - "requestId": "bc41ced6-38fc-42b9-8fd5-22ae0774aac2", - "controller": "name of the controller that generated the notification", - "action": "name of the action that generated the notification", - "collection": "collection name", - "index": "index name", - "volatile": {}, - "state": "done", - "scope": "in", - "type": "document", - "document": { - "content": { - "content": "document content example" - }, - "id": "" - } -} diff --git a/doc/5/essentials/realtime-notifications/snippets/notifications-5.js b/doc/5/essentials/realtime-notifications/snippets/notifications-5.js deleted file mode 100644 index 9724b50e9..000000000 --- a/doc/5/essentials/realtime-notifications/snippets/notifications-5.js +++ /dev/null @@ -1,17 +0,0 @@ -on -{ - "status": 200, - "roomId": "ID of the room concerned by this notification", - "requestId": "5897cd2f-a8a2-40b2-aa43-b31898172008", - "controller": "subscribe", - "user": "in", - "protocol": "protocol used by the notifying user", - "timestamp": 1453193069592, - "volatile": { - "optional": "user information" - }, - "type": "user", - "result": { - "count": 42 - } -} diff --git a/doc/5/index.md b/doc/5/index.md deleted file mode 100644 index 211b9b7be..000000000 --- a/doc/5/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -code: false -type: root -order: 10 -title: Javascript SDK v5.x -description: Javascript SDK v5.x ---- From 2c052ff3efe6a6ee0ade5d0ba95741ef7c5724c6 Mon Sep 17 00:00:00 2001 From: Berthier Date: Wed, 26 Jun 2019 14:10:26 +0200 Subject: [PATCH 12/26] add getting-started folder --- doc/6/getting-started/index.md | 7 + doc/6/getting-started/node-js/index.md | 157 ++++++++++++ .../node-js/snippets/create.js | 39 +++ .../node-js/snippets/create.test.yml | 11 + .../getting-started/node-js/snippets/init.js | 37 +++ .../node-js/snippets/init.test.yml | 9 + .../node-js/snippets/load-sdk.js | 9 + .../node-js/snippets/load-sdk.test.yml | 9 + .../node-js/snippets/prepare-db.js | 20 ++ .../node-js/snippets/prepare-db.test.yml | 9 + .../node-js/snippets/subscribe.js | 51 ++++ .../node-js/snippets/subscribe.test.yml | 11 + doc/6/getting-started/raw-web/index.md | 168 +++++++++++++ .../raw-web/snippets/create.html | 31 +++ .../raw-web/snippets/create.test.yml | 12 + .../raw-web/snippets/load-sdk.html | 14 ++ .../raw-web/snippets/load-sdk.test.yml | 10 + .../raw-web/snippets/prepare-db.html | 29 +++ .../raw-web/snippets/prepare-db.test.yml | 10 + .../raw-web/snippets/subscribe.html | 32 +++ .../raw-web/snippets/subscribe.test.yml | 12 + doc/6/getting-started/webpack/index.md | 223 ++++++++++++++++++ .../webpack/snippets/create.js | 33 +++ .../webpack/snippets/create.test.yml | 13 + .../webpack/snippets/init-kuzzle.js | 30 +++ .../webpack/snippets/init-kuzzle.test.yml | 10 + .../webpack/snippets/subscribe.js | 49 ++++ .../webpack/snippets/subscribe.test.yml | 14 ++ 28 files changed, 1059 insertions(+) create mode 100644 doc/6/getting-started/index.md create mode 100644 doc/6/getting-started/node-js/index.md create mode 100644 doc/6/getting-started/node-js/snippets/create.js create mode 100644 doc/6/getting-started/node-js/snippets/create.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/init.js create mode 100644 doc/6/getting-started/node-js/snippets/init.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/load-sdk.js create mode 100644 doc/6/getting-started/node-js/snippets/load-sdk.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/prepare-db.js create mode 100644 doc/6/getting-started/node-js/snippets/prepare-db.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/subscribe.js create mode 100644 doc/6/getting-started/node-js/snippets/subscribe.test.yml create mode 100644 doc/6/getting-started/raw-web/index.md create mode 100644 doc/6/getting-started/raw-web/snippets/create.html create mode 100644 doc/6/getting-started/raw-web/snippets/create.test.yml create mode 100644 doc/6/getting-started/raw-web/snippets/load-sdk.html create mode 100644 doc/6/getting-started/raw-web/snippets/load-sdk.test.yml create mode 100644 doc/6/getting-started/raw-web/snippets/prepare-db.html create mode 100644 doc/6/getting-started/raw-web/snippets/prepare-db.test.yml create mode 100644 doc/6/getting-started/raw-web/snippets/subscribe.html create mode 100644 doc/6/getting-started/raw-web/snippets/subscribe.test.yml create mode 100644 doc/6/getting-started/webpack/index.md create mode 100644 doc/6/getting-started/webpack/snippets/create.js create mode 100644 doc/6/getting-started/webpack/snippets/create.test.yml create mode 100644 doc/6/getting-started/webpack/snippets/init-kuzzle.js create mode 100644 doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml create mode 100644 doc/6/getting-started/webpack/snippets/subscribe.js create mode 100644 doc/6/getting-started/webpack/snippets/subscribe.test.yml diff --git a/doc/6/getting-started/index.md b/doc/6/getting-started/index.md new file mode 100644 index 000000000..7ea7b11d6 --- /dev/null +++ b/doc/6/getting-started/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +title: Getting Started +description: Get started with the Javascript SDK +order: 0 +--- diff --git a/doc/6/getting-started/node-js/index.md b/doc/6/getting-started/node-js/index.md new file mode 100644 index 000000000..89a2fdc50 --- /dev/null +++ b/doc/6/getting-started/node-js/index.md @@ -0,0 +1,157 @@ +--- +code: false +type: page +title: Node.js +description: Getting started with Kuzzle and Node.js +order: 0 +--- + +# Getting Started with Kuzzle and Node.js + +This tutorial explains you how to use **Kuzzle** with **Node.js** and the **Javascript SDK**. +It will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** about document creations. + +You are going to write an application that **stores** documents in Kuzzle Server and subscribe to **real time notifications** for each created document. + +To follow this tutorial, you must have a Kuzzle Server up and running. Follow these instructions if this is not already the case: [Running Kuzzle](/core/1/guides/getting-started/running-kuzzle/). + + +:::info +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! +::: + +## Explore the SDK + +It's time to get started with the [Kuzzle Javascript SDK](/sdk/js/6). This section, explains you how to store a document and subscribe to notifications in Kuzzle using the Javascript SDK. + +Before proceeding, please make sure your system has **Node.js** version 8 or higher ([download page](https://nodejs.org/en/download/)) installed. + +## Prepare your environment + +Create your playground directory and install the Javascript SDK from the command line using npm: + +```sh +mkdir "kuzzle-playground" +cd "kuzzle-playground" +npm install kuzzle-sdk +``` + +:::info +If you are performing a clean install you might get some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +::: + +Then, create an `init.js` file and start by adding the code below. +This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. + +<<< ./snippets/load-sdk.js + +:::info +Replace 'kuzzle' which is the Kuzzle server hostname with 'localhost' or with the host name where your Kuzzle server is running. +::: + +Next, add a listener to be notified in case of a connection error: + +```js +kuzzle.on('networkError', error => { + console.error('Network Error: ', error); +}); +``` + +Then, connect the client to your Kuzzle server with the `connect()` method, afterwards you have to add the code that will access Kuzzle to create a new index 'nyc-open-data' and a new collection 'yellow-taxi' that you will use to store data later on. + +<<< ./snippets/prepare-db.js + +Your `init.js` file should now look like this: + +<<< ./snippets/init.js + +This code does the following: + +- loads the `Kuzzle SDK` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket +- creates the `nyc-open-data` index +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created or if an error occurs + +Run the code with Node.js: + +```bash +node init.js +``` + +The console should output the following message: + +```bash +nyc-open-data/yellow-taxi ready! +``` + +:::success +Congratulations! You are now ready to say Hello to the World! +::: + +## Create your first "Hello World" document + +Create a `create.js` file with the following code: + +<<< ./snippets/create.js + +This code does the following: + +- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions fails +- disconnects from Kuzzle after the document is created or if an error occurs + +Run the code with Node.js: + +```bash +node create.js +``` + +:::success +You have now successfully stored your first document into Kuzzle. You can now open an [Admin Console](http://console.kuzzle.io) to browse your collection and confirm that your document was saved. +::: + + +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the [realtime notifications](/sdk/js/6/essentials/realtime-notifications/) documentation). + +Let's get started. Create a `subscribe.js` file with the following code: + +<<< ./snippets/subscribe.js + +Run the code with Node.js: + +```bash +node subscribe.js +``` + +The `subscribe.js` program is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. + +Now in another terminal, launch the `create.js` file from the previous section. + +```bash +node create.js +``` + +This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages) sent to the `subscribe.js` program. +Check the `subscribe.js` terminal: a new message is printed everytime a document is created using the `create.js` code. + +```bash +New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. +``` + +:::success +Congratulations! You have just set up your first pub/sub communication! +::: + +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- discover what this SDK has to offer by browsing other sections of this documentation +- learn how to use [Koncorde](/core/1/koncorde) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to perform a [basic authentication](/sdk/js/6/controllers/auth/login) +- follow our guide to learn how to [manage users, and how to set up fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/node-js/snippets/create.js b/doc/6/getting-started/node-js/snippets/create.js new file mode 100644 index 000000000..abd761b20 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/create.js @@ -0,0 +1,39 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates a document + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); + console.log('New document successfully created!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/create.test.yml b/doc/6/getting-started/node-js/snippets/create.test.yml new file mode 100644 index 000000000..910484f25 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/create.test.yml @@ -0,0 +1,11 @@ +name: gettingstarted#nodejscreate +description: Creates a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: empty +expected: New document successfully created! +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/init.js b/doc/6/getting-started/node-js/snippets/init.js new file mode 100644 index 000000000..fd0a31384 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/init.js @@ -0,0 +1,37 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates an index + await kuzzle.index.create('nyc-open-data'); + + // Creates a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/init.test.yml b/doc/6/getting-started/node-js/snippets/init.test.yml new file mode 100644 index 000000000..0e76545bc --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/init.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejsinit +description: Creates an index and a collection +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: empty +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/load-sdk.js b/doc/6/getting-started/node-js/snippets/load-sdk.js new file mode 100644 index 000000000..ae17a9b0e --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/load-sdk.js @@ -0,0 +1,9 @@ +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); diff --git a/doc/6/getting-started/node-js/snippets/load-sdk.test.yml b/doc/6/getting-started/node-js/snippets/load-sdk.test.yml new file mode 100644 index 000000000..0d32da204 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/load-sdk.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejsload +description: Load SDK +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/prepare-db.js b/doc/6/getting-started/node-js/snippets/prepare-db.js new file mode 100644 index 000000000..2fb9b8410 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/prepare-db.js @@ -0,0 +1,20 @@ +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates an index + await kuzzle.index.create('nyc-open-data'); + + // Creates a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/prepare-db.test.yml b/doc/6/getting-started/node-js/snippets/prepare-db.test.yml new file mode 100644 index 000000000..e51b6f7ce --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/prepare-db.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejspreparedb +description: Prepare database +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: blank +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/subscribe.js b/doc/6/getting-started/node-js/snippets/subscribe.js new file mode 100644 index 000000000..f85d66357 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/subscribe.js @@ -0,0 +1,51 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Defines a filter + const filter = { + equals: { license: 'B' } + }; + + // Defines a callback invoked each time a notification is received + const callback = (notification) => { + + if (notification.type === 'document' && notification.action === 'create') { + const { + _source: driver, + _id: driverId + } = notification.result; + + console.log(`New driver ${driver.name} with id ${driverId} has B license.`); + kuzzle.disconnect(); + } + }; + + // Subscribes to document notifications using the above filter + await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filter, callback); + + console.log('Successfully subscribed to document notifications!'); + } catch (error) { + console.error(error.message); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/subscribe.test.yml b/doc/6/getting-started/node-js/snippets/subscribe.test.yml new file mode 100644 index 000000000..5e6720558 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/subscribe.test.yml @@ -0,0 +1,11 @@ +name: gettingstarted#nodejssubscribe +description: Subscribes to document notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: empty-realtime +expected: Successfully subscribed to document notifications! +sdk: js +version: 6 diff --git a/doc/6/getting-started/raw-web/index.md b/doc/6/getting-started/raw-web/index.md new file mode 100644 index 000000000..238fdade3 --- /dev/null +++ b/doc/6/getting-started/raw-web/index.md @@ -0,0 +1,168 @@ +--- +code: false +type: page +title: Browser (Vanilla) +description: Getting started with Kuzzle in the browser +order: 100 +--- + +# Getting Started with Kuzzle in the browser + +This tutorial explains how to use **Kuzzle** with the **Javascript SDK** in a **browser**. + +To follow this tutorial, you must have a Kuzzle Server up and running (you'll need to know the hostname of the machine running it). If this is not already the case, take a look at [how to run Kuzzle](/core/1/guides/getting-started/running-kuzzle/). + +Before proceeding, make sure your system has **Node.js** version 8 or higher ([download page](https://nodejs.org/en/download/)) installed. + +In this tutorial, you'll learn how to **store** a document and **subscribe** to notifications in Kuzzle using the Javascript SDK. + +:::info +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! +::: + +## Prepare your environment + +Create your playground directory: + +```sh +mkdir "kuzzle-playground" +cd "kuzzle-playground" +``` + +:::info +If you are performing a clean install you might get some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +::: + +Then, create an `index.html` file with the following structure: + +```html + + + + + + Kuzzle SDK Playground + + + + + + + + +``` + +:::info +If you are using Internet Explorer (not Edge), you are responsible of installing a Promise polyfill, which enables IE to support +Javascript [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +Our advice is to use [Bluebird](http://bluebirdjs.com/docs/getting-started.html), as shown in the code example above (refer to the commented lines in the `head` tag). +::: + +Then, add the code below in the `body` tag. +This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. If an error occurs, it is displayed +in the console. Once the connection is established, a success message is displayed in the console. + +<<< ./snippets/load-sdk.html + +:::info +Replace `kuzzle` with localhost or with the host name where your Kuzzle server is running. +::: + +Now you have to add the code that will access Kuzzle to create a new index `nyc-open-data` and a new collection `yellow-taxi` +that you will use to store data later on. Make sure the code inside your `body` tag looks like the following: + +<<< ./snippets/prepare-db.html + +Now, let's take a look at what your script is doing: + +- creates an instance of the SDK, +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, +- creates the `nyc-open-data` index, +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created, +- displays an error whenever something goes wrong. + +Run this code by opening the `index.html` file in your favorite browser. +The console should output the following message: + +``` +Successfully connected to Kuzzle +nyc-open-data/yellow-taxi ready! +``` + +:::success +Congratulations! You are now ready to say Hello to the World! +::: + +:::info +If you reload the page, you should see an error in the console. This is OK, since Kuzzle is just refusing to create +the `nyc-open-data` index as it already exists. +::: + +## Create your first "Hello World" document + +Create a `create.html` file with the same structure as `index.html` (see above). +And, right like before, add some code to the `body` tag: + +<<< ./snippets/create.html + +This code does the following: + +- creates an instance of the SDK, +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, +- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions fails +- disconnects from Kuzzle after the document is created or if an error occurs + +Run this code by opening the `create.html` file in your favorite browser. +The console should output the following message: + +``` +Successfully connected to Kuzzle +New document successfully created! +``` + +:::success +You have now successfully stored your first document into Kuzzle. Check our [Admin Console Guide](/core/1/guides/essentials/admin-console/) to see how to browse your collection and confirm that your document was saved. +::: + + +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the [realtime notifications](/sdk/js/6/essentials/realtime-notifications/) documentation). + +Let's get started. Create a `subscribe.html` file (same structure as above) with the following code in the `body` tag: + +<<< ./snippets/subscribe.html + +Run this code by opening the `subscribe.html` file in a new tab, leaving the previous one (showing `create.html`) open. +The console should output the following message: + +``` +Successfully connected to Kuzzle +Successfully subscribed to document notifications! +``` + +The code in the `subscribe.html` page is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. + +Now go back to the other tab and reload `create.html`. + +This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages) sent to the `subscribe.html` tab. Check the `subscribe.html` tab: a new message is printed everytime a document is created using the `create.html` code. + +``` +New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. +``` + +:::success +Congratulations! You have just set up your first pub/sub communication! +::: + +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- discover what this SDK has to offer by browsing other sections of this documentation +- learn how to use [Koncorde](/core/1/koncorde) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to perform a [basic authentication](/sdk/js/6/controllers/auth/login) +- follow our guide to learn how to [manage users, and how to set up fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/raw-web/snippets/create.html b/doc/6/getting-started/raw-web/snippets/create.html new file mode 100644 index 000000000..70aee4f09 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/create.html @@ -0,0 +1,31 @@ + diff --git a/doc/6/getting-started/raw-web/snippets/create.test.yml b/doc/6/getting-started/raw-web/snippets/create.test.yml new file mode 100644 index 000000000..557868de8 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/create.test.yml @@ -0,0 +1,12 @@ +name: gettingstarted#browservanillacreate +description: Create a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: New document successfully created +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/raw-web/snippets/load-sdk.html b/doc/6/getting-started/raw-web/snippets/load-sdk.html new file mode 100644 index 000000000..10d2477d1 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/load-sdk.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/doc/6/getting-started/raw-web/snippets/load-sdk.test.yml b/doc/6/getting-started/raw-web/snippets/load-sdk.test.yml new file mode 100644 index 000000000..c17ef17d8 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/load-sdk.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#browservanillaconnect +description: Connect to Kuzzle +hooks: + before: + after: +template: default +expected: Successfully connected to Kuzzle +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/raw-web/snippets/prepare-db.html b/doc/6/getting-started/raw-web/snippets/prepare-db.html new file mode 100644 index 000000000..c392a86b4 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/prepare-db.html @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/doc/6/getting-started/raw-web/snippets/prepare-db.test.yml b/doc/6/getting-started/raw-web/snippets/prepare-db.test.yml new file mode 100644 index 000000000..3ac1c5a75 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/prepare-db.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#browservanillaprepare +description: Prepare the database +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: default +expected: nyc-open-data/yellow-taxi ready +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/raw-web/snippets/subscribe.html b/doc/6/getting-started/raw-web/snippets/subscribe.html new file mode 100644 index 000000000..ec6c858ab --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/subscribe.html @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/doc/6/getting-started/raw-web/snippets/subscribe.test.yml b/doc/6/getting-started/raw-web/snippets/subscribe.test.yml new file mode 100644 index 000000000..2fad572cd --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/subscribe.test.yml @@ -0,0 +1,12 @@ +name: gettingstarted#browservanillasubscribe +description: Subscribe to notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Successfully subscribed to document notifications +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/webpack/index.md b/doc/6/getting-started/webpack/index.md new file mode 100644 index 000000000..c8d1f622c --- /dev/null +++ b/doc/6/getting-started/webpack/index.md @@ -0,0 +1,223 @@ +--- +type: page +code: false +title: Webpack +description: Getting started with Kuzzle and Webpack +order: 200 +--- + +# Getting Started with Kuzzle and Webpack + +In this tutorial you will learn how to install, run and use **Kuzzle** with the **Javascript SDK** in the browser using **Webpack**. +We will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** for each new document created. + +:::info +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! +::: + +## Running Kuzzle + +Before going through this tutorial, you should have a Kuzzle server running. Please refer to the [Running Kuzzle Tutorial](/core/1/guides/getting-started/running-kuzzle/) if you don't have one yet. + +## Fun with the SDK + +It's time to play with the [Kuzzle Javscript SDK](/sdk/js/6). In this section, we will store a document and subscribe to notifications in Kuzzle using the Javascript SDK in your browser. + +Before proceeding, please make sure your system has **Node.js** version 8 or higher ([download page](https://nodejs.org/en/download/)) installed. + +## Including the Kuzzle SDK in a Webpack project + +:::info +This section explains how to use the Kuzzle SDK within an existing Webpack project. +If you don't have your project up and running yet and want to learn how to leverage Webpack to build it, please refer to +the [official Webpack Getting Started page](https://webpack.js.org/guides/getting-started/). +::: + +In your terminal, go to the root of your front-end project using Webpack and type + +```bash +npm install kuzzle-sdk +``` + +:::info +If you are performing a clean install you might see some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +::: + +Then, create a `init-kuzzle.js` file and start by adding the code below. This will load the Kuzzle Javascript SDK: + +```js +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; +``` + +Next, we instantiate a client that will connect to Kuzzle via WebSocket. If Kuzzle is not running on localhost, replace it with the corresponding server name or IP address. + +```js +const kuzzle = new Kuzzle(new WebSocket('localhost')); +``` + +Next we add a listener to be notified in case of a connection error: + +```js +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); +``` + +Then we have to connect our web app to the Kuzzle server with the `connect()` method. + +```js +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Some more things will go here... + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; +``` + +Finally, we will create a new index `nyc-open-data` and a new collection +`yellow-taxi` that we will use to store data later on. + +```js +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create an index + await kuzzle.index.create('nyc-open-data'); + // Create a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; +``` + +Your `kuzzle-init.js` file should now look like this: + +<<< ./snippets/init-kuzzle.js + +This code does the following: + +- loads the `kuzzle-sdk` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `localhost` with the `WebSocket` protocol +- creates the `nyc-open-data` index +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created or if an error occurs + +Now, to have your script up and running, require it somewhere in your application +(e.g. your main entry point) and launch it. + +```js +require('../path/to/init-kuzzle.js'); +``` + +Your console should output the following message: + +``` +nyc-open-data/yellow-taxi ready! +``` + +:::success +Congratulations! You are now ready to say Hello to the World! +::: + +## Create your first document + +Create a `create.js` file with following code: + +<<< ./snippets/create.js + +This code does the following: + +- creates a new document in `nyc-open-data` within the `yellow-taxi` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions failed +- disconnects from Kuzzle after the document is created or if an error occurs + +To activate this code, create a button somewhere in your page like the following + +```html + +``` + +Then, associate it to the `create` function by adding this code to your application + +```js +const create = require('../path/to/create.js'); + +// This is the most "vanilla" way to call a function in reaction to a click, +// if you're using a front-end framework like Vuejs, React or jQuery, feel free +// to follow any convenience method it provides for this purpose. +document.querySelector('#create-document-btn').addListener('click', event => { + create(); +}); +``` + +Now, click the button and check your console for a message like the following: + +```bash +New document successfully created! +``` + +:::success +You have now successfully stored your first document into Kuzzle. You can now open an [Admin Console](http://console.kuzzle.io) to browse your collection and confirm that your document was saved. +::: + +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the [realtime notifications](/sdk/js/6/essentials/realtime-notifications/) documentation). + +Let's get started. Create a `subscribe.js` file with following code: + +<<< ./snippets/subscribe.js + +This code does the following: + +- loads the `Kuzzle SDK` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `localhost` with the `websocket` protocol +- defines a filter for the subscription to be done later (drivers with "B" license) +- defines a callback that will be called whenever a notification is received from Kuzzle (print driver name to console) +- subscribes for notifications on the `yellow-taxi` collection + +You can execute this code in the same page as before or in another page of your app. Whatever option you choose, to +execute the code, you just need to require it in your page + +```js +require('../path/to/subscribe.js'); +``` + +From now on, whenever you click the button we created before, Kuzzle will send a notification to the page containing +the subscription to the `yellow-taxi` collection. In the console corresponding to this page, you should see the following message: + +```bash +New driver Sirkis with id has B license. +``` + +In place of `` you'll see the ID that Kuzzle automatically generated for the document. + +:::success +Congratulations! You have just choreographed your first pub/sub pattern! +::: + +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- take a look at the [SDK Reference](/sdk/js/6) +- learn how to use [Koncorde](/core/1/koncorde) to create incredibly fine-grained and blazing-fast subscriptions +- follow our guide to learn how to implement [basic authentication](/core/1/guides/essentials/user-authentication/#local-strategy) +- follow our guide to learn how to implement [manage users and setup fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/webpack/snippets/create.js b/doc/6/getting-started/webpack/snippets/create.js new file mode 100644 index 000000000..fe66ca6b5 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/create.js @@ -0,0 +1,33 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const doIt = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create your document + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); + console.log('New document successfully created!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +export default doIt; diff --git a/doc/6/getting-started/webpack/snippets/create.test.yml b/doc/6/getting-started/webpack/snippets/create.test.yml new file mode 100644 index 000000000..fb4561210 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/create.test.yml @@ -0,0 +1,13 @@ +name: gettingstarted#webpackcreate +description: Creates a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: doIt +expected: New document successfully created! + +runner: webpack +sdk: js +version: 6 diff --git a/doc/6/getting-started/webpack/snippets/init-kuzzle.js b/doc/6/getting-started/webpack/snippets/init-kuzzle.js new file mode 100644 index 000000000..49068c155 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/init-kuzzle.js @@ -0,0 +1,30 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create an index + await kuzzle.index.create('nyc-open-data'); + + // Create a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml b/doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml new file mode 100644 index 000000000..cd2ff4589 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#webpackinitkuzzle +description: Creates an index and a collection +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: empty +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 +runner: webpack diff --git a/doc/6/getting-started/webpack/snippets/subscribe.js b/doc/6/getting-started/webpack/snippets/subscribe.js new file mode 100644 index 000000000..892c99bcb --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/subscribe.js @@ -0,0 +1,49 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const doIt = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Define a filter + const filter = { + equals: { license: 'B' } + }; + + // Define a callback + const callback = notification => { + if ( + notification.type === 'document' && + notification.action === 'create' + ) { + const driver = notification.result._source; + const driverId = notification.result._id; + console.log( + `New driver ${driver.name} with id ${driverId} has B license.` + ); + } + }; + + // Subscribes to document notifications with our filter + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filter, + callback + ); + console.log('Successfully subscribed to document notifications!'); + } catch (error) { + console.error(error.message); + } +}; + +doIt(); diff --git a/doc/6/getting-started/webpack/snippets/subscribe.test.yml b/doc/6/getting-started/webpack/snippets/subscribe.test.yml new file mode 100644 index 000000000..f62f51a44 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/subscribe.test.yml @@ -0,0 +1,14 @@ +name: gettingstarted#webpacksubscribe +description: Subscribes to document notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: createDocumentAfterSnippet +expected: + - Successfully subscribed to document notifications! + - New driver Sirkis with id +sdk: js +version: 6 +runner: webpack From 429c8c732cdee022e7e8cc458f4da0145de510d7 Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Thu, 27 Jun 2019 10:25:47 +0200 Subject: [PATCH 13/26] [doc] Updated v6 doc content --- doc/6/controllers/auth/check-token/index.md | 10 +- .../auth/check-token/snippets/check-token.js | 4 + .../auth/create-my-credentials/index.md | 2 +- .../snippets/create-my-credentials.js | 2 +- .../auth/credentials-exist/index.md | 2 +- .../auth/delete-my-credentials/index.md | 2 +- .../auth/get-current-user/index.md | 4 +- .../auth/get-my-credentials/index.md | 2 +- .../snippets/get-my-credentials.js | 2 +- doc/6/controllers/auth/get-my-rights/index.md | 2 +- .../controllers/auth/get-strategies/index.md | 2 +- doc/6/controllers/auth/login/index.md | 18 +- doc/6/controllers/auth/logout/index.md | 6 +- doc/6/controllers/auth/refresh-token/index.md | 58 +++++ .../refresh-token/snippets/refreshToken.js | 22 ++ .../snippets/refreshToken.test.yml | 15 ++ .../auth/update-my-credentials/index.md | 2 +- doc/6/controllers/auth/update-self/index.md | 6 +- .../auth/validate-my-credentials/index.md | 2 +- doc/6/controllers/bulk/import/index.md | 8 +- .../bulk/import/snippets/import.js | 30 ++- doc/6/controllers/collection/create/index.md | 6 +- .../collection/delete-specifications/index.md | 4 +- doc/6/controllers/collection/exists/index.md | 2 +- .../collection/get-mapping/index.md | 4 +- .../get-mapping/snippets/get-mapping.js | 22 +- .../collection/get-specifications/index.md | 2 +- doc/6/controllers/collection/list/index.md | 4 +- .../collection/search-specifications/index.md | 10 +- .../controllers/collection/truncate/index.md | 4 +- .../collection/update-mapping/index.md | 14 +- .../update-mapping/snippets/update-mapping.js | 4 + .../collection/update-specifications/index.md | 4 +- .../validate-specifications/index.md | 4 +- doc/6/controllers/document/count/index.md | 6 +- doc/6/controllers/document/create/index.md | 2 +- .../document/createOrReplace/index.md | 2 +- doc/6/controllers/document/delete/index.md | 2 +- .../document/deleteByQuery/index.md | 2 +- doc/6/controllers/document/get/index.md | 2 +- doc/6/controllers/document/mCreate/index.md | 2 +- .../document/mCreateOrReplace/index.md | 2 +- doc/6/controllers/document/mDelete/index.md | 2 +- doc/6/controllers/document/mGet/index.md | 2 +- doc/6/controllers/document/mReplace/index.md | 2 +- doc/6/controllers/document/mUpdate/index.md | 2 +- doc/6/controllers/document/replace/index.md | 2 +- doc/6/controllers/document/search/index.md | 12 +- doc/6/controllers/document/update/index.md | 2 +- doc/6/controllers/document/validate/index.md | 2 +- doc/6/controllers/index.md | 2 +- doc/6/controllers/index/create/index.md | 4 +- doc/6/controllers/index/delete/index.md | 4 +- doc/6/controllers/index/exists/index.md | 4 +- .../index/get-auto-refresh/index.md | 14 +- doc/6/controllers/index/list/index.md | 4 +- doc/6/controllers/index/m-delete/index.md | 4 +- .../index/refresh-internal/index.md | 19 +- doc/6/controllers/index/refresh/index.md | 12 +- .../index/set-auto-refresh/index.md | 8 +- doc/6/controllers/ms/zrevrangebylex/index.md | 2 +- .../controllers/ms/zrevrangebyscore/index.md | 2 +- doc/6/controllers/realtime/count/index.md | 2 +- doc/6/controllers/realtime/publish/index.md | 2 +- doc/6/controllers/realtime/subscribe/index.md | 4 +- .../controllers/realtime/unsubscribe/index.md | 2 +- .../controllers/server/admin-exists/index.md | 2 +- .../controllers/server/get-all-stats/index.md | 2 +- doc/6/controllers/server/get-config/index.md | 8 +- .../server/get-last-stats/index.md | 2 +- doc/6/controllers/server/get-stats/index.md | 2 +- doc/6/controllers/server/info/index.md | 2 +- doc/6/controllers/server/now/index.md | 2 +- doc/6/core-classes/base-controller/index.md | 7 + .../base-controller/introduction/index.md | 13 + .../base-controller/properties/index.md | 16 ++ .../base-controller/query/index.md | 55 +++++ doc/6/core-classes/index.md | 2 +- .../kuzzle-error/introduction/index.md | 14 +- .../kuzzle-error/properties/index.md | 16 ++ .../add-listener/index.md | 32 +++ .../add-listener/snippets/add-listener.js | 6 + .../snippets/add-listener.test.yml | 9 + .../introduction/index.md | 10 +- .../kuzzle-event-emitter/on/index.md | 2 +- .../kuzzle-event-emitter/once/index.md | 2 +- .../core-classes/kuzzle/add-listener/index.md | 32 --- .../add-listener/snippets/add-listener.js | 9 - .../snippets/add-listener.test.yml | 11 - doc/6/core-classes/kuzzle/connect/index.md | 4 +- .../core-classes/kuzzle/constructor/index.md | 14 +- doc/6/core-classes/kuzzle/disconnect/index.md | 2 +- .../core-classes/kuzzle/flush-queue/index.md | 2 +- doc/6/core-classes/kuzzle/index.md | 2 +- .../core-classes/kuzzle/introduction/index.md | 82 +----- doc/6/core-classes/kuzzle/play-queue/index.md | 2 +- doc/6/core-classes/kuzzle/properties/index.md | 86 +++++++ doc/6/core-classes/kuzzle/query/index.md | 8 +- .../kuzzle/start-queuing/index.md | 2 +- .../core-classes/kuzzle/stop-queuing/index.md | 2 +- .../kuzzle/use-controller/index.md | 34 +++ .../use-controller/snippets/use-controller.js | 35 +++ .../snippets/use-controller.test.yml | 11 + doc/6/core-classes/profile/getRoles/index.md | 2 +- .../profile/introduction/index.md | 20 +- .../core-classes/profile/properties/index.md | 23 ++ doc/6/core-classes/role/introduction/index.md | 13 +- doc/6/core-classes/role/properties/index.md | 16 ++ .../search-result/introduction/index.md | 26 +- .../core-classes/search-result/next/index.md | 22 +- .../search-result/properties/index.md | 27 ++ doc/6/core-classes/user/getProfiles/index.md | 2 +- doc/6/core-classes/user/introduction/index.md | 20 +- doc/6/core-classes/user/properties/index.md | 24 ++ doc/6/essentials/error-handling/index.md | 2 +- doc/6/essentials/events/index.md | 4 +- doc/6/essentials/extend-sdk/index.md | 34 +-- doc/6/essentials/getting-started/index.md | 7 - .../getting-started/node-js/index.md | 156 ------------ .../node-js/snippets/create.js | 39 --- .../node-js/snippets/create.test.yml | 11 - .../getting-started/node-js/snippets/init.js | 37 --- .../node-js/snippets/init.test.yml | 9 - .../node-js/snippets/load-sdk.js | 9 - .../node-js/snippets/load-sdk.test.yml | 9 - .../node-js/snippets/prepare-db.js | 20 -- .../node-js/snippets/prepare-db.test.yml | 9 - .../node-js/snippets/subscribe.js | 51 ---- .../node-js/snippets/subscribe.test.yml | 11 - .../getting-started/raw-web/index.md | 166 ------------- .../raw-web/snippets/create.html | 31 --- .../raw-web/snippets/create.test.yml | 12 - .../raw-web/snippets/load-sdk.html | 14 -- .../raw-web/snippets/load-sdk.test.yml | 10 - .../raw-web/snippets/prepare-db.html | 29 --- .../raw-web/snippets/prepare-db.test.yml | 10 - .../raw-web/snippets/subscribe.html | 32 --- .../raw-web/snippets/subscribe.test.yml | 12 - .../getting-started/webpack/index.md | 233 ------------------ .../webpack/snippets/create.js | 33 --- .../webpack/snippets/create.test.yml | 13 - .../webpack/snippets/init-kuzzle.js | 30 --- .../webpack/snippets/init-kuzzle.test.yml | 10 - .../webpack/snippets/subscribe.js | 49 ---- .../webpack/snippets/subscribe.test.yml | 14 -- doc/6/essentials/index.md | 2 +- doc/6/essentials/offline-tools/index.md | 94 ++++--- .../realtime-notifications/index.md | 6 +- doc/6/getting-started/node-js/index.md | 2 +- doc/6/getting-started/raw-web/index.md | 2 +- doc/6/getting-started/webpack/index.md | 63 ++--- .../webpack/snippets/init-kuzzle.js | 8 + doc/6/protocols/http/constructor/index.md | 4 +- doc/6/protocols/http/introduction/index.md | 15 +- doc/6/protocols/http/properties/index.md | 19 ++ doc/6/protocols/index.md | 2 +- doc/6/protocols/socketio/constructor/index.md | 4 +- .../protocols/socketio/introduction/index.md | 25 +- doc/6/protocols/socketio/properties/index.md | 22 ++ .../protocols/websocket/constructor/index.md | 4 +- .../protocols/websocket/introduction/index.md | 17 +- doc/6/protocols/websocket/properties/index.md | 22 ++ 162 files changed, 955 insertions(+), 1619 deletions(-) create mode 100644 doc/6/controllers/auth/refresh-token/index.md create mode 100644 doc/6/controllers/auth/refresh-token/snippets/refreshToken.js create mode 100644 doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml create mode 100644 doc/6/core-classes/base-controller/index.md create mode 100644 doc/6/core-classes/base-controller/introduction/index.md create mode 100644 doc/6/core-classes/base-controller/properties/index.md create mode 100644 doc/6/core-classes/base-controller/query/index.md create mode 100644 doc/6/core-classes/kuzzle-error/properties/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml delete mode 100644 doc/6/core-classes/kuzzle/add-listener/index.md delete mode 100644 doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.js delete mode 100644 doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml create mode 100644 doc/6/core-classes/kuzzle/properties/index.md create mode 100644 doc/6/core-classes/kuzzle/use-controller/index.md create mode 100644 doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js create mode 100644 doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml create mode 100644 doc/6/core-classes/profile/properties/index.md create mode 100644 doc/6/core-classes/role/properties/index.md create mode 100644 doc/6/core-classes/search-result/properties/index.md create mode 100644 doc/6/core-classes/user/properties/index.md delete mode 100644 doc/6/essentials/getting-started/index.md delete mode 100644 doc/6/essentials/getting-started/node-js/index.md delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/create.js delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/create.test.yml delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/init.js delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/init.test.yml delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/load-sdk.js delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/load-sdk.test.yml delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/prepare-db.js delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/prepare-db.test.yml delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/subscribe.js delete mode 100644 doc/6/essentials/getting-started/node-js/snippets/subscribe.test.yml delete mode 100644 doc/6/essentials/getting-started/raw-web/index.md delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/create.html delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/create.test.yml delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/load-sdk.html delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/load-sdk.test.yml delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/prepare-db.html delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/prepare-db.test.yml delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/subscribe.html delete mode 100644 doc/6/essentials/getting-started/raw-web/snippets/subscribe.test.yml delete mode 100644 doc/6/essentials/getting-started/webpack/index.md delete mode 100644 doc/6/essentials/getting-started/webpack/snippets/create.js delete mode 100644 doc/6/essentials/getting-started/webpack/snippets/create.test.yml delete mode 100644 doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.js delete mode 100644 doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml delete mode 100644 doc/6/essentials/getting-started/webpack/snippets/subscribe.js delete mode 100644 doc/6/essentials/getting-started/webpack/snippets/subscribe.test.yml create mode 100644 doc/6/protocols/http/properties/index.md create mode 100644 doc/6/protocols/socketio/properties/index.md create mode 100644 doc/6/protocols/websocket/properties/index.md diff --git a/doc/6/controllers/auth/check-token/index.md b/doc/6/controllers/auth/check-token/index.md index afb15081b..896cf22f4 100644 --- a/doc/6/controllers/auth/check-token/index.md +++ b/doc/6/controllers/auth/check-token/index.md @@ -7,21 +7,21 @@ description: Checks a JWT's validity. # checkToken -Checks a token validity. +Checks a token validity. -This API route does not require the caller to be logged in. +If no token is provided, the SDK checks its internal authentication token.
-```javascript -checkToken(token); +```js +checkToken([token]); ```
| Property | Type | Description | | -------- | ----------------- | ----------- | -| `token` |
string
| JWT token | +| `token` |
string
| Optional authentication token | ## Resolves diff --git a/doc/6/controllers/auth/check-token/snippets/check-token.js b/doc/6/controllers/auth/check-token/snippets/check-token.js index 7d7914b85..44202a1c5 100644 --- a/doc/6/controllers/auth/check-token/snippets/check-token.js +++ b/doc/6/controllers/auth/check-token/snippets/check-token.js @@ -3,6 +3,10 @@ const credentials = { username: 'foo', password: 'bar' }; try { const jwt = await kuzzle.auth.login('local', credentials); + // Check the internal jwt validity + await kuzzle.auth.checkToken(); + + // Check the jwt validity const result = await kuzzle.auth.checkToken(jwt); console.log(result); /* diff --git a/doc/6/controllers/auth/create-my-credentials/index.md b/doc/6/controllers/auth/create-my-credentials/index.md index bbb2d9ea7..57c5954ea 100644 --- a/doc/6/controllers/auth/create-my-credentials/index.md +++ b/doc/6/controllers/auth/create-my-credentials/index.md @@ -11,7 +11,7 @@ Creates new credentials for the specified strategy for the current user.
-```javascript +```js createMyCredentials(strategy, credentials, [options]); ``` diff --git a/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js index e502caf85..e2213a48c 100644 --- a/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js +++ b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js @@ -5,7 +5,7 @@ await kuzzle.auth.login('local', credentials); const response = await kuzzle.auth.createMyCredentials('other', credentials); console.log(response); /* - { username: 'foo', password: 'bar' } + { username: 'foo', kuid: 'AVkDBl3YsT6qHI7MxLz0' } */ console.log('Credentials successfully created'); diff --git a/doc/6/controllers/auth/credentials-exist/index.md b/doc/6/controllers/auth/credentials-exist/index.md index 5b50cfc12..9c7d5c198 100644 --- a/doc/6/controllers/auth/credentials-exist/index.md +++ b/doc/6/controllers/auth/credentials-exist/index.md @@ -11,7 +11,7 @@ Checks that the current authenticated user has credentials for the specified aut
-```javascript +```js credentialsExist(strategy, [options]); ``` diff --git a/doc/6/controllers/auth/delete-my-credentials/index.md b/doc/6/controllers/auth/delete-my-credentials/index.md index a77775358..a465a5b00 100644 --- a/doc/6/controllers/auth/delete-my-credentials/index.md +++ b/doc/6/controllers/auth/delete-my-credentials/index.md @@ -15,7 +15,7 @@ If the credentials that generated the current JWT are removed, the user will rem
-```javascript +```js deleteMyCredentials(strategy, [options]); ``` diff --git a/doc/6/controllers/auth/get-current-user/index.md b/doc/6/controllers/auth/get-current-user/index.md index 74c7d3cf0..d7cec9938 100644 --- a/doc/6/controllers/auth/get-current-user/index.md +++ b/doc/6/controllers/auth/get-current-user/index.md @@ -11,7 +11,7 @@ Returns information about the currently logged in user.
-```javascript +```js getCurrentUser([options]); ``` @@ -31,7 +31,7 @@ Additional query options ## Resolves -A [User](/sdk/js/6/user) representing the current user logged with the SDK. +A [User](/sdk/js/6/core-classes/user) representing the current user logged with the SDK. ## Usage diff --git a/doc/6/controllers/auth/get-my-credentials/index.md b/doc/6/controllers/auth/get-my-credentials/index.md index d2f4d5cf1..a5a4a3aef 100644 --- a/doc/6/controllers/auth/get-my-credentials/index.md +++ b/doc/6/controllers/auth/get-my-credentials/index.md @@ -15,7 +15,7 @@ The result can be an empty object.
-```javascript +```js getMyCredentials(strategy, [options]); ``` diff --git a/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js index 6ba4e4f7a..9f6888f41 100644 --- a/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js +++ b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js @@ -6,7 +6,7 @@ try { const localCredentials = await kuzzle.auth.getMyCredentials('local'); console.log(localCredentials); /* - { username: 'foo', kuid: 'foo' } + { username: 'foo', kuid: 'AVkDBl3YsT6qHI7MxLz0' } */ console.log('Success'); diff --git a/doc/6/controllers/auth/get-my-rights/index.md b/doc/6/controllers/auth/get-my-rights/index.md index c11b14927..f8fa73bdb 100644 --- a/doc/6/controllers/auth/get-my-rights/index.md +++ b/doc/6/controllers/auth/get-my-rights/index.md @@ -11,7 +11,7 @@ Returns the exhaustive list of granted or denied rights for the currently logged
-```javascript +```js getMyRights([options]); ``` diff --git a/doc/6/controllers/auth/get-strategies/index.md b/doc/6/controllers/auth/get-strategies/index.md index 7e0db7986..9581ee667 100644 --- a/doc/6/controllers/auth/get-strategies/index.md +++ b/doc/6/controllers/auth/get-strategies/index.md @@ -11,7 +11,7 @@ Gets the exhaustive list of registered authentication strategies.
-```javascript +```js getStrategies([options]); ``` diff --git a/doc/6/controllers/auth/login/index.md b/doc/6/controllers/auth/login/index.md index 3baeac2db..22446d6b7 100644 --- a/doc/6/controllers/auth/login/index.md +++ b/doc/6/controllers/auth/login/index.md @@ -9,9 +9,13 @@ description: Authenticate a user Authenticates a user. -
+If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is set to the new authentication token. + +All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout](/sdk/js/6/controllers/auth/logout) action is called, or the `jwt` property is manually set to another value. + +## Arguments -```javascript +```js login(strategy, [credentials], [expiresIn]); ``` @@ -23,14 +27,18 @@ login(strategy, [credentials], [expiresIn]); | `credentials` |
object
|  Credentials for the strategy | | `expiresIn` |
string
|  Expiration time in [ms library](https://www.npmjs.com/package/ms) format. (e.g. `2h`) | -#### strategy +### strategy -The name of the [authentication strategy](/core/1/guide/guides/kuzzle-depth/authentication/) used to log the user in. +The name of the [authentication strategy](/core/1/guides/kuzzle-depth/authentication/) used to log the user in. Depending on the chosen authentication strategy, additional credential arguments may be required. The API request example in this page provides the necessary arguments for the [`local` authentication plugin](https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local). -Check the appropriate [authentication plugin](/core/1/plugins/essentials/strategies/) documentation to get the list of additional arguments to provide. +Check the appropriate [authentication plugin](/core/1/plugins/guides/strategies/overview/) documentation to get the list of additional arguments to provide. + +### expiresIn + + The default value for the `expiresIn` option is defined at server level, in Kuzzle's [configuration file](/core/1/guides/essentials/configuration/). ## Resolves diff --git a/doc/6/controllers/auth/logout/index.md b/doc/6/controllers/auth/logout/index.md index 594597e00..42d67866c 100644 --- a/doc/6/controllers/auth/logout/index.md +++ b/doc/6/controllers/auth/logout/index.md @@ -7,13 +7,15 @@ description: Revokes the user's token & unsubscribe them from registered rooms. # logout -Revokes the user's authentication token. +Revokes the current authentication token. If there were any, real-time subscriptions are cancelled. +If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is unset. +
-```javascript +```js logout(); ``` diff --git a/doc/6/controllers/auth/refresh-token/index.md b/doc/6/controllers/auth/refresh-token/index.md new file mode 100644 index 000000000..a0b517989 --- /dev/null +++ b/doc/6/controllers/auth/refresh-token/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: refreshToken +description: Refresh an authentication token +--- + +# refreshToken + + + +Refreshes a valid, non-expired authentication token. + +If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is set to the new authentication token. + +All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout](/sdk/js/6/controllers/auth/logout) action is called, or the `jwt` property is manually set to another value. + + +## Arguments + +```js +refreshToken ([options]) +``` + +
+ +| Arguments | Type | Description | +|--------------|---------|-------------| +| `options` |
object
| Query options | + + +### options + +Additional query options + +| Property | Type
(default) | Description | +| -------------- | --------- | ------------- | +| `expiresIn` |
string
| Expiration time in [ms library](https://www.npmjs.com/package/ms) format. (e.g. `2h`) | +| `queuable` |
boolean

(`true`)| If true, queues the request during downtime, until connected to Kuzzle again | + +### expiresIn + +The default value for the `expiresIn` option is defined at server level, in Kuzzle's [configuration file](/core/1/guides/essentials/configuration/). + +## Resolves + +The `refreshToken` action resolves to a token object with the following properties: + +| Property | Type | Description | +|--------------|---------|-------------| +| `_id` |
string
| User unique identifier ([kuid](/core/1/guides/essentials/user-authentication/#kuzzle-user-identifier-kuid)) | +| `expiresAt` |
number
| Expiration timestamp in Epoch-millis format (UTC) | +| `jwt` |
string
| Authentication token | +| `ttl` |
number
| Time to live of the authentication token, in milliseconds | + +## Usage + +<<< ./snippets/refreshToken.js diff --git a/doc/6/controllers/auth/refresh-token/snippets/refreshToken.js b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.js new file mode 100644 index 000000000..778869426 --- /dev/null +++ b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.js @@ -0,0 +1,22 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + const jwt = await kuzzle.auth.login('local', credentials); + + // Prints the encrypted authentication token + console.log(jwt); + + // Note: to get a different token, you actually need to wait at least + // 1 second. Otherwise you do receive a refreshed token, but with the exact + // same caracteristics, as the key depends on the timestamp in Epoch format + await new Promise(resolve => setTimeout(resolve, 1000)); + + // Prints: + // { _id: '', + // jwt: '' + // expiresAt: 1553185334220, + // ttl: 3600000 } + console.log(await kuzzle.auth.refreshToken()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml new file mode 100644 index 000000000..c0637630c --- /dev/null +++ b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml @@ -0,0 +1,15 @@ +--- +name: auth#login +description: Authenticate a user +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: + - ^.*\..*$ + - "{ _id: 'foo'," + - ^\s*jwt: '.*\..*' + - ^\s*expiresAt: \d+ + - ^\s*ttl: \d+ } +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/update-my-credentials/index.md b/doc/6/controllers/auth/update-my-credentials/index.md index 04db42062..06bf649ec 100644 --- a/doc/6/controllers/auth/update-my-credentials/index.md +++ b/doc/6/controllers/auth/update-my-credentials/index.md @@ -11,7 +11,7 @@ Updates the credentials of the currently logged in user for the specified strate
-```javascript +```js updateMyCredentials(strategy, credentials, [options]); ``` diff --git a/doc/6/controllers/auth/update-self/index.md b/doc/6/controllers/auth/update-self/index.md index 0d8c014cf..3a041ecd7 100644 --- a/doc/6/controllers/auth/update-self/index.md +++ b/doc/6/controllers/auth/update-self/index.md @@ -9,11 +9,11 @@ description: Updates the current user object in Kuzzle. Updates the currently logged in user content. -This route cannot update the list of associated security profiles. To change a user's security profiles, the route [security:updateUser](/core/1/api/api-reference/controller-security/update-user/) must be used instead. +This route cannot update the list of associated security profiles. To change a user's security profiles, the route [security:updateUser](/core/1/api/controllers/security/update-user/) must be used instead.
-```javascript +```js updateSelf(content, [options]); ``` @@ -34,7 +34,7 @@ Additional query options ## Resolves -A [User](/sdk/js/6/user) representing the current user logged with the SDK. +A [User](/sdk/js/6/core-classes/user) representing the current user logged with the SDK. ## Usage diff --git a/doc/6/controllers/auth/validate-my-credentials/index.md b/doc/6/controllers/auth/validate-my-credentials/index.md index 62f7b2abf..5ebcda913 100644 --- a/doc/6/controllers/auth/validate-my-credentials/index.md +++ b/doc/6/controllers/auth/validate-my-credentials/index.md @@ -13,7 +13,7 @@ This route neither creates nor modifies credentials.
-```javascript +```js validateMyCredentials(strategy, [credentials], [options]); ``` diff --git a/doc/6/controllers/bulk/import/index.md b/doc/6/controllers/bulk/import/index.md index 3dc55c05a..6e53b196b 100644 --- a/doc/6/controllers/bulk/import/index.md +++ b/doc/6/controllers/bulk/import/index.md @@ -15,7 +15,7 @@ If some documents actions fail, the client will receive a [PartialError](/core/1
-```javascript +```js import (bulkData, [options]) ``` @@ -31,7 +31,7 @@ import (bulkData, [options]) This API takes a JSON array containing a list of objects working in pairs. In each pair, the first object specifies the action to perform (the most common is `create`) and the second specifies the document itself, like in the example below: -```javascript +```js [ // The action object { create: { _id: 'id', _index: 'index', _type: 'collection' } }, @@ -71,11 +71,11 @@ An object containing information about the import status for each document. Each object has the following structure: -```javascript +```js { "": { _id: "another-id", - status: 200 + status: 201 } } ``` diff --git a/doc/6/controllers/bulk/import/snippets/import.js b/doc/6/controllers/bulk/import/snippets/import.js index d2ba28f6b..a0011e997 100644 --- a/doc/6/controllers/bulk/import/snippets/import.js +++ b/doc/6/controllers/bulk/import/snippets/import.js @@ -13,18 +13,28 @@ try { /* { errors: false, items: - [ { create: create: { - _id: "1", - status: 200 } }, - { create: create: { - _id: "2", - status: 200 } }, - { create: create: { - _id: "3", - status: 200 } } ] } + [ { + create: { + _id: "uniq-id-1", + status: 201 + } + }, + { + create: { + _id: "uniq-id-2", + status: 201 + } + }, + { + create: { + _id: "uniq-id-3", + status: 206 + } + } ] } */ + const successfulImport = response.items.filter(item => item.create.status === 201); - console.log(`Successfully imported ${response.items.length} documents`); + console.log(`Successfully imported ${successfulImport.length} documents`); } catch (error) { console.error(error.message); } diff --git a/doc/6/controllers/collection/create/index.md b/doc/6/controllers/collection/create/index.md index cd7be0be9..ece434f22 100644 --- a/doc/6/controllers/collection/create/index.md +++ b/doc/6/controllers/collection/create/index.md @@ -7,7 +7,7 @@ description: Create a new collection # create -Creates a new [collection](/core/1/guide/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided index. +Creates a new [collection](/core/1/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided index. You can also provide an optional data mapping that allow you to exploit the full capabilities of our persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html)). @@ -16,7 +16,7 @@ This method will only update the mapping if the collection already exists.
-```javascript +```js create(index, collection, [mapping], [options]); ``` @@ -48,7 +48,7 @@ const mapping = { }; ``` -You can see the full list of Elasticsearch mapping types [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html). +More informations about database mappings [here](/core/1/guides/essentials/database-mappings). ### options diff --git a/doc/6/controllers/collection/delete-specifications/index.md b/doc/6/controllers/collection/delete-specifications/index.md index 59d0e9e06..3445f924b 100644 --- a/doc/6/controllers/collection/delete-specifications/index.md +++ b/doc/6/controllers/collection/delete-specifications/index.md @@ -7,11 +7,11 @@ description: Delete validation specifications for a collection # deleteSpecifications -Deletes validation specifications for a data collection. +Deletes validation specifications for a collection.
-```javascript +```js deleteSpecifications(index, collection, [options]); ``` diff --git a/doc/6/controllers/collection/exists/index.md b/doc/6/controllers/collection/exists/index.md index 978df396b..8a8000677 100644 --- a/doc/6/controllers/collection/exists/index.md +++ b/doc/6/controllers/collection/exists/index.md @@ -11,7 +11,7 @@ Check if a collection exists in Kuzzle.
-```javascript +```js exists(index, collection, [options]); ``` diff --git a/doc/6/controllers/collection/get-mapping/index.md b/doc/6/controllers/collection/get-mapping/index.md index dfecf3989..0f0fdcade 100644 --- a/doc/6/controllers/collection/get-mapping/index.md +++ b/doc/6/controllers/collection/get-mapping/index.md @@ -7,11 +7,11 @@ description: Return collection mapping # getMapping -Returns a data collection mapping. +Returns the collection mapping.
-```javascript +```js getMapping(index, collection, [options]); ``` diff --git a/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js index 0505683f1..772aa3455 100644 --- a/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js +++ b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js @@ -2,17 +2,27 @@ try { const mapping = await kuzzle.collection.getMapping('nyc-open-data', 'yellow-taxi'); console.log(mapping); /* - { - properties: { - license: { type: 'keyword' }, - driver: { + { + "nyc-open-data": { + "mappings": { + "yellow-taxi": { + dynamic: 'false', + _meta: { + area: 'Panipokhari + }, properties: { - name: { type: 'keyword' }, - curriculum: { type: 'text' } + license: { type: 'keyword' }, + driver: { + properties: { + name: { type: 'keyword' }, + curriculum: { type: 'text' } + } + } } } } } + } */ console.log('Success'); diff --git a/doc/6/controllers/collection/get-specifications/index.md b/doc/6/controllers/collection/get-specifications/index.md index ff539a900..955197268 100644 --- a/doc/6/controllers/collection/get-specifications/index.md +++ b/doc/6/controllers/collection/get-specifications/index.md @@ -11,7 +11,7 @@ Returns the validation specifications associated to the given index and collecti
-```javascript +```js getSpecifications(index, collection, [options]); ``` diff --git a/doc/6/controllers/collection/list/index.md b/doc/6/controllers/collection/list/index.md index 5da2329dc..c6b5f6d55 100644 --- a/doc/6/controllers/collection/list/index.md +++ b/doc/6/controllers/collection/list/index.md @@ -7,12 +7,12 @@ description: Returns the collection list of an index # list -Returns the list of data collections associated to a provided data index. +Returns the list of collections associated to a provided index. The returned list is sorted in alphanumerical order.
-```javascript +```js list(index, [options]); ``` diff --git a/doc/6/controllers/collection/search-specifications/index.md b/doc/6/controllers/collection/search-specifications/index.md index d93f4d349..89ba5727a 100644 --- a/doc/6/controllers/collection/search-specifications/index.md +++ b/doc/6/controllers/collection/search-specifications/index.md @@ -14,13 +14,13 @@ Searches collection specifications. There is a limit to how many items can be returned by a single search query. That limit is by default set at 10000, and you can't get over it even with the from and size pagination options. -
- When processing a large number of items (i.e. more than 1000), it is advised to paginate the results using SearchResult.next rather than increasing the size parameter. -
+:::info +When processing a large number of items (i.e. more than 1000), it is advised to paginate the results using [SearchResult.next](/sdk/js/6/core-classes/search-result/next/) rather than increasing the size parameter. +:::
-```javascript +```js searchSpecifications([body], [options]); ``` @@ -63,7 +63,7 @@ const body = { ## Resolves -Resolve to a [SpecificationsSearchResult](/sdk/js/6/search-result). +Resolve to a [SpecificationsSearchResult](/sdk/js/6/core-classes/search-result). ## Usage diff --git a/doc/6/controllers/collection/truncate/index.md b/doc/6/controllers/collection/truncate/index.md index e86c4dab1..0f38bac7f 100644 --- a/doc/6/controllers/collection/truncate/index.md +++ b/doc/6/controllers/collection/truncate/index.md @@ -7,11 +7,11 @@ description: Remove all documents from collection # truncate -Removes all documents from a data collection, while keeping the associated mapping. +Removes all documents from a collection, while keeping the associated mapping.
-```javascript +```js truncate(index, collection, [options]); ``` diff --git a/doc/6/controllers/collection/update-mapping/index.md b/doc/6/controllers/collection/update-mapping/index.md index 2f50650b2..f01043b23 100644 --- a/doc/6/controllers/collection/update-mapping/index.md +++ b/doc/6/controllers/collection/update-mapping/index.md @@ -7,11 +7,15 @@ description: Update the collection mapping # updateMapping -Updates a data collection mapping. + + +You can define the collection [dynamic mapping policy](/core/1/guides/essentials/database-mappings/#dynamic-mapping-policy) by setting the `dynamic` field to the desired value. + +You can define [collection additional metadata](/core/1/guides/essentials/database-mappings/#collection-metadata) within the `_meta` root field.
-```javascript +```js updateMapping(index, collection, mapping, [options]); ``` @@ -21,7 +25,7 @@ updateMapping(index, collection, mapping, [options]); | ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `index` |
string
| Index name | | `collection` |
string
| Collection name | -| `mapping` |
object
| Describes the data mapping to associate to the new collection, using Elasticsearch [mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html) | +| `mapping` |
object
| Describes the collection mapping | | `options` |
object
| Query options | ### mapping @@ -30,7 +34,7 @@ An object representing the collection data mapping. This object must have a root field `properties` that contain the mapping definition: -```javascript +```js const mapping = { properties: { field1: { type: 'text' }, @@ -43,7 +47,7 @@ const mapping = { }; ``` -You can see the full list of Elasticsearch mapping types [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-types.html). +More informations about database mappings [here](/core/1/guides/essentials/database-mappings). ### options diff --git a/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js index 0f37af87f..d286a6c0a 100644 --- a/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js +++ b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js @@ -1,4 +1,8 @@ const mapping = { + dynamic: 'false', + _meta: { + area: 'Panipokhari' + }, properties: { plate: { type: 'keyword' } } diff --git a/doc/6/controllers/collection/update-specifications/index.md b/doc/6/controllers/collection/update-specifications/index.md index 54595e73b..229434640 100644 --- a/doc/6/controllers/collection/update-specifications/index.md +++ b/doc/6/controllers/collection/update-specifications/index.md @@ -13,7 +13,7 @@ When the validation specification is not formatted correctly, a detailed error m
-```javascript +```js updateSpecifications(index, collection, specifications, [options]); ``` @@ -30,7 +30,7 @@ updateSpecifications(index, collection, specifications, [options]); An object representing the specifications. -This object must follow the [Specification Structure](/core/1/guide/guides/essentials/data-validation/): +This object must follow the [Specification Structure](/core/1/guides/essentials/data-validation/): ```js { diff --git a/doc/6/controllers/collection/validate-specifications/index.md b/doc/6/controllers/collection/validate-specifications/index.md index 4c24b5606..23d96e712 100644 --- a/doc/6/controllers/collection/validate-specifications/index.md +++ b/doc/6/controllers/collection/validate-specifications/index.md @@ -13,7 +13,7 @@ When the validation specification is not formatted correctly, a detailed error m
-```javascript +```js validateSpecifications(index, collection, specifications, [options]); ``` @@ -30,7 +30,7 @@ validateSpecifications(index, collection, specifications, [options]); An object representing the specifications. -This object must follow the [Specification Structure](/core/1/guide/datavalidation): +This object must follow the [Specification Structure](/core/1/guides/cookbooks/datavalidation): ```js { diff --git a/doc/6/controllers/document/count/index.md b/doc/6/controllers/document/count/index.md index dbde718c8..9b4bb5660 100644 --- a/doc/6/controllers/document/count/index.md +++ b/doc/6/controllers/document/count/index.md @@ -7,15 +7,15 @@ description: Count documents matching the given query # count -Counts documents in a data collection. +Counts documents in a collection. -A query can be provided to alter the count result, otherwise returns the total number of documents in the data collection. +A query can be provided to alter the count result, otherwise returns the total number of documents in the collection. Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax.
-```javascript +```js count(index, collection, query, [options]); ``` diff --git a/doc/6/controllers/document/create/index.md b/doc/6/controllers/document/create/index.md index c27ca936b..8515405eb 100644 --- a/doc/6/controllers/document/create/index.md +++ b/doc/6/controllers/document/create/index.md @@ -15,7 +15,7 @@ The optional parameter `refresh` can be used with the value `wait_for` in order
-```javascript +```js create(index, collection, document, [id], [options]); ``` diff --git a/doc/6/controllers/document/createOrReplace/index.md b/doc/6/controllers/document/createOrReplace/index.md index d3b9e859e..1851b8ed4 100644 --- a/doc/6/controllers/document/createOrReplace/index.md +++ b/doc/6/controllers/document/createOrReplace/index.md @@ -13,7 +13,7 @@ The optional parameter `refresh` can be used with the value `wait_for` in order
-```javascript +```js createOrReplace(index, collection, id, document, [options]); ``` diff --git a/doc/6/controllers/document/delete/index.md b/doc/6/controllers/document/delete/index.md index 0ad458677..f93577750 100644 --- a/doc/6/controllers/document/delete/index.md +++ b/doc/6/controllers/document/delete/index.md @@ -13,7 +13,7 @@ The optional parameter `refresh` can be used with the value `wait_for` in order
-```javascript +```js delete (index, collection, id, [options]); ``` diff --git a/doc/6/controllers/document/deleteByQuery/index.md b/doc/6/controllers/document/deleteByQuery/index.md index 47e3bffab..2cec180a0 100644 --- a/doc/6/controllers/document/deleteByQuery/index.md +++ b/doc/6/controllers/document/deleteByQuery/index.md @@ -15,7 +15,7 @@ An empty or null query will match all documents in the collection.
-```javascript +```js deleteByQuery(index, collection, [query], [options]); ``` diff --git a/doc/6/controllers/document/get/index.md b/doc/6/controllers/document/get/index.md index f1ba3b924..2f58324f2 100644 --- a/doc/6/controllers/document/get/index.md +++ b/doc/6/controllers/document/get/index.md @@ -11,7 +11,7 @@ Gets a document.
-```javascript +```js get(index, collection, id, [options]); ``` diff --git a/doc/6/controllers/document/mCreate/index.md b/doc/6/controllers/document/mCreate/index.md index 5cf504870..c6ab42416 100644 --- a/doc/6/controllers/document/mCreate/index.md +++ b/doc/6/controllers/document/mCreate/index.md @@ -13,7 +13,7 @@ Throws a partial error (error code 206) if one or more documents creations fail.
-```javascript +```js mCreate(index, collection, documents, [options]); ``` diff --git a/doc/6/controllers/document/mCreateOrReplace/index.md b/doc/6/controllers/document/mCreateOrReplace/index.md index 2d2ab6465..a4b757831 100644 --- a/doc/6/controllers/document/mCreateOrReplace/index.md +++ b/doc/6/controllers/document/mCreateOrReplace/index.md @@ -13,7 +13,7 @@ Throws a partial error (error code 206) if one or more document creations/replac
-```javascript +```js mCreateOrReplace(index, collection, documents, [options]); ``` diff --git a/doc/6/controllers/document/mDelete/index.md b/doc/6/controllers/document/mDelete/index.md index 6bef0490f..8f15386ed 100644 --- a/doc/6/controllers/document/mDelete/index.md +++ b/doc/6/controllers/document/mDelete/index.md @@ -15,7 +15,7 @@ The optional parameter `refresh` can be used with the value `wait_for` in order
-```javascript +```js mDelete(index, collection, ids, [options]); ``` diff --git a/doc/6/controllers/document/mGet/index.md b/doc/6/controllers/document/mGet/index.md index 20cb5730c..95c9009f2 100644 --- a/doc/6/controllers/document/mGet/index.md +++ b/doc/6/controllers/document/mGet/index.md @@ -13,7 +13,7 @@ Throws a partial error (error code 206) if one or more document can not be retri
-```javascript +```js mGet(index, collection, ids, [options]); ``` diff --git a/doc/6/controllers/document/mReplace/index.md b/doc/6/controllers/document/mReplace/index.md index d2fa11d22..c05a6c58c 100644 --- a/doc/6/controllers/document/mReplace/index.md +++ b/doc/6/controllers/document/mReplace/index.md @@ -13,7 +13,7 @@ Throws a partial error (error code 206) if one or more documents can not be repl
-```javascript +```js mReplace(index, collection, documents, [options]); ``` diff --git a/doc/6/controllers/document/mUpdate/index.md b/doc/6/controllers/document/mUpdate/index.md index c6ce22d3c..28dd2ec8e 100644 --- a/doc/6/controllers/document/mUpdate/index.md +++ b/doc/6/controllers/document/mUpdate/index.md @@ -17,7 +17,7 @@ You can set the `retryOnConflict` optional argument (with a retry count), to tel
-```javascript +```js mUpdate(index, collection, documents, [options]); ``` diff --git a/doc/6/controllers/document/replace/index.md b/doc/6/controllers/document/replace/index.md index 2dc508387..f219be349 100644 --- a/doc/6/controllers/document/replace/index.md +++ b/doc/6/controllers/document/replace/index.md @@ -11,7 +11,7 @@ Replaces the content of an existing document.
-```javascript +```js replace(index, collection, id, document, [options]); ``` diff --git a/doc/6/controllers/document/search/index.md b/doc/6/controllers/document/search/index.md index ed851c5da..d55ddf8e3 100644 --- a/doc/6/controllers/document/search/index.md +++ b/doc/6/controllers/document/search/index.md @@ -12,15 +12,13 @@ Searches documents. There is a limit to how many documents can be returned by a single search query. That limit is by default set at 10000 documents, and you can't get over it even with the from and size pagination options. -
-

- When processing a large number of documents (i.e. more than 1000), it is advised to paginate the results using SearchResult.next rather than increasing the size parameter. -

-
+:::info +When processing a large number of documents (i.e. more than 1000), it is advised to paginate the results using [SearchResult.next](/sdk/js/6/core-classes/search-result/next/) rather than increasing the size parameter. +:::
-```javascript +```js search(index, collection, [query], [options]); ``` @@ -54,7 +52,7 @@ An empty body matches all documents in the queried collection. ## Resolves -Resolves to a [SearchResult](/sdk/js/6/search-result) object. +Resolves to a [SearchResult](/sdk/js/6/core-classes/search-result) object. ## Usage diff --git a/doc/6/controllers/document/update/index.md b/doc/6/controllers/document/update/index.md index c92edebac..a2587af85 100644 --- a/doc/6/controllers/document/update/index.md +++ b/doc/6/controllers/document/update/index.md @@ -14,7 +14,7 @@ You can set the `retryOnConflict` optional argument (with a retry count), to tel
-```javascript +```js update(index, collection, id, document, [options]); ``` diff --git a/doc/6/controllers/document/validate/index.md b/doc/6/controllers/document/validate/index.md index 89002971f..e274a21c1 100644 --- a/doc/6/controllers/document/validate/index.md +++ b/doc/6/controllers/document/validate/index.md @@ -15,7 +15,7 @@ This request does **not** store or publish the document.
-```javascript +```js validate(index, collection, document, [options]); ``` diff --git a/doc/6/controllers/index.md b/doc/6/controllers/index.md index 35788d401..18fd371b3 100644 --- a/doc/6/controllers/index.md +++ b/doc/6/controllers/index.md @@ -1,7 +1,7 @@ --- code: false type: branch -order: 300 +order: 400 title: Controllers description: Javascript SDK v6.x controllers --- diff --git a/doc/6/controllers/index/create/index.md b/doc/6/controllers/index/create/index.md index 9f5ceee55..6fd496175 100644 --- a/doc/6/controllers/index/create/index.md +++ b/doc/6/controllers/index/create/index.md @@ -7,11 +7,11 @@ description: Creates an index # create -Creates a new data index. +Creates a new index.
-```javascript +```js create(index, [options]); ``` diff --git a/doc/6/controllers/index/delete/index.md b/doc/6/controllers/index/delete/index.md index 86dd310b8..29e082d6d 100644 --- a/doc/6/controllers/index/delete/index.md +++ b/doc/6/controllers/index/delete/index.md @@ -7,11 +7,11 @@ description: Deletes an index # delete -Deletes a data index. +Deletes a index.
-```javascript +```js delete (index, [options]); ``` diff --git a/doc/6/controllers/index/exists/index.md b/doc/6/controllers/index/exists/index.md index 177abd303..c16e4e312 100644 --- a/doc/6/controllers/index/exists/index.md +++ b/doc/6/controllers/index/exists/index.md @@ -7,11 +7,11 @@ description: Check for index existence # exists -Checks if the given data index exists. +Checks if the given index exists.
-```javascript +```js exists(index, [options]); ``` diff --git a/doc/6/controllers/index/get-auto-refresh/index.md b/doc/6/controllers/index/get-auto-refresh/index.md index 8c55abebd..46c82aa47 100644 --- a/doc/6/controllers/index/get-auto-refresh/index.md +++ b/doc/6/controllers/index/get-auto-refresh/index.md @@ -7,21 +7,21 @@ description: Returns the status of autorefresh flag # getAutoRefresh -This action returns the current autorefresh status of a data index. +This action returns the current autorefresh status of a index. Each index has an autorefresh flag. When set to true, each write request triggers a [refresh](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html) action in Elasticsearch. Without a refresh after a write request, the documents may not be immediately visible in search. -
- A refresh operation comes with some performance costs. - While forcing the autoRefresh can be convenient on a development or test environment, - we recommend that you avoid using it in production or at least carefully monitor its implications before using it. -
+:::info +A refresh operation comes with some performance costs. +While forcing the autoRefresh can be convenient on a development or test environment, +we recommend that you avoid using it in production or at least carefully monitor its implications before using it. +:::
-```javascript +```js getAutoRefresh(index, [options]); ``` diff --git a/doc/6/controllers/index/list/index.md b/doc/6/controllers/index/list/index.md index a626d87c0..8e0cdb985 100644 --- a/doc/6/controllers/index/list/index.md +++ b/doc/6/controllers/index/list/index.md @@ -7,11 +7,11 @@ description: Lists the indexes # list -Returns the complete list of data indexes. +Returns the complete list of indexes.
-```javascript +```js list([options]); ``` diff --git a/doc/6/controllers/index/m-delete/index.md b/doc/6/controllers/index/m-delete/index.md index 473c7c1eb..fbd825509 100644 --- a/doc/6/controllers/index/m-delete/index.md +++ b/doc/6/controllers/index/m-delete/index.md @@ -7,11 +7,11 @@ description: Deletes multiple indexes # mDelete -Deletes multiple data indexes. +Deletes multiple indexes.
-```javascript +```js mDelete(indexes, [options]); ``` diff --git a/doc/6/controllers/index/refresh-internal/index.md b/doc/6/controllers/index/refresh-internal/index.md index f8ec74000..e09917b8d 100644 --- a/doc/6/controllers/index/refresh-internal/index.md +++ b/doc/6/controllers/index/refresh-internal/index.md @@ -11,30 +11,29 @@ When writing or deleting security and internal documents (users, roles, profiles The `refreshInternal` action forces a [refresh](//sdk/js/6/controllers/index/refresh), on the internal index, making the documents available to search immediately. -
- A refresh operation comes with some performance costs. +:::info +A refresh operation comes with some performance costs. -From [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html): -"While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." +From the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html): +> "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." -
+::: -
+## Arguments -```javascript -refreshInternal(index, [options]); +```js +refreshInternal([options]); ```
| Arguments | Type | Description | | --------- | ----------------- | ------------- | -| `index` |
string
| Index name | | `options` |
object
| Query options | ### options -Additional query options +The `options` arguments can contain the following option properties: | Property | Type
(default) | Description | | ---------- | ------------------------------- | ---------------------------------------------------------------------------- | diff --git a/doc/6/controllers/index/refresh/index.md b/doc/6/controllers/index/refresh/index.md index 77d6eac98..cb338cfe4 100644 --- a/doc/6/controllers/index/refresh/index.md +++ b/doc/6/controllers/index/refresh/index.md @@ -9,17 +9,17 @@ description: Forces an Elasticsearch search index update When writing or deleting documents in Kuzzle, the update needs to be indexed before being available in search results. -
- A refresh operation comes with some performance costs. +:::info +A refresh operation comes with some performance costs. -From [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html): -"While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." +From the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html): +> "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." -
+:::
-```javascript +```js refresh(index, [options]); ``` diff --git a/doc/6/controllers/index/set-auto-refresh/index.md b/doc/6/controllers/index/set-auto-refresh/index.md index 4cbd1dc80..9f21a040d 100644 --- a/doc/6/controllers/index/set-auto-refresh/index.md +++ b/doc/6/controllers/index/set-auto-refresh/index.md @@ -7,21 +7,21 @@ description: Set the autorefresh flag # setAutoRefresh -The setAutoRefresh action allows to set the autorefresh flag for a data index. +The setAutoRefresh action allows to set the autorefresh flag for a index. Each index has an autorefresh flag. When set to true, each write request trigger a [refresh](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html) action on Elasticsearch. Without a refresh after a write request, the documents may not be immediately visible in search. -
+:::info A refresh operation comes with performance costs. While forcing the autoRefresh can be convenient on a development or test environment, we recommend that you avoid using it in production or at least carefully monitor its implications before using it. -
+:::
-```javascript +```js setAutoRefresh(index, autoRefresh, [options]); ``` diff --git a/doc/6/controllers/ms/zrevrangebylex/index.md b/doc/6/controllers/ms/zrevrangebylex/index.md index 3ded3eb72..413ac7f97 100644 --- a/doc/6/controllers/ms/zrevrangebylex/index.md +++ b/doc/6/controllers/ms/zrevrangebylex/index.md @@ -6,7 +6,7 @@ title: zrevrangebylex # zrevrangebylex -Identical to [zrangebylex](/core/1/api/api-reference/controller-memory-storage/zrangebylex/) except that the sorted set is traversed in descending order. +Identical to [zrangebylex](/core/1/api/controllers/memory-storage/zrangebylex/) except that the sorted set is traversed in descending order. [[_Redis documentation_]](https://redis.io/commands/zrevrangebylex) diff --git a/doc/6/controllers/ms/zrevrangebyscore/index.md b/doc/6/controllers/ms/zrevrangebyscore/index.md index 28cf60125..cf6d3313a 100644 --- a/doc/6/controllers/ms/zrevrangebyscore/index.md +++ b/doc/6/controllers/ms/zrevrangebyscore/index.md @@ -6,7 +6,7 @@ title: zrevrangebyscore # zrevrangebyscore -Identical to [zrangebyscore](/core/1/api/api-reference/controller-memory-storage/zrangebyscore/), except that the sorted set is traversed in descending order. +Identical to [zrangebyscore](/core/1/api/controllers/memory-storage/zrangebyscore/), except that the sorted set is traversed in descending order. [[_Redis documentation_]](https://redis.io/commands/zrevrangebyscore) diff --git a/doc/6/controllers/realtime/count/index.md b/doc/6/controllers/realtime/count/index.md index 6787eb0b2..d8beddf88 100644 --- a/doc/6/controllers/realtime/count/index.md +++ b/doc/6/controllers/realtime/count/index.md @@ -11,7 +11,7 @@ Returns the number of other connections sharing the same subscription. ## Arguments -```javascript +```js count(roomId, [options]); ``` diff --git a/doc/6/controllers/realtime/publish/index.md b/doc/6/controllers/realtime/publish/index.md index 0ccc0ced4..947c21771 100644 --- a/doc/6/controllers/realtime/publish/index.md +++ b/doc/6/controllers/realtime/publish/index.md @@ -15,7 +15,7 @@ The index and collection are indicative and serve only to distinguish the rooms.
-```javascript +```js publish(index, collection, message, [options]); ``` diff --git a/doc/6/controllers/realtime/subscribe/index.md b/doc/6/controllers/realtime/subscribe/index.md index 3bf31333d..7eb6b6b42 100644 --- a/doc/6/controllers/realtime/subscribe/index.md +++ b/doc/6/controllers/realtime/subscribe/index.md @@ -11,7 +11,7 @@ Subscribes by providing a set of filters: messages, document changes and, option
-```javascript +```js subscribe(index, collection, filters, callback, [options]); ``` @@ -21,7 +21,7 @@ subscribe(index, collection, filters, callback, [options]); | ------------ | ------------------- | ------------------------------------------------------------- | | `index` |
string
| Index name | | `collection` |
string
| Collection name | -| `filters` |
object
| Set of filters following [Koncorde syntax](/core/1/koncorde/) | +| `filters` |
object
| Set of filters following [Koncorde syntax](/core/1/guides/cookbooks/realtime-api/) | | `callback` |
function
| Callback function to handle notifications | | `options` |
object
| Query options | diff --git a/doc/6/controllers/realtime/unsubscribe/index.md b/doc/6/controllers/realtime/unsubscribe/index.md index b0615854c..795959c8a 100644 --- a/doc/6/controllers/realtime/unsubscribe/index.md +++ b/doc/6/controllers/realtime/unsubscribe/index.md @@ -11,7 +11,7 @@ Removes a subscription.
-```javascript +```js unsubscribe(roomId, [options]); ``` diff --git a/doc/6/controllers/server/admin-exists/index.md b/doc/6/controllers/server/admin-exists/index.md index 76c0cbe0d..9c1e84988 100644 --- a/doc/6/controllers/server/admin-exists/index.md +++ b/doc/6/controllers/server/admin-exists/index.md @@ -11,7 +11,7 @@ Checks that an administrator account exists.
-```javascript +```js adminExists([options]); ``` diff --git a/doc/6/controllers/server/get-all-stats/index.md b/doc/6/controllers/server/get-all-stats/index.md index 65eb2fd03..a808d44d5 100644 --- a/doc/6/controllers/server/get-all-stats/index.md +++ b/doc/6/controllers/server/get-all-stats/index.md @@ -19,7 +19,7 @@ These statistics include:
-```javascript +```js getAllStats([options]); ``` diff --git a/doc/6/controllers/server/get-config/index.md b/doc/6/controllers/server/get-config/index.md index fdcb314fe..f1820d340 100644 --- a/doc/6/controllers/server/get-config/index.md +++ b/doc/6/controllers/server/get-config/index.md @@ -9,13 +9,13 @@ description: Returns the current Kuzzle configuration. Returns the current Kuzzle configuration. -
- This route should only be accessible to administrators, as it might return sensitive information about the backend. -
+:::warning +This route should only be accessible to administrators, as it might return sensitive information about the backend. +:::
-```javascript +```js getConfig([options]); ``` diff --git a/doc/6/controllers/server/get-last-stats/index.md b/doc/6/controllers/server/get-last-stats/index.md index a60987c80..4b2343fc9 100644 --- a/doc/6/controllers/server/get-last-stats/index.md +++ b/doc/6/controllers/server/get-last-stats/index.md @@ -20,7 +20,7 @@ These statistics include:
-```javascript +```js getLastStats([options]); ``` diff --git a/doc/6/controllers/server/get-stats/index.md b/doc/6/controllers/server/get-stats/index.md index 53b2a3589..d30996d00 100644 --- a/doc/6/controllers/server/get-stats/index.md +++ b/doc/6/controllers/server/get-stats/index.md @@ -19,7 +19,7 @@ These statistics include:
-```javascript +```js getStats(startTime, stopTime, [options]); ``` diff --git a/doc/6/controllers/server/info/index.md b/doc/6/controllers/server/info/index.md index 68b63400e..182f32649 100644 --- a/doc/6/controllers/server/info/index.md +++ b/doc/6/controllers/server/info/index.md @@ -11,7 +11,7 @@ Returns information about Kuzzle: available API (base + extended), plugins, exte
-```javascript +```js info([options]); ``` diff --git a/doc/6/controllers/server/now/index.md b/doc/6/controllers/server/now/index.md index fd82c7774..9a2ad4777 100644 --- a/doc/6/controllers/server/now/index.md +++ b/doc/6/controllers/server/now/index.md @@ -11,7 +11,7 @@ Returns the current server timestamp, in Epoch-millis format.
-```javascript +```js now([options]); ``` diff --git a/doc/6/core-classes/base-controller/index.md b/doc/6/core-classes/base-controller/index.md new file mode 100644 index 000000000..15b75fbad --- /dev/null +++ b/doc/6/core-classes/base-controller/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: BaseController +description: BaseController object documentation +order: 500 +--- diff --git a/doc/6/core-classes/base-controller/introduction/index.md b/doc/6/core-classes/base-controller/introduction/index.md new file mode 100644 index 000000000..5692b1d71 --- /dev/null +++ b/doc/6/core-classes/base-controller/introduction/index.md @@ -0,0 +1,13 @@ +--- +code: true +type: page +title: Introduction +description: BaseController class +order: 0 +--- + +# BaseController + +Base class for a [custom SDK controller](/sdk/js/6/essentials/extend-sdk/#define-a-custom-sdk-controller). + +Custom SDK controllers have to extend the `BaseController` class to be added with the [Kuzzle.useController](/sdk/js/6/core-classes/kuzzle/use-controller) method. \ No newline at end of file diff --git a/doc/6/core-classes/base-controller/properties/index.md b/doc/6/core-classes/base-controller/properties/index.md new file mode 100644 index 000000000..d12d79117 --- /dev/null +++ b/doc/6/core-classes/base-controller/properties/index.md @@ -0,0 +1,16 @@ +--- +code: true +type: page +title: Properties +description: BaseController Properties +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | --------------------------------------- | +| `name` |
string
| Controller name | +| `kuzzle` | [`Kuzzle`](/sdk/js/6/core-classes/kuzzle/constructor) | Kuzzle SDK instance | + +**Note:** + - The `name` property will be injected in the request sent by the [BaseController.query](/sdk/js/6/core-classes/base-controller/query) method if the `controller` property is not set. \ No newline at end of file diff --git a/doc/6/core-classes/base-controller/query/index.md b/doc/6/core-classes/base-controller/query/index.md new file mode 100644 index 000000000..db26f4c75 --- /dev/null +++ b/doc/6/core-classes/base-controller/query/index.md @@ -0,0 +1,55 @@ +--- +code: true +type: page +title: query +description: Wrapper around the Kuzzle.query method +--- + +# query + +Base method used to send queries to a Kuzzle controller, following the [API Documentation](/core/1/api/essentials/connecting-to-kuzzle). + +This method injects the controller name into the the request and forwards it to the original [Kuzzle.query](/sdk/js/6/core-classes/kuzzle/query) method. + +## Arguments + +```js +query (request, [options]); +``` + +
+ +| Argument | Type | Description | +| -------------- | --------- | ------------- | +| `request` |
object
| API request | +| `options` |
object
| Optional query options | + +### request + +All properties necessary for the Kuzzle API can be added in the request object. +The following properties are the most common. + +| Property | Type | Description | +| -------------- | --------- | ------------- | +| `action` |
string
| Action name (required) | +| `controller` |
string
| Controller name | +| `body` |
object
| Query body for this action | +| `index` |
string
| Index name for this action | +| `collection` |
string
| Collection name for this action | +| `_id` |
string
| id for this action | +| `volatile` |
object
| Additional information to send to Kuzzle | + +**Note:** + - If the `controller` property is not set, the controller [name property](/sdk/js/6/core-classes/base-controller/properties) will be used + +### options + +Additional query options + +| Property | Type
(default) | Description | +| -------------- | --------- | ------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve to the raw Kuzzle API response. See the [API Documentation](/core/1/api/essentials/connecting-to-kuzzle). \ No newline at end of file diff --git a/doc/6/core-classes/index.md b/doc/6/core-classes/index.md index bc837b134..cb1e2bab9 100644 --- a/doc/6/core-classes/index.md +++ b/doc/6/core-classes/index.md @@ -1,7 +1,7 @@ --- code: false type: branch -order: 100 +order: 200 title: Core Classes description: Javascript SDK v6.x core classes --- diff --git a/doc/6/core-classes/kuzzle-error/introduction/index.md b/doc/6/core-classes/kuzzle-error/introduction/index.md index a53f48e11..0f86b1a99 100644 --- a/doc/6/core-classes/kuzzle-error/introduction/index.md +++ b/doc/6/core-classes/kuzzle-error/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: KuzzleError object @@ -10,14 +10,4 @@ order: 0 Inherits from the standard `Error` class. -The KuzzleError class represents an [error response from Kuzzle API](/core/1/api/essentials/errors/). - -## Properties - -Available properties. - -| Property name | Type | Description | -| ------------- | ----------------- | ------------------------------------------- | -| `message` |
string
| Error message | -| `status` |
number
| Error status code | -| `stack` |
string
| Error stacktrace (only in development mode) | +The KuzzleError class represents an [error response from Kuzzle API](/core/1/api/essentials/errors/). \ No newline at end of file diff --git a/doc/6/core-classes/kuzzle-error/properties/index.md b/doc/6/core-classes/kuzzle-error/properties/index.md new file mode 100644 index 000000000..1b5655e92 --- /dev/null +++ b/doc/6/core-classes/kuzzle-error/properties/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: Properties +description: KuzzleError Properties +order: 10 +--- + + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | --------------------------------------- | +| `message` |
string
| Error message | +| `status` |
number
| Error status code | +| `stack` |
string
| Error stacktrace (only in development mode) | diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md new file mode 100644 index 000000000..8d673ae28 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md @@ -0,0 +1,32 @@ +--- +code: true +type: page +title: addListener +description: Adds a new listener for an event +--- + +# addListener + +Adds a listener function to the end of the listeners array for an event. +Whenever an event is triggered, listener functions are called in the order they were registered. + +## Arguments + +```js +addListener (eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ---------- | -------- | -------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call every time the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/add-listener.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js new file mode 100644 index 000000000..b98d6e0be --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js @@ -0,0 +1,6 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent"!')); + +// Prints: Caught event "myEvent"! +eventEmitter.emit('myEvent'); diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml new file mode 100644 index 000000000..32d033093 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#add-listener +description: Adds new listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Caught event "myEvent"! +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md b/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md index dc2102834..7e3981199 100644 --- a/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md +++ b/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: KuzzleEventEmitter class @@ -12,7 +12,7 @@ A portable implementation of the Node.js `EventEmitter` interface. There are several classes extending `KuzzleEventEmitter` in the SDK: -- [Kuzzle](/sdk/js/6/kuzzle) -- [WebSocket](/sdk/js/6/websocket) -- [Http](/sdk/js/6/http) -- [SocketIO](/sdk/js/6/socketio) +- [Kuzzle](/sdk/js/6/core-classes/kuzzle) +- [WebSocket](/sdk/js/6/protocols/websocket) +- [Http](/sdk/js/6/protocols/http) +- [SocketIO](/sdk/js/6/protocols/socketio) diff --git a/doc/6/core-classes/kuzzle-event-emitter/on/index.md b/doc/6/core-classes/kuzzle-event-emitter/on/index.md index 828d20535..2d76aa56c 100644 --- a/doc/6/core-classes/kuzzle-event-emitter/on/index.md +++ b/doc/6/core-classes/kuzzle-event-emitter/on/index.md @@ -7,4 +7,4 @@ description: Alias for addListener # on -Alias for [addListener](/sdk/js/6/core-classes/kuzzle-event-emitteradd-listener/). +Alias for [addListener](https://nodejs.org/api/events.html#events_emitter_addlistener_eventname_listener). diff --git a/doc/6/core-classes/kuzzle-event-emitter/once/index.md b/doc/6/core-classes/kuzzle-event-emitter/once/index.md index 79f84e55d..ca3e6b4b3 100644 --- a/doc/6/core-classes/kuzzle-event-emitter/once/index.md +++ b/doc/6/core-classes/kuzzle-event-emitter/once/index.md @@ -7,4 +7,4 @@ description: Alias for addOnceListener # once -Alias for [addOnceListener](/sdk/js/6/core-classes/kuzzle-event-emitteradd-once-listener/). +Alias for [addOnceListener](/sdk/js/6/core-classes/kuzzle-event-emitter/add-once-listener/). diff --git a/doc/6/core-classes/kuzzle/add-listener/index.md b/doc/6/core-classes/kuzzle/add-listener/index.md deleted file mode 100644 index 9c14a22a7..000000000 --- a/doc/6/core-classes/kuzzle/add-listener/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -code: true -type: page -title: addListener -description: Add a listener to an event ---- - -# addListener - -Adds a listener function to the end of the listeners array for an event. -Whenever an event is triggered, listener functions are called in the order they were registered. - -## Arguments - -```javascript -addListener(event, callback); -``` - -
- -| Argument | Type | Description | -| ---------- | ------------------- | ------------------------------------------------------------------------------------------ | -| `event` |
string
| One of the event described in the [Events](/sdk/js/6/events) section of this documentation | -| `callback` |
function
| The function to call every time the event is triggered | - -## Return - -The `Kuzzle` instance. - -## Usage - -<<< ./snippets/add-listener.js diff --git a/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.js b/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.js deleted file mode 100644 index 925da4259..000000000 --- a/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.js +++ /dev/null @@ -1,9 +0,0 @@ -try { - kuzzle - .addListener('connected', () => console.log('You are connected')) - .addListener('connected', () => console.log('I already told you')); - - console.log('Success'); -} catch (error) { - console.error(error); -} diff --git a/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml b/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml deleted file mode 100644 index 2ba3a0a70..000000000 --- a/doc/6/core-classes/kuzzle/add-listener/snippets/add-listener.test.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: kuzzle#addListener -description: Add a listener to an event -hooks: - before: - after: -template: without-connect -expected: Success - -sdk: js -version: 6 diff --git a/doc/6/core-classes/kuzzle/connect/index.md b/doc/6/core-classes/kuzzle/connect/index.md index 48e0a8fcb..ec8404a64 100644 --- a/doc/6/core-classes/kuzzle/connect/index.md +++ b/doc/6/core-classes/kuzzle/connect/index.md @@ -7,12 +7,12 @@ description: Connects the SDK to Kuzzle # connect -Connects to Kuzzle using the `host` property provided in the [constructor options](/sdk/js/6/core-classes/kuzzle/constructor/#arguments-default). +Connects to Kuzzle using the `host` property provided in the [constructor options](/sdk/js/6/core-classes/kuzzle/constructor/#arguments). Subsequent call have no effect if the SDK is already connected. ## Arguments -```javascript +```js connect(); ``` diff --git a/doc/6/core-classes/kuzzle/constructor/index.md b/doc/6/core-classes/kuzzle/constructor/index.md index 93a5dcf13..618fe9828 100644 --- a/doc/6/core-classes/kuzzle/constructor/index.md +++ b/doc/6/core-classes/kuzzle/constructor/index.md @@ -1,19 +1,19 @@ --- code: true type: page -title: Constructor +title: constructor description: Creates a new Kuzzle object connected to the backend order: 50 --- # Constructor -Use this constructor to create a new instance of the SDK. +Use this constructor to create a new instance of the SDK. Each instance represent a different connection to a Kuzzle server with specific options. ## Arguments -```javascript +```js Kuzzle(protocol, [options]); ``` @@ -26,12 +26,12 @@ Kuzzle(protocol, [options]); ### protocol -The protocol used to connect to the Kuzzle instance. +The protocol used to connect to the Kuzzle instance. It can be one of the following available protocols: -- [WebSocket](/sdk/js/6/websocket) -- [Http](/sdk/js/6/http) -- [SocketIO](/sdk/js/6/socketio) +- [WebSocket](/sdk/js/6/protocols/websocket) +- [Http](/sdk/js/6/protocols/http) +- [SocketIO](/sdk/js/6/protocols/socketio) ### options diff --git a/doc/6/core-classes/kuzzle/disconnect/index.md b/doc/6/core-classes/kuzzle/disconnect/index.md index 594aa0faa..896ab0e0b 100644 --- a/doc/6/core-classes/kuzzle/disconnect/index.md +++ b/doc/6/core-classes/kuzzle/disconnect/index.md @@ -13,7 +13,7 @@ A call to `disconnect()` will not trigger a `disconnected` event. This event is ## Arguments -```javascript +```js disconnect(); ``` diff --git a/doc/6/core-classes/kuzzle/flush-queue/index.md b/doc/6/core-classes/kuzzle/flush-queue/index.md index e2ecad867..9245cf5f6 100644 --- a/doc/6/core-classes/kuzzle/flush-queue/index.md +++ b/doc/6/core-classes/kuzzle/flush-queue/index.md @@ -11,7 +11,7 @@ Empties the offline request queue without playing it. ## Arguments -```javascript +```js flushQueue(); ``` diff --git a/doc/6/core-classes/kuzzle/index.md b/doc/6/core-classes/kuzzle/index.md index 83d60da5d..81ec30a82 100644 --- a/doc/6/core-classes/kuzzle/index.md +++ b/doc/6/core-classes/kuzzle/index.md @@ -3,5 +3,5 @@ code: true type: branch title: Kuzzle description: Kuzzle object documentation -order: 500 +order: 510 --- diff --git a/doc/6/core-classes/kuzzle/introduction/index.md b/doc/6/core-classes/kuzzle/introduction/index.md index 1df558d3b..eeb4b1549 100644 --- a/doc/6/core-classes/kuzzle/introduction/index.md +++ b/doc/6/core-classes/kuzzle/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: Kuzzle object @@ -8,15 +8,15 @@ order: 0 # Kuzzle -Inherits from: [KuzzleEventEmitter](/sdk/js/6/kuzzle-event-emitter). +Inherits from: [KuzzleEventEmitter](/sdk/js/6/core-classes/kuzzle-event-emitter). -The Kuzzle class is the main class of the SDK. +The Kuzzle class is the main class of the SDK. Once instantiated, it represents a connection to your Kuzzle server. It gives access to the different features of the SDKs: - access to the available controllers -- [SDK events](/sdk/cpp/1/events) handling +- [SDK events](/sdk/cpp/1/essentials/events) handling - resilience to connection loss - network request queue management @@ -26,78 +26,12 @@ Each instance of the class communicates with the Kuzzle server through a class r The following protocols are available in the SDK JS 6: -- [WebSocket](/sdk/js/6/websocket) -- [Http](/sdk/js/6/http) -- [SocketIO](/sdk/js/6/socketio) +- [WebSocket](/sdk/js/6/protocols/websocket) +- [Http](/sdk/js/6/protocols/http) +- [SocketIO](/sdk/js/6/protocols/socketio) ## Volatile data You can tell the Kuzzle SDK to attach a set of "volatile" data to each request. You can set it as an object contained in the `volatile` field of the Kuzzle constructor. The response to a request containing volatile data will contain the same data in its `volatile` field. This can be useful, for example, in real-time notifications for [user join/leave notifications](/core/1/api/essentials/volatile-data/) to provide additional informations about the client who sent the request. -Note that you can also set volatile data on a per-request basis (on requests that accept a `volatile` field in their `options` argument). In this case, per-request volatile data will be merged with the global `volatile` object set in the constructor. Per-request fields will override global ones. - -## Properties - -Available properties. - -| Property name | Type | Description | Writable? | -| -------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------- | :-------: | -| `autoQueue` |
boolean
| Automatically queue all requests during offline mode | Yes | -| `autoReplay` |
boolean
| Automatically replay queued requests on a `reconnected` event | Yes | -| `autoResubscribe` |
boolean
| Automatically renew all subscriptions on a `reconnected` event | Yes | -| `jwt` |
string
| Token used in requests for authentication | Yes | -| `offlineQueue` |
object[]
| Contains the queued requests during offline mode | No | -| `offlineQueueLoader` |
function
| Called before dequeuing requests after exiting offline mode,
to add items at the beginning of the offline queue | Yes | -| `protocol` |
Protocol
| Protocol used by the SDK | No | -| `queueFilter` |
function
| Called during offline mode.
Takes a request object as arguments and returns a boolean, indicating if a request can be queued | Yes | -| `queueMaxSize` |
number
| Number of maximum requests kept during offline mode | Yes | -| `queueTTL` |
number
| Time a queued request is kept during offline mode, in milliseconds | Yes | -| `replayInterval` |
number
| Delay between each replayed requests | Yes | -| `volatile` |
object
| Common volatile data, will be sent to all future requests | Yes | - -### offlineQueueLoader - -The `offlineQueueLoader` property must be set with a function of one of the following formats: - -```js -Object[] offlineQueueLoader() - -Promise offlineQueueLoader() -``` - -The returned (or resolved) array must contain objects, each with the following properties: - -| Property | Type | Description | -| --------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -| `query` |
object
| Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format | -| `reject` |
function
| A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function | -| `resolve` |
function
| A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function | - -### queueFilter - -The `queueFilter` property must be set with a function of the following form: - -```js -boolean queueFilter(request) -``` - -The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format. - -### queueMaxSize - -This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue. - -This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests. - -If `queueMaxSize` is set to a number lower than, or equal to `0`, then an unlimited number of requests is kept in the offline buffer. -Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory. - -### queueTTL - -If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely. - -### volatile - -Multiple methods allow passing specific `volatile` data. - -These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones. +Note that you can also set volatile data on a per-request basis (on requests that accept a `volatile` field in their `options` argument). In this case, per-request volatile data will be merged with the global `volatile` object set in the constructor. Per-request fields will override global ones. \ No newline at end of file diff --git a/doc/6/core-classes/kuzzle/play-queue/index.md b/doc/6/core-classes/kuzzle/play-queue/index.md index 62296de57..f614b16ca 100644 --- a/doc/6/core-classes/kuzzle/play-queue/index.md +++ b/doc/6/core-classes/kuzzle/play-queue/index.md @@ -12,7 +12,7 @@ Works only if the SDK is not in a `offline` state, and if the `autoReplay` optio ## Arguments -```javascript +```js playQueue(); ``` diff --git a/doc/6/core-classes/kuzzle/properties/index.md b/doc/6/core-classes/kuzzle/properties/index.md new file mode 100644 index 000000000..81006cdec --- /dev/null +++ b/doc/6/core-classes/kuzzle/properties/index.md @@ -0,0 +1,86 @@ +--- +code: false +type: page +title: Properties +description: Kuzzle class properties +order: 10 +--- + +# Read-only properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `authenticated` |
boolean
| Returns `true` if the SDK holds a valid token | +| `connected` |
boolean
| Returns `true` if the SDK is currently connected to a Kuzzle server. | +| `offlineQueue` |
object[]
| Contains the queued requests during offline mode | +| `protocol` |
Protocol
| Protocol used by the SDK | + +### connected + +The `connected` property wraps the underlying protocol `connected` property. +See the associated documentation: + - [Http.connected](/sdk/js/6/protocols/http/properties) + - [WebSocket.connected](/sdk/js/6/protocols/websocket/properties) + - [SocketIO.connected](/sdk/js/6/protocols/socketio/properties) + +# Writable properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoQueue` |
boolean
| If `true`, automatically queues all requests during offline mode | +| `autoReplay` |
boolean
| If `true`, automatically replays queued requests on a `reconnected` event | +| `autoResubscribe` |
boolean
| If `true`, automatically renews all subscriptions on a `reconnected` event | +| `jwt` |
string
| Authentication token | +| `offlineQueueLoader` |
function
| Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue | +| `queueFilter` |
function
| Custom function called during offline mode to filter queued requests on-the-fly | +| `queueMaxSize` |
number
| Number of maximum requests kept during offline mode| +| `queueTTL` |
number
| Time a queued request is kept during offline mode, in milliseconds | +| `replayInterval` |
number
| Delay between each replayed requests | +| `volatile` |
object
| Common volatile data, will be sent to all future requests | + +### offlineQueueLoader + +The `offlineQueueLoader` property must be set with a function of one of the following formats: + +```js +Object[] offlineQueueLoader() + +Promise offlineQueueLoader() +``` + +The returned (or resolved) array must contain objects, each with the following properties: + +| Property | Type | Description | +|---|---|---| +| `query` |
object
| Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format | +| `reject` |
function
| A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function | +| `resolve` |
function
| A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function | + +### queueFilter + +The `queueFilter` property must be set with a function of the following form: + +```js +boolean queueFilter(request) +``` + +The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format. + +### queueMaxSize + +This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue. + +This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests. + +If `queueMaxSize` is set to a number lower than, or equal to `0`, then an unlimited number of requests is kept in the offline buffer. +Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory. + +### queueTTL + +If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely. + +### volatile + +Multiple methods allow passing specific `volatile` data. + +These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones. diff --git a/doc/6/core-classes/kuzzle/query/index.md b/doc/6/core-classes/kuzzle/query/index.md index 1c5885fae..be63f82a0 100644 --- a/doc/6/core-classes/kuzzle/query/index.md +++ b/doc/6/core-classes/kuzzle/query/index.md @@ -9,13 +9,13 @@ description: Base method to send API query to Kuzzle Base method used to send queries to Kuzzle, following the [API Documentation](/core/1/api). -
+:::warning This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods. -
+::: ## Arguments -```javascript +```js query(request, [options]); ``` @@ -23,7 +23,7 @@ query(request, [options]); | Argument | Type | Description | | --------- | ----------------- | ---------------------- | -| `request` |
object
| API request options | +| `request` |
object
| API request | | `options` |
object
| Optional query options | ### request diff --git a/doc/6/core-classes/kuzzle/start-queuing/index.md b/doc/6/core-classes/kuzzle/start-queuing/index.md index b8643668a..bc6899895 100644 --- a/doc/6/core-classes/kuzzle/start-queuing/index.md +++ b/doc/6/core-classes/kuzzle/start-queuing/index.md @@ -12,7 +12,7 @@ Works only in `offline` state, and if the `autoQueue` option is set to false. ## Arguments -```javascript +```js startQueuing(); ``` diff --git a/doc/6/core-classes/kuzzle/stop-queuing/index.md b/doc/6/core-classes/kuzzle/stop-queuing/index.md index b067de427..1cdb49faf 100644 --- a/doc/6/core-classes/kuzzle/stop-queuing/index.md +++ b/doc/6/core-classes/kuzzle/stop-queuing/index.md @@ -12,7 +12,7 @@ Works only in `offline` state, and if the `autoQueue` option is set to false. ## Arguments -```javascript +```js stopQueuing(); ``` diff --git a/doc/6/core-classes/kuzzle/use-controller/index.md b/doc/6/core-classes/kuzzle/use-controller/index.md new file mode 100644 index 000000000..e5fcbd2a0 --- /dev/null +++ b/doc/6/core-classes/kuzzle/use-controller/index.md @@ -0,0 +1,34 @@ +--- +code: true +type: page +title: useController +description: Adds a new controller to the SDK +--- + +# useController + +Adds a new controller to the SDK. + +*See also:* + - *[Extend the SDK](/sdk/js/6/essentials/extend-sdk)* + +## Arguments + +```js +useController (ControllerClass, accessor); +``` + +
+ +| Argument | Type | Description | +| -------------- | --------- | ------------- | +| `ControllerClass` |
Class
| Controller class. Must inherit from [BaseController](/sdk/js/6/core-classes/base-controller) | +| `accessor` |
string
| Accessor name for the controller in the Kuzzle object | + +## Returns + +Returns the Kuzzle object. + +## Usage + +<<< ./snippets/use-controller.js \ No newline at end of file diff --git a/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js new file mode 100644 index 000000000..c63c4f286 --- /dev/null +++ b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js @@ -0,0 +1,35 @@ +class TaxiController extends BaseController { + constructor (kuzzle) { + super(kuzzle, 'my-plugin/taxi'); + } + + enroll () { + return this.query({ + action: 'enroll' + }); + } +} + +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Add the custom SDK controller +kuzzle.useController(TaxiController, 'taxi'); + +const run = async () => { + try { + await kuzzle.connect(); + + // Call the custom SDK controller action + console.log(await kuzzle.taxi.enroll()); + + console.log('Success'); + } catch (error) { + console.error(error); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml new file mode 100644 index 000000000..f16fbf941 --- /dev/null +++ b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#useController +description: Adds a new controller to the SDK +hooks: + before: + after: +template: controller +expected: Success + +sdk: js +version: 6 \ No newline at end of file diff --git a/doc/6/core-classes/profile/getRoles/index.md b/doc/6/core-classes/profile/getRoles/index.md index a091c0a32..b0457e1ba 100644 --- a/doc/6/core-classes/profile/getRoles/index.md +++ b/doc/6/core-classes/profile/getRoles/index.md @@ -17,7 +17,7 @@ getRoles(); ## Resolve -Resolves to an array of [Role](/sdk/js/6/role). +Resolves to an array of [Role](/sdk/js/6/core-classes/role/). ## Usage diff --git a/doc/6/core-classes/profile/introduction/index.md b/doc/6/core-classes/profile/introduction/index.md index 27319490e..783f3a717 100644 --- a/doc/6/core-classes/profile/introduction/index.md +++ b/doc/6/core-classes/profile/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: Profile class @@ -10,20 +10,4 @@ order: 0 This class represents a Kuzzle Profile. -Refer to the [Security guide](/core/1/guide/guides/essentials/security/#defining-profiles-default) for more information about profiles. - -## Properties - -Available properties: - -| Property | Type | Description | -| ---------- | ------------------- | ---------------------------------- | -| `_id` |
string
| Profile ID | -| `policies` |
object[]
| Array of policies for this profile | - -Each policy object can contain the following properties: - -| Property | Type | Description | -| -------------- | ------------------- | ------------------------------------------------------------------------------------- | -| `roleId` |
string
| Roles IDs for this user | -| `restrictedTo` |
object[]
| Array of object containing indexes and collections which the profile is restricted to | +Refer to the [Security guide](/core/1/guides/essentials/security/#defining-profiles) for more information about profiles. diff --git a/doc/6/core-classes/profile/properties/index.md b/doc/6/core-classes/profile/properties/index.md new file mode 100644 index 000000000..c6dddc9eb --- /dev/null +++ b/doc/6/core-classes/profile/properties/index.md @@ -0,0 +1,23 @@ +--- +code: false +type: page +title: Properties +description: Profile Properties +order: 10 +--- + +# Properties + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Profile ID | +| `policies` |
object[]
| Array of policies for this profile | + +### policies + +Each policy object can contain the following properties: + +| Property | Type | Description | +|--- |--- |--- | +| `roleId` |
string
| Roles IDs for this user | +| `restrictedTo` |
object[]
| Array of object containing indexes and collections which the profile is restricted to | diff --git a/doc/6/core-classes/role/introduction/index.md b/doc/6/core-classes/role/introduction/index.md index 0ac949f4d..f1748eade 100644 --- a/doc/6/core-classes/role/introduction/index.md +++ b/doc/6/core-classes/role/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: Role class @@ -10,13 +10,4 @@ order: 0 This class represents a Kuzzle Role. -Refer to the [Security guide](/core/1/guide/guides/essentials/security/#defining-roles-default) for more information about roles. - -## Properties - -Available properties: - -| Property | Type | Description | -| ------------- | ----------------- | ---------------------------------------------------------- | -| `_id` |
string
| Role ID | -| `controllers` |
object
| Object defining controllers action available for this role | +Refer to the [Security guide](/core/1/guides/essentials/security/#defining-roles) for more information about roles. \ No newline at end of file diff --git a/doc/6/core-classes/role/properties/index.md b/doc/6/core-classes/role/properties/index.md new file mode 100644 index 000000000..c3fe42c7c --- /dev/null +++ b/doc/6/core-classes/role/properties/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: Properties +description: Role class properties +order: 10 +--- + +# Properties + +Available properties: + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Role unique identifier | +| `controllers` |
object
| Object defining controller actions allowed by this role | diff --git a/doc/6/core-classes/search-result/introduction/index.md b/doc/6/core-classes/search-result/introduction/index.md index 01fef966f..5690ee10d 100644 --- a/doc/6/core-classes/search-result/introduction/index.md +++ b/doc/6/core-classes/search-result/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: SearchResult class @@ -8,28 +8,8 @@ order: 0 # SearchResult -The class is used to retrieve the subsequent paginated results of a search query. +The class is used to retrieve the subsequent paginated results of a search query. The following methods returns a `SearchResult`: - [document:search](/sdk/js/6/controllers/document/search) -- [collection:searchSpecifications](/sdk/js/6/collection/search-specifications) - -## Properties - -Available properties. - -| Property | Type | Description | -| -------------- | ------------------- | ----------------------------------------------------------------- | -| `aggregations` |
object
| Search aggregations if any | -| `hits` |
object[]
| Array containing the retrieved items for the current page | -| `total` |
number
| Total number of items matching the given query in Kuzzle database | -| `fetched` |
number
| Number of retrieved items so far | -| `scroll_id` |
string
| Scroll identifier if the search was given a `scroll` parameter | - -Each object of the `hits` array contain the following properties: - -| Property | Type | Description | -| --------- | ----------------- | --------------------------------------------------------------------------------------------------- | -| `_id` |
string
| Document ID | -| `_score` |
number
| [Relevance score](https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html) | -| `_source` |
object
| Document content | +- [collection:searchSpecifications](/sdk/js/6/controllers/collection/search-specifications) diff --git a/doc/6/core-classes/search-result/next/index.md b/doc/6/core-classes/search-result/next/index.md index 34ae4afb1..ace94e5da 100644 --- a/doc/6/core-classes/search-result/next/index.md +++ b/doc/6/core-classes/search-result/next/index.md @@ -3,6 +3,7 @@ code: true type: page title: next description: SearchResult next method +order: 200 --- # SearchResult @@ -23,14 +24,11 @@ Depending on the arguments given to the initial search, thhe `next` method will If no policy is applicable, the `next` method will throw an exception. -
-

- When processing a large number of documents (i.e. more than 1000), it is advised to use a scroll cursor. -

-

- It is also the only method that garantees all matching documents will be retrieved and no duplicates will be included. -

-
+:::info +When processing a large number of documents (i.e. more than 1000), it is advised to use a scroll cursor. + +It is also the only method guaranteeing that all matching documents will be retrieved and no duplicates will be included. +::: ## Usage with scroll @@ -58,10 +56,8 @@ If the initial search is given some `from` and `size` parameters, the `next` met Because this method does not freeze the research between two calls, if some updates are applied to the database between two calls, it is possible to miss some documents and/or to get some duplicates between search pages. -
-

- NB: It is not possible to retrieve more than 10000 items using this method. Above that limit, any call to next will throw an Exception. -

-
+:::info +It is not possible to retrieve more than 10000 items using this method. Above that limit, any call to `next` will throw an Exception. +::: <<< ./snippets/fromsize.js diff --git a/doc/6/core-classes/search-result/properties/index.md b/doc/6/core-classes/search-result/properties/index.md new file mode 100644 index 000000000..d2cddde51 --- /dev/null +++ b/doc/6/core-classes/search-result/properties/index.md @@ -0,0 +1,27 @@ +--- +code: false +type: page +title: Properties +description: SearchResult class properties +order: 100 +--- + +# Properties + +| Property | Type | Description | +|--- |--- |--- | +| `aggregations` |
object
| Search aggregations if any | +| `hits` |
object[]
| Array containing the retrieved items for the current page | +| `total` |
number
| Total number of items matching the given query in Kuzzle database | +| `fetched` |
number
| Number of retrieved items so far | +| `scroll_id` |
string
| Scroll identifier if the search was given a `scroll` parameter | + +### hits + +Each object of the `hits` array contain the following properties: + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Document ID | +| `_score` |
number
| [Relevance score](https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html) | +| `_source` |
object
| Document content | diff --git a/doc/6/core-classes/user/getProfiles/index.md b/doc/6/core-classes/user/getProfiles/index.md index cb837c20c..87a9895ee 100644 --- a/doc/6/core-classes/user/getProfiles/index.md +++ b/doc/6/core-classes/user/getProfiles/index.md @@ -17,7 +17,7 @@ getProfiles(); ## Resolve -Resolves to an array of [Profile](/sdk/js/6/profile). +Resolves to an array of [Profile](/sdk/js/6/core-classes/profile). ## Usage diff --git a/doc/6/core-classes/user/introduction/index.md b/doc/6/core-classes/user/introduction/index.md index efe42528b..5bc9f6142 100644 --- a/doc/6/core-classes/user/introduction/index.md +++ b/doc/6/core-classes/user/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: User class @@ -10,25 +10,9 @@ order: 0 This class represents a Kuzzle User. -Refer to the [Security guide](/core/1/guide/guides/essentials/security/) for more information about users. +Refer to the [Security guide](/core/1/guides/essentials/security/) for more information about users. The following methods return a `User` object: - [auth:getCurrentUser](/sdk/js/6/controllers/auth/get-current-user) - [auth:updateSelf](/sdk/js/6/controllers/auth/update-self) - -## Properties - -Available properties: - -| Property | Type | Description | -| --------- | ----------------- | --------------------- | -| `_id` |
string
| User ID (kuid) | -| `content` |
object
| User internal content | - -The `content` property is an object containing generic properties alongside custom defined properties. - -| Property | Type | Description | -| -------------- | ------------------- | --------------------------------------------------------------------- | -| `profileIds` |
string[]
| Profiles IDs for this user | -| `_kuzzle_info` |
object
| [Kuzzle metadata](/core/1/guide/guides/essentials/document-metadata/) | diff --git a/doc/6/core-classes/user/properties/index.md b/doc/6/core-classes/user/properties/index.md new file mode 100644 index 000000000..f1995aa86 --- /dev/null +++ b/doc/6/core-classes/user/properties/index.md @@ -0,0 +1,24 @@ +--- +code: false +type: page +title: Properties +description: User class properties +order: 10 +--- + +# Properties + + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| User ID (kuid) | +| `content` |
object
| User internal content | + +### content + +The `content` property is an object containing, alongside custom defined values, the following generic properties: + +| Property | Type | Description | +|--- |--- |--- | +| `profileIds` |
string[]
| Profiles IDs for this user | +| `_kuzzle_info` |
object
| [Kuzzle metadata](/core/1/guides/essentials/document-metadata/) | diff --git a/doc/6/essentials/error-handling/index.md b/doc/6/essentials/error-handling/index.md index 7f3e5a713..31249dc23 100644 --- a/doc/6/essentials/error-handling/index.md +++ b/doc/6/essentials/error-handling/index.md @@ -10,7 +10,7 @@ order: 100 All SDK methods return a promise, that can be rejected with a `KuzzleError` value in case of failure. -[KuzzleError](/sdk/js/6/core-classes/kuzzle-errorintroduction/) objects inherit the standard `Error` object, and add the following properties to it: +[KuzzleError](/sdk/js/6/core-classes/kuzzle-error/introduction/) objects inherit the standard `Error` object, and add the following properties to it: | Property | Type | Description | | -------- | ----------------- | ------------------------------------------------------------------------------------------ | diff --git a/doc/6/essentials/events/index.md b/doc/6/essentials/events/index.md index 62548d82d..de31b9dda 100644 --- a/doc/6/essentials/events/index.md +++ b/doc/6/essentials/events/index.md @@ -8,9 +8,9 @@ order: 200 # Events -An event system allows to be notified when the SDK status changes. These events are issued by the [Kuzzle](/sdk/js/6/kuzzle) SDK object. +An event system allows to be notified when the SDK status changes. These events are issued by the [Kuzzle](/sdk/js/6/core-classes/kuzzle) SDK object. -The API for interacting with events is described by our [KuzzleEventEmitter](/sdk-reference/js/6/kuzzle-event-emitter) class documentation. +The API for interacting with events is described by our [KuzzleEventEmitter](/sdk/js/6/core-classes/kuzzle-event-emitter) class documentation. **Note:** listeners are called in the order of their insertion. diff --git a/doc/6/essentials/extend-sdk/index.md b/doc/6/essentials/extend-sdk/index.md index 1b381fe12..df7387ec8 100644 --- a/doc/6/essentials/extend-sdk/index.md +++ b/doc/6/essentials/extend-sdk/index.md @@ -10,25 +10,25 @@ order: 410 -It is possible to extend the SDK's API by adding new controllers. +It is possible to extend the SDK's API by adding new controllers. -These controllers correspond to [custom controllers created in a plugin](/plugins/1/essentials/controllers). Thus, it is possible to use the actions of a core plugin in the SDK in the same way as the other actions of the Kuzzle API. +These controllers correspond to [custom controllers created in a plugin](/core/1/plugins/guides/controllers). Thus, it is possible to use the actions of a core plugin in the SDK in the same way as the other actions of the Kuzzle API. ## Define a custom SDK controller -A custom SDK controller is a class inheriting from the [BaseController](/sdk-reference/js/6/base-controller) class and defining methods matching Kuzzle API actions. +A custom SDK controller is a class inheriting from the [BaseController](/sdk/js/6/core-classes/base-controller) class and defining methods matching Kuzzle API actions. -This base class is exposed alongside the other classes of the SDK module. +This base class is exposed alongside the other classes of the SDK module. -After defining your new controller based on `BaseController`, you can add it to the SDK with the [Kuzzle.useController](/sdk-reference/js/6/kuzzle/use-controller) method. +After defining your new controller based on `BaseController`, you can add it to the SDK with the [Kuzzle.useController](/sdk/js/6/core-classes/kuzzle/use-controller) method. ## Constructor -The constructor of a custom SDK controller will be called by passing the SDK instance to it. It must call the parent constructor with this instance of the SDK and its name as defined in the API. +The constructor of a custom SDK controller will be called by passing the SDK instance to it. It must call the parent constructor with this instance of the SDK and its name as defined in the API. For instance, if there is a plugin named `nyc-open-data-plugin`, extending Kuzzle's API with the following controller: -```javascript +```js this.controllers = { taxi: { startDuty: request => this.startDuty(request) @@ -36,9 +36,9 @@ this.controllers = { } ``` -Then the constructor of the custom SDK controller must specify its name as follows (see [how to query a custom API route](/plugins/1/essentials/controllers/#querying-plugins-controllers) documentation): +Then the constructor of the custom SDK controller must specify its name as follows (see [how to query a custom API route](/core/1/plugins/guides/controllers/#querying-plugins-controllers) documentation): -```javascript +```js const { BaseController } = require('kuzzle-sdk'); class TaxiController extends BaseController { @@ -48,17 +48,17 @@ class TaxiController extends BaseController { } ``` -The controller name will then be injected into the requests sent with the [BaseController.query](/sdk-reference/js/6/base-controller/query) method. +The controller name will then be injected into the requests sent with the [BaseController.query](/sdk/js/6/core-classes/base-controller/query) method. ## Define custom SDK controller actions -Each action of your custom SDK controller is a method of the class. +Each action of your custom SDK controller is a method of the class. -These methods have to use the [BaseController.query](/sdk-reference/js/6/base-controller/query) method to invoke an API action. +These methods have to use the [BaseController.query](/sdk/js/6/core-classes/base-controller/query) method to invoke an API action. Extending the previous example, we now have: -```javascript +```js const { BaseController } = require('kuzzle-sdk'); class TaxiController extends BaseController { @@ -82,13 +82,13 @@ class TaxiController extends BaseController { ## Add a custom SDK controller to the SDK -Once you have defined your custom SDK controller, you can add it to the SDK with the [Kuzzle.useController](/sdk-reference/js/6/kuzzle/use-controller) method. +Once you have defined your custom SDK controller, you can add it to the SDK with the [Kuzzle.useController](/sdk/js/6/core-classes/kuzzle/use-controller) method. -You can then use the actions of your plugins in the same way as the rest of the Kuzzle API by taking advantage of authentication, offline mode management, etc. +You can then use the actions of your plugins in the same way as the rest of the Kuzzle API by taking advantage of authentication, offline mode management, etc. -```javascript -const +```js +const TaxiController = require('./taxiController'), { Kuzzle, WebSocket } = require('kuzzle-sdk'); diff --git a/doc/6/essentials/getting-started/index.md b/doc/6/essentials/getting-started/index.md deleted file mode 100644 index 7ea7b11d6..000000000 --- a/doc/6/essentials/getting-started/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -code: false -type: branch -title: Getting Started -description: Get started with the Javascript SDK -order: 0 ---- diff --git a/doc/6/essentials/getting-started/node-js/index.md b/doc/6/essentials/getting-started/node-js/index.md deleted file mode 100644 index 2ca8dae3c..000000000 --- a/doc/6/essentials/getting-started/node-js/index.md +++ /dev/null @@ -1,156 +0,0 @@ ---- -code: false -type: page -title: Node.js -description: Getting started with Kuzzle and Node.js -order: 100 ---- - -# Getting Started with Kuzzle and Node.js - -This tutorial explains you how to use **Kuzzle** with **Node.js** and the **Javascript SDK**. -It will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** about document creations. - -You are going to write an application that **stores** documents in Kuzzle Server and subscribe to **real time notifications** for each created document. - -To follow this tutorial, you must have a Kuzzle Server up and running. Follow these instructions if this is not already the case: [Running Kuzzle](/core/1/guide/guides/getting-started/running-kuzzle/). - -## Explore the SDK - -It's time to get started with the [Kuzzle Javascript SDK](/sdk/js/6). This section, explains you how to store a document and subscribe to notifications in Kuzzle using the Javascript SDK. - -Before proceeding, please make sure your system has **Node.js** version 8 or higher (
instructions here) installed. - -## Prepare your environment - -Create your playground directory and install the Javascript SDK from the command line using npm: - -```sh -mkdir "kuzzle-playground" -cd "kuzzle-playground" -npm install kuzzle-sdk -``` - -
-If you are performing a clean install you might get some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. -
- -Then, create an `init.js` file and start by adding the code below. -This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. - -<<< ./snippets/load-sdk.js - -
-Replace 'kuzzle' which is the Kuzzle server hostname with 'localhost' or the hostname where your Kuzzle server is running. -
- -Next, add a listener to be notified in case of a connection error: - -```javascript -kuzzle.on('networkError', error => { - console.error('Network Error: ', error); -}); -``` - -Then, connect the client to your Kuzzle server with the `connect()` method, afterwards you have to add the code that will access Kuzzle to create a new index 'nyc-open-data' and a new collection 'yellow-taxi' that you will use to store data later on. - -<<< ./snippets/prepare-db.js - -Your `init.js` file should now look like this: - -<<< ./snippets/init.js - -This code does the following: - -- loads the `Kuzzle SDK` from its NPM package -- creates an instance of the SDK -- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket -- creates the `nyc-open-data` index -- creates the `yellow-taxi` collection (within the `nyc-open-data` index), -- disconnects from Kuzzle after the collection is created or if an error occurs - -Run the code with Node.js: - -```bash -node init.js -``` - -The console should output the following message: - -```bash -nyc-open-data/yellow-taxi ready! -``` - -
-Congratulations! You are now ready to say Hello to the World! -
- -## Create your first "Hello World" document - -Create a `create.js` file with the following code: - -<<< ./snippets/create.js - -This code does the following: - -- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index -- logs a success message to the console if everything went fine -- logs an error message if any of the previous actions fails -- disconnects from Kuzzle after the document is created or if an error occurs - -Run the code with Node.js: - -```bash -node create.js -``` - -
-You have now successfully stored your first document into Kuzzle. Click here to see how you can use the - Kuzzle Admin Console to browse your collection and confirm that your document was saved. -
- -
-Having trouble? Get in touch with us on Gitter! We're happy to help. -
- -## Subscribe to realtime document notifications (pub/sub) - -Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the realtime notifications documentation). - -Let's get started. Create a `subscribe.js` file with the following code: - -<<< ./snippets/subscribe.js - -Run the code with Node.js: - -```bash -node subscribe.js -``` - -The `subscribe.js` program is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. - -Now in another terminal, launch the `create.js` file from the previous section. - -```bash -node create.js -``` - -This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages-default) sent to the `subscribe.js` program. -Check the `subscribe.js` terminal: a new message is printed everytime a document is created using the `create.js` code. - -```bash -New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. -``` - -
-Congratulations! You have just set up your first pub/sub communication! -
- -## Where do we go from here? - -Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: - -- discover what this SDK has to offer by browsing other sections of this documentation -- learn how to use Koncorde to create incredibly fine-grained and blazing-fast subscriptions -- learn how to perform a basic authentication -- follow our guide to learn how to manage users, and how to set up fine-grained access control diff --git a/doc/6/essentials/getting-started/node-js/snippets/create.js b/doc/6/essentials/getting-started/node-js/snippets/create.js deleted file mode 100644 index abd761b20..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/create.js +++ /dev/null @@ -1,39 +0,0 @@ -// Loads the Kuzzle SDK modules -const { - Kuzzle, - WebSocket -} = require('kuzzle-sdk'); - -// Instantiates a Kuzzle client with the WebSocket protocol -// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') -const kuzzle = new Kuzzle( - new WebSocket('kuzzle') -); - -// Adds a listener to detect connection problems -kuzzle.on('networkError', error => { - console.error('Network Error:', error); -}); - -const run = async () => { - try { - // Connects to the Kuzzle server - await kuzzle.connect(); - - // Creates a document - const driver = { - name: 'Sirkis', - birthday: '1959-06-22', - license: 'B' - }; - - await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); - console.log('New document successfully created!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; - -run(); diff --git a/doc/6/essentials/getting-started/node-js/snippets/create.test.yml b/doc/6/essentials/getting-started/node-js/snippets/create.test.yml deleted file mode 100644 index 910484f25..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/create.test.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: gettingstarted#nodejscreate -description: Creates a document -hooks: - before: | - curl -XPOST kuzzle:7512/nyc-open-data/_create - curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi - after: -template: empty -expected: New document successfully created! -sdk: js -version: 6 diff --git a/doc/6/essentials/getting-started/node-js/snippets/init.js b/doc/6/essentials/getting-started/node-js/snippets/init.js deleted file mode 100644 index fd0a31384..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/init.js +++ /dev/null @@ -1,37 +0,0 @@ -// Loads the Kuzzle SDK modules -const { - Kuzzle, - WebSocket -} = require('kuzzle-sdk'); - -// Instantiates a Kuzzle client with the WebSocket protocol -// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') -const kuzzle = new Kuzzle( - new WebSocket('kuzzle') -); - -// Adds a listener to detect connection problems -kuzzle.on('networkError', error => { - console.error('Network Error:', error); -}); - -const run = async () => { - try { - // Connects to the Kuzzle server - await kuzzle.connect(); - - // Creates an index - await kuzzle.index.create('nyc-open-data'); - - // Creates a collection - await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); - - console.log('nyc-open-data/yellow-taxi ready!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; - -run(); diff --git a/doc/6/essentials/getting-started/node-js/snippets/init.test.yml b/doc/6/essentials/getting-started/node-js/snippets/init.test.yml deleted file mode 100644 index 0e76545bc..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/init.test.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: gettingstarted#nodejsinit -description: Creates an index and a collection -hooks: - before: curl -X DELETE kuzzle:7512/nyc-open-data - after: -template: empty -expected: nyc-open-data/yellow-taxi ready! -sdk: js -version: 6 diff --git a/doc/6/essentials/getting-started/node-js/snippets/load-sdk.js b/doc/6/essentials/getting-started/node-js/snippets/load-sdk.js deleted file mode 100644 index ae17a9b0e..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/load-sdk.js +++ /dev/null @@ -1,9 +0,0 @@ -const { - Kuzzle, - WebSocket -} = require('kuzzle-sdk'); - -// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') -const kuzzle = new Kuzzle( - new WebSocket('kuzzle') -); diff --git a/doc/6/essentials/getting-started/node-js/snippets/load-sdk.test.yml b/doc/6/essentials/getting-started/node-js/snippets/load-sdk.test.yml deleted file mode 100644 index 0d32da204..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/load-sdk.test.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: gettingstarted#nodejsload -description: Load SDK -hooks: - before: - after: -template: empty -expected: Success -sdk: js -version: 6 diff --git a/doc/6/essentials/getting-started/node-js/snippets/prepare-db.js b/doc/6/essentials/getting-started/node-js/snippets/prepare-db.js deleted file mode 100644 index 2fb9b8410..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/prepare-db.js +++ /dev/null @@ -1,20 +0,0 @@ -const run = async () => { - try { - // Connects to the Kuzzle server - await kuzzle.connect(); - - // Creates an index - await kuzzle.index.create('nyc-open-data'); - - // Creates a collection - await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); - - console.log('nyc-open-data/yellow-taxi ready!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; - -run(); diff --git a/doc/6/essentials/getting-started/node-js/snippets/prepare-db.test.yml b/doc/6/essentials/getting-started/node-js/snippets/prepare-db.test.yml deleted file mode 100644 index e51b6f7ce..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/prepare-db.test.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: gettingstarted#nodejspreparedb -description: Prepare database -hooks: - before: curl -X DELETE kuzzle:7512/nyc-open-data - after: -template: blank -expected: nyc-open-data/yellow-taxi ready! -sdk: js -version: 6 diff --git a/doc/6/essentials/getting-started/node-js/snippets/subscribe.js b/doc/6/essentials/getting-started/node-js/snippets/subscribe.js deleted file mode 100644 index f85d66357..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/subscribe.js +++ /dev/null @@ -1,51 +0,0 @@ -// Loads the Kuzzle SDK modules -const { - Kuzzle, - WebSocket -} = require('kuzzle-sdk'); - -// Instantiates a Kuzzle client with the WebSocket protocol -// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') -const kuzzle = new Kuzzle( - new WebSocket('kuzzle') -); - -// Adds a listener to detect any connection problems -kuzzle.on('networkError', error => { - console.error('Network Error:', error); -}); - -const run = async () => { - try { - // Connects to the Kuzzle server - await kuzzle.connect(); - - // Defines a filter - const filter = { - equals: { license: 'B' } - }; - - // Defines a callback invoked each time a notification is received - const callback = (notification) => { - - if (notification.type === 'document' && notification.action === 'create') { - const { - _source: driver, - _id: driverId - } = notification.result; - - console.log(`New driver ${driver.name} with id ${driverId} has B license.`); - kuzzle.disconnect(); - } - }; - - // Subscribes to document notifications using the above filter - await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filter, callback); - - console.log('Successfully subscribed to document notifications!'); - } catch (error) { - console.error(error.message); - } -}; - -run(); diff --git a/doc/6/essentials/getting-started/node-js/snippets/subscribe.test.yml b/doc/6/essentials/getting-started/node-js/snippets/subscribe.test.yml deleted file mode 100644 index 5e6720558..000000000 --- a/doc/6/essentials/getting-started/node-js/snippets/subscribe.test.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: gettingstarted#nodejssubscribe -description: Subscribes to document notifications -hooks: - before: | - curl -XPOST kuzzle:7512/nyc-open-data/_create - curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi - after: -template: empty-realtime -expected: Successfully subscribed to document notifications! -sdk: js -version: 6 diff --git a/doc/6/essentials/getting-started/raw-web/index.md b/doc/6/essentials/getting-started/raw-web/index.md deleted file mode 100644 index c7d0c74a5..000000000 --- a/doc/6/essentials/getting-started/raw-web/index.md +++ /dev/null @@ -1,166 +0,0 @@ ---- -code: false -type: page -title: Browser (Vanilla) -description: Getting started with Kuzzle in the browser ---- - -# Getting Started with Kuzzle in the browser - -This tutorial explains how to use **Kuzzle** with the **Javascript SDK** in a **browser**. - -To follow this tutorial, you must have a Kuzzle Server up and running (you'll need to know the hostname of the machine running it). If this is not already the case, take a look at [how to run Kuzzle](/core/1/guide/guides/getting-started/running-kuzzle/). - -Before proceeding, make sure your system has **Node.js** version 8 or higher (instructions here) installed. - -In this tutorial, you'll learn how to **store** a document and **subscribe** to notifications in Kuzzle using the Javascript SDK. - -## Prepare your environment - -Create your playground directory: - -```sh -mkdir "kuzzle-playground" -cd "kuzzle-playground" -``` - -
-If you are performing a clean install you might get some UNMET PEER DEPENDENCY warnings, these are safe to ignore as they refer to optional dependencies. -
- -Then, create an `index.html` file with the following structure: - -```html - - - - - - Kuzzle SDK Playground - - - - - - - - -``` - -
-If you are using Internet Explorer (not Edge), you are responsible of installing a Promise polyfill, which enables IE to support -Javascript Promises. -Our advice is to use Bluebird, as shown in the code example above (refer to the commented lines in the head tag). -
- -Then, add the code below in the `body` tag. -This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. If an error occurs, it is displayed -in the console. Once the connection is established, a success message is displayed in the console. - -<<< ./snippets/load-sdk.js - -
-Replace kuzzle with localhost or the hostname where your Kuzzle server is running. -
- -Now you have to add the code that will access Kuzzle to create a new index `nyc-open-data` and a new collection `yellow-taxi` -that you will use to store data later on. Make sure the code inside your `body` tag looks like the following: - -<<< ./snippets/prepare-db.js - -Now, let's take a look at what your script is doing: - -- creates an instance of the SDK, -- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, -- creates the `nyc-open-data` index, -- creates the `yellow-taxi` collection (within the `nyc-open-data` index), -- disconnects from Kuzzle after the collection is created, -- displays an error whenever something goes wrong. - -Run this code by opening the `index.html` file in your favorite browser. -The console should output the following message: - -```plaintext -Successfully connected to Kuzzle -nyc-open-data/yellow-taxi ready! -``` - -
-Congratulations! You are now ready to say Hello to the World! -
- -
-If you reload the page, you should see an error in the console. This is OK, since Kuzzle is just refusing to create -the nyc-open-data index as it already exists. -
- -## Create your first "Hello World" document - -Create a `create.html` file with the same structure as `index.html` (see above). -And, right like before, add some code to the `body` tag: - -<<< ./snippets/create.js - -This code does the following: - -- creates an instance of the SDK, -- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, -- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index -- logs a success message to the console if everything went fine -- logs an error message if any of the previous actions fails -- disconnects from Kuzzle after the document is created or if an error occurs - -Run this code by opening the `create.html` file in your favorite browser. -The console should output the following message: - -``` -Successfully connected to Kuzzle -New document successfully created! -``` - -
-You have now successfully stored your first document into Kuzzle. Click here to see how you can use the Kuzzle Admin Console to browse your collection and confirm that your document was saved. -
- -
-Having trouble? Get in touch with us on Gitter! We're happy to help. -
- -## Subscribe to realtime document notifications (pub/sub) - -Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the realtime notifications documentation). - -Let's get started. Create a `subscribe.html` file (same structure as above) with the following code in the `body` tag: - -<<< ./snippets/subscribe.js - -Run this code by opening the `subscribe.html` file in a new tab, leaving the previous one (showing `create.html`) open. -The console should output the following message: - -``` -Successfully connected to Kuzzle -Successfully subscribed to document notifications! -``` - -The code in the `subscribe.html` page is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. - -Now go back to the other tab and reload `create.html`. - -This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages-default) sent to the `subscribe.html` tab. Check the `subscribe.html` tab: a new message is printed everytime a document is created using the `create.html` code. - -``` -New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. -``` - -
-Congratulations! You have just set up your first pub/sub communication! -
- -## Where do we go from here? - -Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: - -- discover what this SDK has to offer by browsing other sections of this documentation -- learn how to use Koncorde to create incredibly fine-grained and blazing-fast subscriptions -- learn how to perform a basic authentication -- follow our guide to learn how to manage users, and how to set up fine-grained access control diff --git a/doc/6/essentials/getting-started/raw-web/snippets/create.html b/doc/6/essentials/getting-started/raw-web/snippets/create.html deleted file mode 100644 index 70aee4f09..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/create.html +++ /dev/null @@ -1,31 +0,0 @@ - diff --git a/doc/6/essentials/getting-started/raw-web/snippets/create.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/create.test.yml deleted file mode 100644 index 557868de8..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/create.test.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: gettingstarted#browservanillacreate -description: Create a document -hooks: - before: | - curl -XPOST kuzzle:7512/nyc-open-data/_create - curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi - after: -template: default -expected: New document successfully created -sdk: js -version: 6 -runner: web diff --git a/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.html b/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.html deleted file mode 100644 index 10d2477d1..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.html +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.test.yml deleted file mode 100644 index c17ef17d8..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/load-sdk.test.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: gettingstarted#browservanillaconnect -description: Connect to Kuzzle -hooks: - before: - after: -template: default -expected: Successfully connected to Kuzzle -sdk: js -version: 6 -runner: web diff --git a/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.html b/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.html deleted file mode 100644 index c392a86b4..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.html +++ /dev/null @@ -1,29 +0,0 @@ - \ No newline at end of file diff --git a/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.test.yml deleted file mode 100644 index 3ac1c5a75..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/prepare-db.test.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: gettingstarted#browservanillaprepare -description: Prepare the database -hooks: - before: curl -X DELETE kuzzle:7512/nyc-open-data - after: -template: default -expected: nyc-open-data/yellow-taxi ready -sdk: js -version: 6 -runner: web diff --git a/doc/6/essentials/getting-started/raw-web/snippets/subscribe.html b/doc/6/essentials/getting-started/raw-web/snippets/subscribe.html deleted file mode 100644 index ec6c858ab..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/subscribe.html +++ /dev/null @@ -1,32 +0,0 @@ - \ No newline at end of file diff --git a/doc/6/essentials/getting-started/raw-web/snippets/subscribe.test.yml b/doc/6/essentials/getting-started/raw-web/snippets/subscribe.test.yml deleted file mode 100644 index 2fad572cd..000000000 --- a/doc/6/essentials/getting-started/raw-web/snippets/subscribe.test.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: gettingstarted#browservanillasubscribe -description: Subscribe to notifications -hooks: - before: | - curl -XPOST kuzzle:7512/nyc-open-data/_create - curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi - after: -template: default -expected: Successfully subscribed to document notifications -sdk: js -version: 6 -runner: web diff --git a/doc/6/essentials/getting-started/webpack/index.md b/doc/6/essentials/getting-started/webpack/index.md deleted file mode 100644 index fefe62f78..000000000 --- a/doc/6/essentials/getting-started/webpack/index.md +++ /dev/null @@ -1,233 +0,0 @@ ---- -type: page -code: false -title: Webpack -description: Getting started with Kuzzle and Webpack ---- - -# Getting Started with Kuzzle and Webpack - -In this tutorial you will learn how to install, run and use **Kuzzle** with the **Javascript SDK** in the browser using **Webpack**. -We will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** for each new document created. - -## Running Kuzzle - -Before going through this tutorial, you should have a Kuzzle server running. Please refer to the [Running Kuzzle Tutorial](https://docs.kuzzle.io/core/1/guide/guides/getting-started/running-kuzzle/) if you don't have one yet. - -## Fun with the SDK - -It's time to play with the [Kuzzle Javscript SDK](/sdk/js/6). In this section, we will store a document and subscribe to notifications in Kuzzle using the Javascript SDK in your browser. - -Before proceeding, please make sure your system has **Node.js** version 8 or higher (instructions here) installed. - -## Including the Kuzzle SDK in a Webpack project - -
- This section explains how to use the Kuzzle SDK within an existing Webpack project. - If you don't have your project up and running yet and want to learn how to leverage Webpack to build it, please refer to - the official Webpack Getting Started page. -
- -In your terminal, go to the root of your front-end project using Webpack and type - -```bash -npm install kuzzle-sdk -``` - -
-If you are performing a clean install you might see some unmet peer dependency warnings, these are safe to ignore as they refer to optional dependencies. -
- -Then, create a `init-kuzzle.js` file and start by adding the code below. This will load the Kuzzle Javascript SDK: - -```javascript -import { Kuzzle, WebSocket } from 'kuzzle-sdk'; -``` - -Next, we instantiate a client that will connect to Kuzzle via WebSocket. If Kuzzle is not running on localhost, replace it with the corresponding server name or IP address. - -```javascript -const kuzzle = new Kuzzle(new WebSocket('localhost')); -``` - -Next we add a listener to be notified in case of a connection error: - -```javascript -kuzzle.on('networkError', error => { - console.error(`Network Error: ${error}`); -}); -``` - -Then we have to connect our web app to the Kuzzle server with the `connect()` method. - -```javascript -const run = async () => { - try { - // Connect to Kuzzle server - await kuzzle.connect(); - - // Some more things will go here... - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; -``` - -Finally, we will create a new index `nyc-open-data` and a new collection -`yellow-taxi` that we will use to store data later on. - -```javascript -const run = async () => { - try { - // Connect to Kuzzle server - await kuzzle.connect(); - - // Create an index - await kuzzle.index.create('nyc-open-data'); - // Create a collection - await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); - console.log('nyc-open-data/yellow-taxi ready!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; -``` - -Your `kuzzle-init.js` file should now look like this: - -<<< ./snippets/init-kuzzle.js - -This code does the following: - -- loads the `kuzzle-sdk` from its NPM package -- creates an instance of the SDK -- connects it to Kuzzle running on `localhost` with the `WebSocket` protocol -- creates the `nyc-open-data` index -- creates the `yellow-taxi` collection (within the `nyc-open-data` index), -- disconnects from Kuzzle after the collection is created or if an error occurs - -Now, to have your script up and running, require it somewhere in your application -(e.g. your main entry point) and launch it. - -```javascript -require('../path/to/init-kuzzle.js'); -``` - -Your console should output the following message: - -``` -nyc-open-data/yellow-taxi ready! -``` - -
-Congratulations! You are now ready to say Hello to the World! -
- -
-Having trouble? Get in touch with us on Gitter! We're happy to help. -
- -## Create your first document - -Create a `create.js` file with following code: - -<<< ./snippets/create.js - -This code does the following: - -- creates a new document in `nyc-open-data` within the `yellow-taxi` index -- logs a success message to the console if everything went fine -- logs an error message if any of the previous actions failed -- disconnects from Kuzzle after the document is created or if an error occurs - -To activate this code, create a button somewhere in your page like the following - -```html - -``` - -Then, associate it to the `create` function by adding this code to your application - -```javascript -const create = require('../path/to/create.js'); - -// This is the most "vanilla" way to call a function in reaction to a click, -// if you're using a front-end framework like Vuejs, React or jQuery, feel free -// to follow any convenience method it provides for this purpose. -document.querySelector('#create-document-btn').addListener('click', event => { - create(); -}); -``` - -Now, click the button and check your console for a message like the following: - -```bash -New document successfully created! -``` - -
- You have now successfully stored your first document into Kuzzle. Click - here to see how you can use the - Kuzzle Admin Console to browse your collection and - confirm that your document was saved. -
- -
-Having trouble? Get in touch with us on Gitter! We're happy to help. -
- -## Subscribe to realtime document notifications (pub/sub) - -Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the realtime notifications documentation). - -Let's get started. Create a `subscribe.js` file with following code: - -<<< ./snippets/subscribe.js - -This code does the following: - -- loads the `Kuzzle SDK` from its NPM package -- creates an instance of the SDK -- connects it to Kuzzle running on `localhost` with the `websocket` protocol -- defines a filter for the subscription to be done later (drivers with "B" license) -- defines a callback that will be called whenever a notification is received from Kuzzle (print driver name to console) -- subscribes for notifications on the `yellow-taxi` collection - -You can execute this code in the same page as before or in another page of your app. Whatever option you choose, to -execute the code, you just need to require it in your page - -```javascript -require('../path/to/subscribe.js'); -``` - -From now on, whenever you click the button we created before, Kuzzle will send a notification to the page containing -the subscription to the `yellow-taxi` collection. In the console corresponding to this page, you should see the following message: - -```bash -New driver Sirkis with id has B license. -``` - -In place of `` you'll see the ID that Kuzzle automatically generated for the document. - -
-Congratulations! You have just choreographed your first pub/sub pattern! -
- -
-Having trouble? Get in touch with us on Gitter! We're happy to help. -
- -## Where do we go from here? - -Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: - -- take a look at the SDK Reference -- learn how to use Koncorde to create incredibly fine-grained and blazing-fast subscriptions -- follow our guide to learn how to implement basic authentication -- follow our guide to learn how to implement manage users and setup fine-grained access control diff --git a/doc/6/essentials/getting-started/webpack/snippets/create.js b/doc/6/essentials/getting-started/webpack/snippets/create.js deleted file mode 100644 index fe66ca6b5..000000000 --- a/doc/6/essentials/getting-started/webpack/snippets/create.js +++ /dev/null @@ -1,33 +0,0 @@ -// load the Kuzzle SDK module -import { Kuzzle, WebSocket } from 'kuzzle-sdk'; - -// instantiate a Kuzzle client -const kuzzle = new Kuzzle(new WebSocket('kuzzle')); - -// add a listener to detect any connection problems -kuzzle.on('networkError', error => { - console.error(`Network Error: ${error}`); -}); - -const doIt = async () => { - try { - // Connect to Kuzzle server - await kuzzle.connect(); - - // Create your document - const driver = { - name: 'Sirkis', - birthday: '1959-06-22', - license: 'B' - }; - - await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); - console.log('New document successfully created!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; - -export default doIt; diff --git a/doc/6/essentials/getting-started/webpack/snippets/create.test.yml b/doc/6/essentials/getting-started/webpack/snippets/create.test.yml deleted file mode 100644 index fb4561210..000000000 --- a/doc/6/essentials/getting-started/webpack/snippets/create.test.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: gettingstarted#webpackcreate -description: Creates a document -hooks: - before: | - curl -XPOST kuzzle:7512/nyc-open-data/_create - curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi - after: -template: doIt -expected: New document successfully created! - -runner: webpack -sdk: js -version: 6 diff --git a/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.js b/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.js deleted file mode 100644 index 49068c155..000000000 --- a/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.js +++ /dev/null @@ -1,30 +0,0 @@ -// load the Kuzzle SDK module -import { Kuzzle, WebSocket } from 'kuzzle-sdk'; - -// instantiate a Kuzzle client -const kuzzle = new Kuzzle(new WebSocket('kuzzle')); - -// add a listener to detect any connection problems -kuzzle.on('networkError', error => { - console.error(`Network Error: ${error}`); -}); - -const run = async () => { - try { - // Connect to Kuzzle server - await kuzzle.connect(); - - // Create an index - await kuzzle.index.create('nyc-open-data'); - - // Create a collection - await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); - console.log('nyc-open-data/yellow-taxi ready!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; - -run(); diff --git a/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml b/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml deleted file mode 100644 index cd2ff4589..000000000 --- a/doc/6/essentials/getting-started/webpack/snippets/init-kuzzle.test.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: gettingstarted#webpackinitkuzzle -description: Creates an index and a collection -hooks: - before: curl -X DELETE kuzzle:7512/nyc-open-data - after: -template: empty -expected: nyc-open-data/yellow-taxi ready! -sdk: js -version: 6 -runner: webpack diff --git a/doc/6/essentials/getting-started/webpack/snippets/subscribe.js b/doc/6/essentials/getting-started/webpack/snippets/subscribe.js deleted file mode 100644 index 892c99bcb..000000000 --- a/doc/6/essentials/getting-started/webpack/snippets/subscribe.js +++ /dev/null @@ -1,49 +0,0 @@ -// load the Kuzzle SDK module -import { Kuzzle, WebSocket } from 'kuzzle-sdk'; - -// instantiate a Kuzzle client -const kuzzle = new Kuzzle(new WebSocket('kuzzle')); - -// add a listener to detect any connection problems -kuzzle.on('networkError', error => { - console.error(`Network Error: ${error}`); -}); - -const doIt = async () => { - try { - // Connect to Kuzzle server - await kuzzle.connect(); - - // Define a filter - const filter = { - equals: { license: 'B' } - }; - - // Define a callback - const callback = notification => { - if ( - notification.type === 'document' && - notification.action === 'create' - ) { - const driver = notification.result._source; - const driverId = notification.result._id; - console.log( - `New driver ${driver.name} with id ${driverId} has B license.` - ); - } - }; - - // Subscribes to document notifications with our filter - await kuzzle.realtime.subscribe( - 'nyc-open-data', - 'yellow-taxi', - filter, - callback - ); - console.log('Successfully subscribed to document notifications!'); - } catch (error) { - console.error(error.message); - } -}; - -doIt(); diff --git a/doc/6/essentials/getting-started/webpack/snippets/subscribe.test.yml b/doc/6/essentials/getting-started/webpack/snippets/subscribe.test.yml deleted file mode 100644 index f62f51a44..000000000 --- a/doc/6/essentials/getting-started/webpack/snippets/subscribe.test.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: gettingstarted#webpacksubscribe -description: Subscribes to document notifications -hooks: - before: | - curl -XPOST kuzzle:7512/nyc-open-data/_create - curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi - after: -template: createDocumentAfterSnippet -expected: - - Successfully subscribed to document notifications! - - New driver Sirkis with id -sdk: js -version: 6 -runner: webpack diff --git a/doc/6/essentials/index.md b/doc/6/essentials/index.md index cfad2d95d..41c639b95 100644 --- a/doc/6/essentials/index.md +++ b/doc/6/essentials/index.md @@ -1,7 +1,7 @@ --- code: false type: branch -order: 0 +order: 100 title: Essentials description: Javascript SDK v6.x essential notions --- diff --git a/doc/6/essentials/offline-tools/index.md b/doc/6/essentials/offline-tools/index.md index 411536c0b..a77c60213 100644 --- a/doc/6/essentials/offline-tools/index.md +++ b/doc/6/essentials/offline-tools/index.md @@ -8,69 +8,91 @@ order: 400 # Offline tools -The Kuzzle SDK provides a set of properties that help your application to be resilient to the loss of network connection +The Kuzzle SDK provides a set of properties that helps your application to be resilient to the loss of network connection during its lifespan. -## offlineQueue +## Contructor options and properties -A read-only `Array` containing the requests queued while the SDK is in the `offline` state (it behaves like a FIFO queue). +These properties can be set in the `options` object when [instantiating a new SDK](/sdk/js/6/core-classes/kuzzle/constructor/#arguments). -## queueMaxSize +Some of them are also [writable properties](/sdk/js/6/core-classes/kuzzle/properties) available after SDK instantiation. -A writable `number` defining the maximun size of the `offlineQueue`. +### autoQueue -## queueTTL +A writable `boolean` telling the SDK whether to automatically queue requests during the `offline` state or not. -A writable `number` defining the time in milliseconds a queued request is kept in the `offlineQueue`. +Default value: `false` -## startQueuing() +### autoReconnect -Starts queuing requests when in `offline` state. Request will be put in the `offlineQueue` instead of being discarded, until `stopQueuing` is called. -Works only in `offline` state when the `autoQueue` option is set to `false`. Call `playQueue` to send to Kuzzle the -requests in the queue, once the SDK state passes to `online`. Call `flushQueue` to empty the queue without sending the requests. +A writable `boolean` telling the SDK whether to automatically reconnect or not to Kuzzle after a connection loss. -## stopQueuing() +Default value: *Depends on the Protocol* -Stop queuing the requests. Requests will no more be put in the `offlineQueue`, they will be discarded. -Works only in the `offline` state, and if the `autoQueue` option is set to `false`. +### autoReplay -## playQueue() +A writable `boolean` telling the SDK whether to automatically send or not the requests in the `offlineQueue` on a +`reconnected` event. -Sends to Kuzzle all the requests in the `offlineQueue`. Works only if the SDK is not in a `offline` state, and if the -`autoReplay` option is set to false. +Default value: `false` -## flushQueue() +### autoResubscribe -Empties the `offlineQueue` without sending the requests to Kuzzle. +A writable `boolean` telling the SDK whether to automatically renew or not all subscriptions on a reconnected event. -## autoQueue +Default value: `true` -A writable `boolean` telling the SDK whether to automatically queue requests during the `offline` state or not. +### offlineQueue -## autoReplay +A read-only `Array` containing the requests queued while the SDK is in the `offline` state (it behaves like a FIFO queue). -A writable `boolean` telling the SDK whether to automatically send or not the requests in the `offlineQueue` on a -`reconnected` event. +### offlineQueueLoader -## autoReconnect +A writable `Function` called by the SDK before playing the requests in the `offlineQueue`. This function takes no arguments +and returns an array of `Request` that are added on top of the `offlineQueue`. Use it to inject new requests to be played +before the queue. -A writable `boolean` telling the SDK whether to automatically reconnect or not to Kuzzle after a connection loss. +### queueFilter + +A writable `Function` called by the SDK each time a `Request` need to be queued. The `Request` is passed as the only argument +to the function and is queued only if the function returns `true`. Use it to define which requests are allowed to be queued. -## reconnectionDelay +### queueMaxSize + +A writable `number` defining the maximun size of the `offlineQueue`. + +Default value: `500` + +### queueTTL + +A writable `number` defining the time in milliseconds a queued request is kept in the `offlineQueue`. + +Default value: `120000` + +### reconnectionDelay A read-only `number` specifying the time in milliseconds between different reconnection attempts. -## autoResubscribe +Default value: *Depends on the Protocol* -A writable `boolean` telling the SDK whether to automatically renew or not all subscriptions on a reconnected event. +## Methods -## queueFilter +### [flushQueue()](/sdk/js/6/core-classes/kuzzle/flush-queue) -A writable `Function` called by the SDK each time a `Request` need to be queued. The `Request` is passed as the only argument -to the function and is queued only if the function returns `true`. Use it to define which requests are allowed to be queued. +Empties the `offlineQueue` without sending the requests to Kuzzle. -## offlineQueueLoader +### [playQueue()](/sdk/js/6/core-classes/kuzzle/play-queue) -A writable `Function` called by the SDK before playing the requests in the `offlineQueue`. This function takes no arguments -and returns an array of `Request` that are added on top of the `offlineQueue`. Use it to inject new requests to be played -before the queue. +Sends to Kuzzle all the requests in the `offlineQueue`. Works only if the SDK is not in a `offline` state, and if the +`autoReplay` option is set to false. + +### [startQueuing()](/sdk/js/6/core-classes/kuzzle/start-queuing/) + +Starts queuing requests when in `offline` state. Requests will be put in the `offlineQueue` array instead of being discarded, until `stopQueuing` is called. +Works only in `offline` state when the `autoQueue` option is set to `false`. Call `playQueue` to send to Kuzzle the +requests in the queue, once the SDK state passes to `online`. Call `flushQueue` to empty the queue without sending the requests. + +### [stopQueuing()](/sdk/js/6/core-classes/kuzzle/stop-queuing) + +Stop queuing the requests. Requests will no more be put in the `offlineQueue`, they will be discarded. +Works only in the `offline` state, and if the `autoQueue` option is set to `false`. diff --git a/doc/6/essentials/realtime-notifications/index.md b/doc/6/essentials/realtime-notifications/index.md index 45d570203..a06b06aa0 100644 --- a/doc/6/essentials/realtime-notifications/index.md +++ b/doc/6/essentials/realtime-notifications/index.md @@ -12,7 +12,7 @@ The [realtime.subscribe](/sdk/js/6/controllers/realtime/) method takes a callbac ## Document & messages -These notifications represent [documents changes & messages](/core/1/api/essentials/notifications#documents-changes-messages-default). +These notifications represent [documents changes & messages](/core/1/api/essentials/notifications#documents-changes-messages). | Property | Type | Description | | ------------ | ----------------- | ----------------------------------------------------------------------------------------------------- | @@ -37,7 +37,7 @@ The `result` object is the notification content, and it has the following struct ## User -These notifications represent [user events](/core/1/api/essentials/notifications#user-events-default). +These notifications represent [user events](/core/1/api/essentials/notifications#user-notification). | Property | Type | Description | | ------------ | ----------------- | ----------------------------------------------------------------------------------------------------- | @@ -61,7 +61,7 @@ The `result` object is the notification content, and it has the following struct ## Server -These notifications represent [server events](/core/1/api/essentials/notifications#server-events-default). +These notifications represent [server events](/core/1/api/essentials/notifications#server-notification). | Property | Type | Value | | --------- | ----------------- | ------------------------------------------------------------------ | diff --git a/doc/6/getting-started/node-js/index.md b/doc/6/getting-started/node-js/index.md index 89a2fdc50..1c15138d8 100644 --- a/doc/6/getting-started/node-js/index.md +++ b/doc/6/getting-started/node-js/index.md @@ -152,6 +152,6 @@ Congratulations! You have just set up your first pub/sub communication! Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: - discover what this SDK has to offer by browsing other sections of this documentation -- learn how to use [Koncorde](/core/1/koncorde) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to use [Koncorde](/core/1/guides/cookbooks/realtime-api) to create incredibly fine-grained and blazing-fast subscriptions - learn how to perform a [basic authentication](/sdk/js/6/controllers/auth/login) - follow our guide to learn how to [manage users, and how to set up fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/raw-web/index.md b/doc/6/getting-started/raw-web/index.md index 238fdade3..bee031566 100644 --- a/doc/6/getting-started/raw-web/index.md +++ b/doc/6/getting-started/raw-web/index.md @@ -163,6 +163,6 @@ Congratulations! You have just set up your first pub/sub communication! Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: - discover what this SDK has to offer by browsing other sections of this documentation -- learn how to use [Koncorde](/core/1/koncorde) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to use [Koncorde](/core/1/guides/cookbooks/realtime-api) to create incredibly fine-grained and blazing-fast subscriptions - learn how to perform a [basic authentication](/sdk/js/6/controllers/auth/login) - follow our guide to learn how to [manage users, and how to set up fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/webpack/index.md b/doc/6/getting-started/webpack/index.md index c8d1f622c..aa88ebfc9 100644 --- a/doc/6/getting-started/webpack/index.md +++ b/doc/6/getting-started/webpack/index.md @@ -23,11 +23,11 @@ Before going through this tutorial, you should have a Kuzzle server running. Ple It's time to play with the [Kuzzle Javscript SDK](/sdk/js/6). In this section, we will store a document and subscribe to notifications in Kuzzle using the Javascript SDK in your browser. -Before proceeding, please make sure your system has **Node.js** version 8 or higher ([download page](https://nodejs.org/en/download/)) installed. +Before proceeding, please make sure your system has **Node.js** version 8 or higher ([instructions here](https://nodejs.org/en/download/)) installed. ## Including the Kuzzle SDK in a Webpack project -:::info +::: info This section explains how to use the Kuzzle SDK within an existing Webpack project. If you don't have your project up and running yet and want to learn how to leverage Webpack to build it, please refer to the [official Webpack Getting Started page](https://webpack.js.org/guides/getting-started/). @@ -45,23 +45,15 @@ If you are performing a clean install you might see some `UNMET PEER DEPENDENCY` Then, create a `init-kuzzle.js` file and start by adding the code below. This will load the Kuzzle Javascript SDK: -```js -import { Kuzzle, WebSocket } from 'kuzzle-sdk'; -``` +<<< ./snippets/init-kuzzle.js:1 Next, we instantiate a client that will connect to Kuzzle via WebSocket. If Kuzzle is not running on localhost, replace it with the corresponding server name or IP address. -```js -const kuzzle = new Kuzzle(new WebSocket('localhost')); -``` +<<< ./snippets/init-kuzzle.js:2 Next we add a listener to be notified in case of a connection error: -```js -kuzzle.on('networkError', error => { - console.error(`Network Error: ${error}`); -}); -``` +<<< ./snippets/init-kuzzle.js:3 Then we have to connect our web app to the Kuzzle server with the `connect()` method. @@ -70,7 +62,6 @@ const run = async () => { try { // Connect to Kuzzle server await kuzzle.connect(); - // Some more things will go here... } catch (error) { console.error(error.message); @@ -83,24 +74,7 @@ const run = async () => { Finally, we will create a new index `nyc-open-data` and a new collection `yellow-taxi` that we will use to store data later on. -```js -const run = async () => { - try { - // Connect to Kuzzle server - await kuzzle.connect(); - - // Create an index - await kuzzle.index.create('nyc-open-data'); - // Create a collection - await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); - console.log('nyc-open-data/yellow-taxi ready!'); - } catch (error) { - console.error(error.message); - } finally { - kuzzle.disconnect(); - } -}; -``` +<<< ./snippets/init-kuzzle.js:4 Your `kuzzle-init.js` file should now look like this: @@ -128,10 +102,14 @@ Your console should output the following message: nyc-open-data/yellow-taxi ready! ``` -:::success +::: success Congratulations! You are now ready to say Hello to the World! ::: +::: info +Having trouble? Get in touch with us on [Gitter!](https://gitter.im/kuzzleio/kuzzle) We're happy to help. +::: + ## Create your first document Create a `create.js` file with following code: @@ -172,8 +150,15 @@ Now, click the button and check your console for a message like the following: New document successfully created! ``` -:::success -You have now successfully stored your first document into Kuzzle. You can now open an [Admin Console](http://console.kuzzle.io) to browse your collection and confirm that your document was saved. +::: success +You have now successfully stored your first document into Kuzzle. Click +[here](/core/1/guides/essentials/admin-console/) to see how you can use the +[**Kuzzle Admin Console**](http://console.kuzzle.io/) to browse your collection and +confirm that your document was saved. +::: + +::: info +Having trouble? Get in touch with us on [Gitter!](https://gitter.im/kuzzleio/kuzzle) We're happy to help. ::: ## Subscribe to realtime document notifications (pub/sub) @@ -209,15 +194,19 @@ New driver Sirkis with id has B license. In place of `` you'll see the ID that Kuzzle automatically generated for the document. -:::success +::: success Congratulations! You have just choreographed your first pub/sub pattern! ::: +::: info +Having trouble? Get in touch with us on [Gitter!](https://gitter.im/kuzzleio/kuzzle) We're happy to help. +::: + ## Where do we go from here? Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: - take a look at the [SDK Reference](/sdk/js/6) -- learn how to use [Koncorde](/core/1/koncorde) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to use [Koncorde](/core/1/guides/cookbooks/realtime-api) to create incredibly fine-grained and blazing-fast subscriptions - follow our guide to learn how to implement [basic authentication](/core/1/guides/essentials/user-authentication/#local-strategy) - follow our guide to learn how to implement [manage users and setup fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/webpack/snippets/init-kuzzle.js b/doc/6/getting-started/webpack/snippets/init-kuzzle.js index 49068c155..dd8476b40 100644 --- a/doc/6/getting-started/webpack/snippets/init-kuzzle.js +++ b/doc/6/getting-started/webpack/snippets/init-kuzzle.js @@ -1,14 +1,21 @@ // load the Kuzzle SDK module +/* snippet:start:1 */ import { Kuzzle, WebSocket } from 'kuzzle-sdk'; +/* snippet:end */ // instantiate a Kuzzle client +/* snippet:start:2 */ const kuzzle = new Kuzzle(new WebSocket('kuzzle')); +/* snippet:end */ // add a listener to detect any connection problems +/* snippet:start:3 */ kuzzle.on('networkError', error => { console.error(`Network Error: ${error}`); }); +/* snippet:end */ +/* snippet:start:4 */ const run = async () => { try { // Connect to Kuzzle server @@ -26,5 +33,6 @@ const run = async () => { kuzzle.disconnect(); } }; +/* snippet:end */ run(); diff --git a/doc/6/protocols/http/constructor/index.md b/doc/6/protocols/http/constructor/index.md index 15cc9ac1b..24a46550c 100644 --- a/doc/6/protocols/http/constructor/index.md +++ b/doc/6/protocols/http/constructor/index.md @@ -1,7 +1,7 @@ --- code: true type: page -title: Constructor +title: constructor description: Creates a new Http protocol order: 50 --- @@ -12,7 +12,7 @@ Use this constructor to create a new instance of the `Http` protocol with specif ## Arguments -```javascript +```js Http(host, [options]); ``` diff --git a/doc/6/protocols/http/introduction/index.md b/doc/6/protocols/http/introduction/index.md index 1f2b0bab4..0bb636705 100644 --- a/doc/6/protocols/http/introduction/index.md +++ b/doc/6/protocols/http/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: Http protocol implementation @@ -10,11 +10,8 @@ order: 0 The Http protocol can be used by an instance of the SDK to communicate with your Kuzzle server. -
-

- This protocol does not allow to use the real-time notifications. -

-

- You have to use WebSocket or SocketIO protocol instead. -

-
+:::info +This protocol does not allow to use the [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). + +If you need real-time features, then you have to use either [WebSocket](/sdk/js/6/protocols/websocket) or [SocketIO](/sdk/js/6/protocols/socketio) protocols. +::: diff --git a/doc/6/protocols/http/properties/index.md b/doc/6/protocols/http/properties/index.md new file mode 100644 index 000000000..e280f5787 --- /dev/null +++ b/doc/6/protocols/http/properties/index.md @@ -0,0 +1,19 @@ +--- +code: false +type: page +title: Properties +description: Http class properties +order: 10 +--- + + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `connected` |
boolean
| Always returns `true` | +| `host` |
string
| Kuzzle server host | +| `http` |
object
| Returns a list of available routes | +| `port` |
number
| Kuzzle server port | +| `protocol` |
string
| `https` or `http` | +| `ssl` |
boolean
| `true` if ssl is active | diff --git a/doc/6/protocols/index.md b/doc/6/protocols/index.md index 91d86f85d..a6a409d8a 100644 --- a/doc/6/protocols/index.md +++ b/doc/6/protocols/index.md @@ -1,7 +1,7 @@ --- code: false type: branch -order: 200 +order: 300 title: Protocols description: Javascript SDK v6.x protocols --- diff --git a/doc/6/protocols/socketio/constructor/index.md b/doc/6/protocols/socketio/constructor/index.md index 8ba0dd9bf..fca54a645 100644 --- a/doc/6/protocols/socketio/constructor/index.md +++ b/doc/6/protocols/socketio/constructor/index.md @@ -1,7 +1,7 @@ --- code: true type: page -title: Constructor +title: constructor description: Creates a new SocketIO protocol order: 50 --- @@ -12,7 +12,7 @@ Use this constructor to create a new instance of the `SocketIO` protocol with sp ## Arguments -```javascript +```js SocketIO(host, [options]); ``` diff --git a/doc/6/protocols/socketio/introduction/index.md b/doc/6/protocols/socketio/introduction/index.md index 528d29882..58717f7ad 100644 --- a/doc/6/protocols/socketio/introduction/index.md +++ b/doc/6/protocols/socketio/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: SocketIO protocol implementation @@ -8,24 +8,9 @@ order: 0 # SocketIO -The SocketIO protocol can be used by an instance of the SDK to communicate with your Kuzzle server. +The SocketIO protocol can be used by an instance of the SDK to communicate with your Kuzzle server. This protocol allows you to use all the features of Kuzzle, including [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). -
-

- The SocketIO protocol is used for websocket compatibility with older browsers. It is preferable to use the WebSocket protocol when possible. -

-
- -## Properties - -Available properties. - -| Property name | Type | Description | Writable? | -| ------------------- | ------------------ | ---------------------------------------------------- | :-------: | -| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | No | -| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | No | - -**Notes:** - -- updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on next `connect` call +:::info +The SocketIO protocol is used for WebSocket compatibility with older browsers. It is preferable to use the [WebSocket](/sdk/js/6/protocols/websocket) protocol when possible. +::: diff --git a/doc/6/protocols/socketio/properties/index.md b/doc/6/protocols/socketio/properties/index.md new file mode 100644 index 000000000..42aeefe36 --- /dev/null +++ b/doc/6/protocols/socketio/properties/index.md @@ -0,0 +1,22 @@ +--- +code: false +type: page +title: Properties +description: SocketIO class properties +order: 10 +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoReconnect` |
boolean
| Automatically reconnects after a connection loss | +| `connected` |
boolean
| Returns `true` if the socket is open | +| `host` |
string
| Kuzzle server host | +| `port` |
number
| Kuzzle server port | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | +| `ssl` |
boolean
| `true` if ssl is active | + +::: info +Updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on the next `connect` call. +::: diff --git a/doc/6/protocols/websocket/constructor/index.md b/doc/6/protocols/websocket/constructor/index.md index 8ac46fe20..736df3deb 100644 --- a/doc/6/protocols/websocket/constructor/index.md +++ b/doc/6/protocols/websocket/constructor/index.md @@ -1,7 +1,7 @@ --- code: true type: page -title: Constructor +title: constructor description: Creates a new WebSocket protocol order: 50 --- @@ -12,7 +12,7 @@ This constructor creates a new WebSocket connection, using the specified options ## Arguments -```javascript +```js WebSocket(host, [options]); ``` diff --git a/doc/6/protocols/websocket/introduction/index.md b/doc/6/protocols/websocket/introduction/index.md index d9627a470..1757128cc 100644 --- a/doc/6/protocols/websocket/introduction/index.md +++ b/doc/6/protocols/websocket/introduction/index.md @@ -1,5 +1,5 @@ --- -code: true +code: false type: page title: Introduction description: Websocket protocol implementation @@ -8,21 +8,8 @@ order: 0 # WebSocket -Inherits from: [KuzzleEventEmitter](/sdk/js/6/kuzzle-event-emitter) +Inherits from: [KuzzleEventEmitter](/sdk/js/6/core-classes/kuzzle-event-emitter) The WebSocket protocol can be used by an instance of the SDK to communicate with your Kuzzle server. This protocol allows you to use all the features of Kuzzle, including [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). - -## Properties - -Available properties. - -| Property name | Type | Description | Writable? | -| ------------------- | ------------------ | ---------------------------------------------------- | :-------: | -| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | No | -| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | No | - -**Notes:** - -- updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on next `connect` call diff --git a/doc/6/protocols/websocket/properties/index.md b/doc/6/protocols/websocket/properties/index.md new file mode 100644 index 000000000..6b20dc9fb --- /dev/null +++ b/doc/6/protocols/websocket/properties/index.md @@ -0,0 +1,22 @@ +--- +code: false +type: page +title: Properties +description: Websocket class properties +order: 10 +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | +| `connected` |
boolean
| Returns `true` if the socket is open | +| `host` |
string
| Kuzzle server host | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | +| `port` |
number
| Kuzzle server port | +| `ssl` |
boolean
| `true` if ssl is active | + +::: info +Updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on the next `connect` call. +::: \ No newline at end of file From ebedc20cea4b12b781a5c7910b065528daff1bae Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Thu, 27 Jun 2019 18:17:11 +0200 Subject: [PATCH 14/26] [fix] Test cases and Docker Compose --- .ci/doc/docker-compose.yml | 48 ++++++++++--------- .vscode/launch.json | 14 ++++++ .../snippets/refreshToken.test.yml | 6 +-- .../snippets/search-specifications.test.yml | 1 - 4 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.ci/doc/docker-compose.yml b/.ci/doc/docker-compose.yml index 11c38dc5d..57a14e051 100644 --- a/.ci/doc/docker-compose.yml +++ b/.ci/doc/docker-compose.yml @@ -31,6 +31,8 @@ services: doc-tests: image: kuzzleio/snippets-tests privileged: true + ports: + - "9229:9229" depends_on: - kuzzle - doc-runner-node @@ -44,12 +46,19 @@ services: - CONFIG_FILE=/mnt/.ci/doc/config.yml doc-runner-node: - image: node:8-alpine + image: node:10-alpine + volumes: + - ../..:/mnt + - snippets:/var/snippets command: > ash -c ' mkdir -p /var/snippets/node; apk add --no-cache curl; - npm install -g \ + npm install -g eslint; + cd /var/snippets/node; + npm install \ + bluebird \ + /mnt/ \ eslint \ eslint-plugin-html \ eslint-plugin-import \ @@ -57,16 +66,9 @@ services: eslint-plugin-promise \ eslint-plugin-standard; touch /tmp/runner_ready_to_lint; - cd /var/snippets/node; - npm install \ - bluebird \ - /mnt/; touch /tmp/runner_is_ready; tail -f /dev/null ' - volumes: - - ../..:/mnt - - snippets:/var/snippets doc-runner-web: image: buildkite/puppeteer:latest @@ -76,6 +78,12 @@ services: apt-get update; apt-get install -y curl; npm install -g \ + eslint; + cd /var/snippets/web; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; + npm install \ + /mnt/ \ + puppeteer \ eslint \ eslint-plugin-html \ eslint-plugin-import \ @@ -83,11 +91,6 @@ services: eslint-plugin-promise \ eslint-plugin-standard; touch /tmp/runner_ready_to_lint; - cd /var/snippets/web; - cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; - npm install \ - /mnt/ \ - puppeteer; touch /tmp/runner_is_ready; tail -f /dev/null ' @@ -103,13 +106,7 @@ services: apt-get update; apt-get install -y curl; npm install -g \ - eslint \ - eslint-plugin-html \ - eslint-plugin-import \ - eslint-plugin-node \ - eslint-plugin-promise \ - eslint-plugin-standard; - touch /tmp/runner_ready_to_lint; + eslint; cd /var/snippets/webpack; cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/; cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/; @@ -120,7 +117,14 @@ services: puppeteer \ html-webpack-plugin \ webpack \ - webpack-cli; + webpack-cli \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; touch /tmp/runner_is_ready; tail -f /dev/null ' diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..a4b5bd3e9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/index.js" + } + ] +} \ No newline at end of file diff --git a/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml index c0637630c..be2ec825c 100644 --- a/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml +++ b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml @@ -1,13 +1,13 @@ --- -name: auth#login -description: Authenticate a user +name: auth#refreshtoken +description: Refresh a user's token hooks: before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' after: curl -X DELETE kuzzle:7512/users/foo template: default expected: - ^.*\..*$ - - "{ _id: 'foo'," + - ^{ _id: 'foo' - ^\s*jwt: '.*\..*' - ^\s*expiresAt: \d+ - ^\s*ttl: \d+ } diff --git a/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml index 920b4e2f3..f32b7aa16 100644 --- a/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml +++ b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml @@ -17,7 +17,6 @@ hooks: } } }' kuzzle:7512/_specifications?refresh=wait_for - after: template: default expected: 'fetched: 1' sdk: js From b94db379cae709f1fbf3b7e3432676333012f6b7 Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Fri, 28 Jun 2019 09:33:59 +0200 Subject: [PATCH 15/26] [skip ci] Added npm run doc-testing --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index daddc8d77..a2599e9a0 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "prepublish": "npm run build", "test": "npm run --silent lint && npm run unit-testing && npm run functional-testing", "unit-testing": "nyc --reporter=text-summary --reporter=lcov mocha", + "doc-testing": "docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index", "functional-testing": "cucumber-js --exit --fail-fast", "lint": "eslint --max-warnings=0 ./src ./test", "build": "node build.js" From 03e4c3c16e504ff6a05e9d9741dae2e83098c52a Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Fri, 28 Jun 2019 10:43:24 +0200 Subject: [PATCH 16/26] [skip ci] improved npm doc-testing cmd --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2599e9a0..5133aefed 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "prepublish": "npm run build", "test": "npm run --silent lint && npm run unit-testing && npm run functional-testing", "unit-testing": "nyc --reporter=text-summary --reporter=lcov mocha", - "doc-testing": "docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index", + "doc-testing": "docker-compose -f .ci/doc/docker-compose.yml pull; docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index; docker-compose -f .ci/doc/docker-compose.yml down", "functional-testing": "cucumber-js --exit --fail-fast", "lint": "eslint --max-warnings=0 ./src ./test", "build": "node build.js" From 548604dda6cedab5588cadb2f201232de01b2383 Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Fri, 28 Jun 2019 12:51:26 +0200 Subject: [PATCH 17/26] [package] fixed doc-testing cmd --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5133aefed..67971f84a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "prepublish": "npm run build", "test": "npm run --silent lint && npm run unit-testing && npm run functional-testing", "unit-testing": "nyc --reporter=text-summary --reporter=lcov mocha", - "doc-testing": "docker-compose -f .ci/doc/docker-compose.yml pull; docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index; docker-compose -f .ci/doc/docker-compose.yml down", + "doc-testing": "docker-compose -f .ci/doc/docker-compose.yml pull; docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index", "functional-testing": "cucumber-js --exit --fail-fast", "lint": "eslint --max-warnings=0 ./src ./test", "build": "node build.js" From aa71e970d40ee903dc22db41cea1e052427d598a Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Fri, 28 Jun 2019 14:06:25 +0200 Subject: [PATCH 18/26] [test] fixed dependencies in web runner --- .ci/doc/docker-compose.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.ci/doc/docker-compose.yml b/.ci/doc/docker-compose.yml index 57a14e051..d6e1c083e 100644 --- a/.ci/doc/docker-compose.yml +++ b/.ci/doc/docker-compose.yml @@ -4,7 +4,7 @@ services: kuzzle: image: kuzzleio/kuzzle ports: - - "7512:7512" + - '7512:7512' cap_add: - SYS_PTRACE depends_on: @@ -26,13 +26,13 @@ services: nofile: 65536 environment: - cluster.name=kuzzle - - "ES_JAVA_OPTS=-Xms256m -Xmx256m" + - 'ES_JAVA_OPTS=-Xms256m -Xmx256m' doc-tests: image: kuzzleio/snippets-tests privileged: true ports: - - "9229:9229" + - '9229:9229' depends_on: - kuzzle - doc-runner-node @@ -79,6 +79,8 @@ services: apt-get install -y curl; npm install -g \ eslint; + cd /mnt; + npm install; cd /var/snippets/web; cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; npm install \ @@ -134,4 +136,3 @@ services: volumes: snippets: - From eb52b4402ac8ecbd09c9d4cd0c8ee588b3507780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Vidis?= Date: Fri, 28 Jun 2019 15:42:45 +0200 Subject: [PATCH 19/26] Documentation v6 and Snippet Tests (#399) Imports the SDK v6 documentation in the doc/6/ folder and integrates snippet testing. --- .ci/doc/config.yml | 47 ++++ .ci/doc/docker-compose.yml | 138 ++++++++++ .ci/doc/eslint.json | 236 ++++++++++++++++++ .ci/doc/puppeteer.js | 38 +++ .ci/doc/templates/blank.tpl.js | 14 ++ .ci/doc/templates/catch.tpl.js | 31 +++ .ci/doc/templates/controller.tpl.js | 11 + .../createDocumentAfterSnippet.tpl.js | 27 ++ .ci/doc/templates/default.tpl.html | 12 + .ci/doc/templates/default.tpl.js | 27 ++ .ci/doc/templates/doIt.tpl.js | 5 + .ci/doc/templates/empty-realtime.tpl.js | 23 ++ .ci/doc/templates/empty.tpl.js | 3 + .ci/doc/templates/eventemitter.tpl.js | 6 + .ci/doc/templates/mqtt-end.tpl.js | 4 + .ci/doc/templates/realtime.tpl.js | 47 ++++ .ci/doc/templates/success.tpl.js | 32 +++ .ci/doc/templates/thencatch.tpl.js | 28 +++ .ci/doc/templates/without-connect.tpl.js | 22 ++ .ci/doc/webpackBuild.js | 53 ++++ .ci/docker-compose.yml | 9 +- .travis.yml | 11 +- .vscode/launch.json | 14 ++ doc/6/controllers/auth/check-token/index.md | 38 +++ .../auth/check-token/snippets/check-token.js | 23 ++ .../check-token/snippets/check-token.test.yml | 11 + .../auth/create-my-credentials/index.md | 41 +++ .../snippets/create-my-credentials.js | 11 + .../snippets/create-my-credentials.test.yml | 10 + .../auth/credentials-exist/index.md | 39 +++ .../snippets/credentials-exist.js | 13 + .../snippets/credentials-exist.test.yml | 10 + .../auth/delete-my-credentials/index.md | 43 ++++ .../snippets/delete-my-credentials.js | 13 + .../snippets/delete-my-credentials.test.yml | 10 + .../auth/get-current-user/index.md | 38 +++ .../snippets/get-current-user.js | 23 ++ .../snippets/get-current-user.test.yml | 10 + .../auth/get-my-credentials/index.md | 44 ++++ .../snippets/get-my-credentials.js | 15 ++ .../snippets/get-my-credentials.test.yml | 10 + doc/6/controllers/auth/get-my-rights/index.md | 46 ++++ .../get-my-rights/snippets/get-my-rights.js | 19 ++ .../snippets/get-my-rights.test.yml | 10 + .../controllers/auth/get-strategies/index.md | 38 +++ .../get-strategies/snippets/get-strategies.js | 15 ++ .../snippets/get-strategies.test.yml | 10 + doc/6/controllers/auth/index.md | 6 + doc/6/controllers/auth/login/index.md | 51 ++++ .../controllers/auth/login/snippets/login.js | 12 + .../auth/login/snippets/login.test.yml | 11 + doc/6/controllers/auth/logout/index.md | 24 ++ .../auth/logout/snippets/logout.js | 11 + .../auth/logout/snippets/logout.test.yml | 10 + doc/6/controllers/auth/refresh-token/index.md | 58 +++++ .../refresh-token/snippets/refreshToken.js | 22 ++ .../snippets/refreshToken.test.yml | 15 ++ .../auth/update-my-credentials/index.md | 41 +++ .../snippets/update-my-credentials.js | 18 ++ .../snippets/update-my-credentials.test.yml | 10 + doc/6/controllers/auth/update-self/index.md | 41 +++ .../auth/update-self/snippets/update-self.js | 24 ++ .../update-self/snippets/update-self.test.yml | 10 + .../auth/validate-my-credentials/index.md | 42 ++++ .../snippets/validate-my-credentials.js | 13 + .../snippets/validate-my-credentials.test.yml | 10 + doc/6/controllers/bulk/import/index.md | 85 +++++++ .../bulk/import/snippets/import.js | 40 +++ .../bulk/import/snippets/import.test.yml | 13 + doc/6/controllers/bulk/index.md | 6 + doc/6/controllers/collection/create/index.md | 67 +++++ .../collection/create/snippets/create.js | 19 ++ .../create/snippets/create.test.yml | 10 + .../collection/delete-specifications/index.md | 40 +++ .../snippets/delete-specifications.js | 7 + .../snippets/delete-specifications.test.yml | 10 + doc/6/controllers/collection/exists/index.md | 40 +++ .../collection/exists/snippets/exists.js | 9 + .../exists/snippets/exists.test.yml | 10 + .../collection/get-mapping/index.md | 40 +++ .../get-mapping/snippets/get-mapping.js | 31 +++ .../get-mapping/snippets/get-mapping.test.yml | 10 + .../collection/get-specifications/index.md | 40 +++ .../snippets/get-specifications.js | 23 ++ .../snippets/get-specifications.test.yml | 9 + doc/6/controllers/collection/index.md | 6 + doc/6/controllers/collection/list/index.md | 56 +++++ .../collection/list/snippets/list.js | 18 ++ .../collection/list/snippets/list.test.yml | 10 + .../collection/search-specifications/index.md | 70 ++++++ .../snippets/search-specifications.js | 47 ++++ .../snippets/search-specifications.test.yml | 23 ++ .../controllers/collection/truncate/index.md | 40 +++ .../collection/truncate/snippets/truncate.js | 7 + .../truncate/snippets/truncate.test.yml | 10 + .../collection/update-mapping/index.md | 66 +++++ .../update-mapping/snippets/update-mapping.js | 17 ++ .../snippets/update-mapping.test.yml | 10 + .../collection/update-specifications/index.md | 58 +++++ .../snippets/update-specifications.js | 25 ++ .../snippets/update-specifications.test.yml | 10 + .../validate-specifications/index.md | 66 +++++ .../snippets/validate-specifications.js | 29 +++ .../snippets/validate-specifications.test.yml | 10 + doc/6/controllers/document/count/index.md | 43 ++++ .../document/count/snippets/count.js | 15 ++ .../document/count/snippets/count.test.yml | 22 ++ doc/6/controllers/document/create/index.md | 51 ++++ .../document/create/snippets/create.js | 33 +++ .../document/create/snippets/create.test.yml | 14 ++ .../document/createOrReplace/index.md | 49 ++++ .../snippets/create-or-replace.js | 33 +++ .../snippets/create-or-replace.test.yml | 14 ++ doc/6/controllers/document/delete/index.md | 42 ++++ .../document/delete/snippets/delete.js | 9 + .../document/delete/snippets/delete.test.yml | 15 ++ .../document/deleteByQuery/index.md | 44 ++++ .../deleteByQuery/snippets/delete-by-query.js | 15 ++ .../snippets/delete-by-query.test.yml | 24 ++ doc/6/controllers/document/get/index.md | 37 +++ .../controllers/document/get/snippets/get.js | 30 +++ .../document/get/snippets/get.test.yml | 14 ++ doc/6/controllers/document/index.md | 8 + doc/6/controllers/document/mCreate/index.md | 47 ++++ .../document/mCreate/snippets/m-create.js | 78 ++++++ .../mCreate/snippets/m-create.test.yml | 14 ++ .../document/mCreateOrReplace/index.md | 47 ++++ .../snippets/m-create-or-replace.js | 80 ++++++ .../snippets/m-create-or-replace.test.yml | 14 ++ doc/6/controllers/document/mDelete/index.md | 44 ++++ .../document/mDelete/snippets/m-delete.js | 14 ++ .../mDelete/snippets/m-delete.test.yml | 14 ++ doc/6/controllers/document/mGet/index.md | 46 ++++ .../document/mGet/snippets/m-get.js | 61 +++++ .../document/mGet/snippets/m-get.test.yml | 14 ++ doc/6/controllers/document/mReplace/index.md | 47 ++++ .../document/mReplace/snippets/m-replace.js | 64 +++++ .../mReplace/snippets/m-replace.test.yml | 14 ++ doc/6/controllers/document/mUpdate/index.md | 52 ++++ .../document/mUpdate/snippets/m-update.js | 51 ++++ .../mUpdate/snippets/m-update.test.yml | 14 ++ doc/6/controllers/document/replace/index.md | 47 ++++ .../document/replace/snippets/replace.js | 36 +++ .../replace/snippets/replace.test.yml | 13 + doc/6/controllers/document/search/index.md | 59 +++++ .../document/search/snippets/search.js | 61 +++++ .../document/search/snippets/search.test.yml | 13 + doc/6/controllers/document/update/index.md | 45 ++++ .../document/update/snippets/update.js | 27 ++ .../document/update/snippets/update.test.yml | 14 ++ doc/6/controllers/document/validate/index.md | 43 ++++ .../document/validate/snippets/validate.js | 13 + .../validate/snippets/validate.test.yml | 14 ++ doc/6/controllers/index.md | 7 + doc/6/controllers/index/create/index.md | 44 ++++ .../index/create/snippets/create.js | 12 + .../index/create/snippets/create.test.yml | 12 + doc/6/controllers/index/delete/index.md | 39 +++ .../index/delete/snippets/delete.js | 7 + .../index/delete/snippets/delete.test.yml | 11 + doc/6/controllers/index/exists/index.md | 39 +++ .../index/exists/snippets/exists.js | 11 + .../index/exists/snippets/exists.test.yml | 11 + .../index/get-auto-refresh/index.md | 49 ++++ .../snippets/getAutoRefresh.js | 7 + .../snippets/getAutoRefresh.test.yml | 11 + doc/6/controllers/index/index.md | 6 + doc/6/controllers/index/list/index.md | 38 +++ doc/6/controllers/index/list/snippets/list.js | 11 + .../index/list/snippets/list.test.yml | 14 ++ doc/6/controllers/index/m-delete/index.md | 39 +++ .../index/m-delete/snippets/mDelete.js | 11 + .../index/m-delete/snippets/mDelete.test.yml | 13 + .../index/refresh-internal/index.md | 48 ++++ .../snippets/refreshInternal.js | 9 + .../snippets/refreshInternal.test.yml | 11 + doc/6/controllers/index/refresh/index.md | 52 ++++ .../index/refresh/snippets/refresh.js | 11 + .../index/refresh/snippets/refresh.test.yml | 11 + .../index/set-auto-refresh/index.md | 50 ++++ .../snippets/setAutoRefresh.js | 9 + .../snippets/setAutoRefresh.test.yml | 13 + doc/6/controllers/ms/append/index.md | 41 +++ .../controllers/ms/append/snippets/append.js | 10 + .../ms/append/snippets/append.test.yml | 9 + doc/6/controllers/ms/bitcount/index.md | 42 ++++ .../ms/bitcount/snippets/bitcount.js | 11 + .../ms/bitcount/snippets/bitcount.test.yml | 11 + doc/6/controllers/ms/bitop/index.md | 42 ++++ doc/6/controllers/ms/bitop/snippets/bitop.js | 11 + .../ms/bitop/snippets/bitop.test.yml | 9 + doc/6/controllers/ms/bitpos/index.md | 43 ++++ .../controllers/ms/bitpos/snippets/bitpos.js | 8 + .../ms/bitpos/snippets/bitpos.test.yml | 9 + doc/6/controllers/ms/dbsize/index.md | 39 +++ .../controllers/ms/dbsize/snippets/dbsize.js | 6 + .../ms/dbsize/snippets/dbsize.test.yml | 9 + doc/6/controllers/ms/decr/index.md | 40 +++ doc/6/controllers/ms/decr/snippets/decr.js | 8 + .../ms/decr/snippets/decr.test.yml | 9 + doc/6/controllers/ms/decrby/index.md | 41 +++ .../controllers/ms/decrby/snippets/decrby.js | 8 + .../ms/decrby/snippets/decrby.test.yml | 9 + doc/6/controllers/ms/del/index.md | 40 +++ doc/6/controllers/ms/del/snippets/del.js | 15 ++ .../controllers/ms/del/snippets/del.test.yml | 9 + doc/6/controllers/ms/exists/index.md | 40 +++ .../controllers/ms/exists/snippets/exists.js | 13 + .../ms/exists/snippets/exists.test.yml | 11 + doc/6/controllers/ms/expire/index.md | 41 +++ .../controllers/ms/expire/snippets/expire.js | 13 + .../ms/expire/snippets/expire.test.yml | 11 + doc/6/controllers/ms/expireat/index.md | 41 +++ .../ms/expireat/snippets/expireat.js | 14 ++ .../ms/expireat/snippets/expireat.test.yml | 11 + doc/6/controllers/ms/flushdb/index.md | 39 +++ .../ms/flushdb/snippets/flushdb.js | 6 + .../ms/flushdb/snippets/flushdb.test.yml | 9 + doc/6/controllers/ms/geoadd/index.md | 51 ++++ .../controllers/ms/geoadd/snippets/geoadd.js | 19 ++ .../ms/geoadd/snippets/geoadd.test.yml | 9 + doc/6/controllers/ms/geodist/index.md | 45 ++++ .../ms/geodist/snippets/geodist.js | 28 +++ .../ms/geodist/snippets/geodist.test.yml | 11 + doc/6/controllers/ms/geohash/index.md | 41 +++ .../ms/geohash/snippets/geohash.js | 20 ++ .../ms/geohash/snippets/geohash.test.yml | 9 + doc/6/controllers/ms/geopos/index.md | 41 +++ .../controllers/ms/geopos/snippets/geopos.js | 24 ++ .../ms/geopos/snippets/geopos.test.yml | 11 + doc/6/controllers/ms/georadius/index.md | 56 +++++ .../ms/georadius/snippets/georadius.js | 61 +++++ .../ms/georadius/snippets/georadius.test.yml | 18 ++ .../controllers/ms/georadiusbymember/index.md | 55 ++++ .../snippets/georadiusbymember.js | 58 +++++ .../snippets/georadiusbymember.test.yml | 18 ++ doc/6/controllers/ms/get/index.md | 40 +++ doc/6/controllers/ms/get/snippets/get.js | 8 + .../controllers/ms/get/snippets/get.test.yml | 9 + doc/6/controllers/ms/getbit/index.md | 42 ++++ .../controllers/ms/getbit/snippets/getbit.js | 11 + .../ms/getbit/snippets/getbit.test.yml | 11 + doc/6/controllers/ms/getrange/index.md | 44 ++++ .../ms/getrange/snippets/getrange.js | 11 + .../ms/getrange/snippets/getrange.test.yml | 11 + doc/6/controllers/ms/getset/index.md | 41 +++ .../controllers/ms/getset/snippets/getset.js | 11 + .../ms/getset/snippets/getset.test.yml | 11 + doc/6/controllers/ms/hdel/index.md | 41 +++ doc/6/controllers/ms/hdel/snippets/hdel.js | 14 ++ .../ms/hdel/snippets/hdel.test.yml | 11 + doc/6/controllers/ms/hexists/index.md | 41 +++ .../ms/hexists/snippets/hexists.js | 11 + .../ms/hexists/snippets/hexists.test.yml | 11 + doc/6/controllers/ms/hget/index.md | 41 +++ doc/6/controllers/ms/hget/snippets/hget.js | 8 + .../ms/hget/snippets/hget.test.yml | 9 + doc/6/controllers/ms/hgetall/index.md | 40 +++ .../ms/hgetall/snippets/hgetall.js | 9 + .../ms/hgetall/snippets/hgetall.test.yml | 9 + doc/6/controllers/ms/hincrby/index.md | 42 ++++ .../ms/hincrby/snippets/hincrby.js | 8 + .../ms/hincrby/snippets/hincrby.test.yml | 9 + doc/6/controllers/ms/hincrbyfloat/index.md | 42 ++++ .../ms/hincrbyfloat/snippets/hincrbyfloat.js | 8 + .../snippets/hincrbyfloat.test.yml | 9 + doc/6/controllers/ms/hkeys/index.md | 40 +++ doc/6/controllers/ms/hkeys/snippets/hkeys.js | 10 + .../ms/hkeys/snippets/hkeys.test.yml | 9 + doc/6/controllers/ms/hlen/index.md | 40 +++ doc/6/controllers/ms/hlen/snippets/hlen.js | 10 + .../ms/hlen/snippets/hlen.test.yml | 9 + doc/6/controllers/ms/hmget/index.md | 41 +++ doc/6/controllers/ms/hmget/snippets/hmget.js | 11 + .../ms/hmget/snippets/hmget.test.yml | 9 + doc/6/controllers/ms/hmset/index.md | 50 ++++ doc/6/controllers/ms/hmset/snippets/hmset.js | 15 ++ .../ms/hmset/snippets/hmset.test.yml | 9 + doc/6/controllers/ms/hscan/index.md | 53 ++++ doc/6/controllers/ms/hscan/snippets/hscan.js | 14 ++ .../ms/hscan/snippets/hscan.test.yml | 11 + doc/6/controllers/ms/hset/index.md | 46 ++++ doc/6/controllers/ms/hset/snippets/hset.js | 8 + .../ms/hset/snippets/hset.test.yml | 9 + doc/6/controllers/ms/hsetnx/index.md | 38 +++ .../controllers/ms/hsetnx/snippets/hsetnx.js | 13 + .../ms/hsetnx/snippets/hsetnx.test.yml | 12 + doc/6/controllers/ms/hstrlen/index.md | 41 +++ .../ms/hstrlen/snippets/hstrlen.js | 8 + .../ms/hstrlen/snippets/hstrlen.test.yml | 9 + doc/6/controllers/ms/hvals/index.md | 40 +++ doc/6/controllers/ms/hvals/snippets/hvals.js | 10 + .../ms/hvals/snippets/hvals.test.yml | 9 + doc/6/controllers/ms/incr/index.md | 40 +++ doc/6/controllers/ms/incr/snippets/incr.js | 8 + .../ms/incr/snippets/incr.test.yml | 9 + doc/6/controllers/ms/incrby/index.md | 41 +++ .../controllers/ms/incrby/snippets/incrby.js | 8 + .../ms/incrby/snippets/incrby.test.yml | 9 + doc/6/controllers/ms/incrbyfloat/index.md | 41 +++ .../ms/incrbyfloat/snippets/incrbyfloat.js | 8 + .../incrbyfloat/snippets/incrbyfloat.test.yml | 9 + doc/6/controllers/ms/index.md | 6 + doc/6/controllers/ms/keys/index.md | 40 +++ doc/6/controllers/ms/keys/snippets/keys.js | 10 + .../ms/keys/snippets/keys.test.yml | 9 + doc/6/controllers/ms/lindex/index.md | 41 +++ .../controllers/ms/lindex/snippets/lindex.js | 8 + .../ms/lindex/snippets/lindex.test.yml | 9 + doc/6/controllers/ms/linsert/index.md | 43 ++++ .../ms/linsert/snippets/linsert.js | 10 + .../ms/linsert/snippets/linsert.test.yml | 9 + doc/6/controllers/ms/llen/index.md | 40 +++ doc/6/controllers/ms/llen/snippets/llen.js | 8 + .../ms/llen/snippets/llen.test.yml | 9 + doc/6/controllers/ms/lpop/index.md | 40 +++ doc/6/controllers/ms/lpop/snippets/lpop.js | 11 + .../ms/lpop/snippets/lpop.test.yml | 11 + doc/6/controllers/ms/lpush/index.md | 43 ++++ doc/6/controllers/ms/lpush/snippets/lpush.js | 11 + .../ms/lpush/snippets/lpush.test.yml | 11 + doc/6/controllers/ms/lpushx/index.md | 41 +++ .../controllers/ms/lpushx/snippets/lpushx.js | 17 ++ .../ms/lpushx/snippets/lpushx.test.yml | 13 + doc/6/controllers/ms/lrange/index.md | 46 ++++ .../controllers/ms/lrange/snippets/lrange.js | 11 + .../ms/lrange/snippets/lrange.test.yml | 11 + doc/6/controllers/ms/lrem/index.md | 42 ++++ doc/6/controllers/ms/lrem/snippets/lrem.js | 11 + .../ms/lrem/snippets/lrem.test.yml | 11 + doc/6/controllers/ms/lset/index.md | 42 ++++ doc/6/controllers/ms/lset/snippets/lset.js | 10 + .../ms/lset/snippets/lset.test.yml | 9 + doc/6/controllers/ms/ltrim/index.md | 44 ++++ doc/6/controllers/ms/ltrim/snippets/ltrim.js | 10 + .../ms/ltrim/snippets/ltrim.test.yml | 9 + doc/6/controllers/ms/mget/index.md | 40 +++ doc/6/controllers/ms/mget/snippets/mget.js | 9 + .../ms/mget/snippets/mget.test.yml | 9 + doc/6/controllers/ms/mset/index.md | 49 ++++ doc/6/controllers/ms/mset/snippets/mset.js | 15 ++ .../ms/mset/snippets/mset.test.yml | 11 + doc/6/controllers/ms/msetnx/index.md | 49 ++++ .../controllers/ms/msetnx/snippets/msetnx.js | 19 ++ .../ms/msetnx/snippets/msetnx.test.yml | 11 + doc/6/controllers/ms/object/index.md | 41 +++ .../controllers/ms/object/snippets/object.js | 8 + .../ms/object/snippets/object.test.yml | 9 + doc/6/controllers/ms/persist/index.md | 40 +++ .../ms/persist/snippets/persist.js | 13 + .../ms/persist/snippets/persist.test.yml | 11 + doc/6/controllers/ms/pexpire/index.md | 41 +++ .../ms/pexpire/snippets/pexpire.js | 13 + .../ms/pexpire/snippets/pexpire.test.yml | 11 + doc/6/controllers/ms/pexpireat/index.md | 41 +++ .../ms/pexpireat/snippets/pexpireat.js | 14 ++ .../ms/pexpireat/snippets/pexpireat.test.yml | 11 + doc/6/controllers/ms/pfadd/index.md | 40 +++ doc/6/controllers/ms/pfadd/snippets/pfadd.js | 8 + .../ms/pfadd/snippets/pfadd.test.yml | 9 + doc/6/controllers/ms/pfcount/index.md | 40 +++ .../ms/pfcount/snippets/pfcount.js | 9 + .../ms/pfcount/snippets/pfcount.test.yml | 9 + doc/6/controllers/ms/pfmerge/index.md | 41 +++ .../ms/pfmerge/snippets/pfmerge.js | 11 + .../ms/pfmerge/snippets/pfmerge.test.yml | 9 + doc/6/controllers/ms/ping/index.md | 39 +++ doc/6/controllers/ms/ping/snippets/ping.js | 6 + .../ms/ping/snippets/ping.test.yml | 9 + doc/6/controllers/ms/psetex/index.md | 42 ++++ .../controllers/ms/psetex/snippets/psetex.js | 11 + .../ms/psetex/snippets/psetex.test.yml | 11 + doc/6/controllers/ms/pttl/index.md | 40 +++ doc/6/controllers/ms/pttl/snippets/pttl.js | 8 + .../ms/pttl/snippets/pttl.test.yml | 9 + doc/6/controllers/ms/randomkey/index.md | 40 +++ .../ms/randomkey/snippets/randomkey.js | 10 + .../ms/randomkey/snippets/randomkey.test.yml | 9 + doc/6/controllers/ms/rename/index.md | 43 ++++ .../controllers/ms/rename/snippets/rename.js | 10 + .../ms/rename/snippets/rename.test.yml | 9 + doc/6/controllers/ms/renamenx/index.md | 41 +++ .../ms/renamenx/snippets/renamenx.js | 13 + .../ms/renamenx/snippets/renamenx.test.yml | 11 + doc/6/controllers/ms/rpop/index.md | 40 +++ doc/6/controllers/ms/rpop/snippets/rpop.js | 11 + .../ms/rpop/snippets/rpop.test.yml | 11 + doc/6/controllers/ms/rpoplpush/index.md | 41 +++ .../ms/rpoplpush/snippets/rpoplpush.js | 12 + .../ms/rpoplpush/snippets/rpoplpush.test.yml | 11 + doc/6/controllers/ms/rpush/index.md | 43 ++++ doc/6/controllers/ms/rpush/snippets/rpush.js | 8 + .../ms/rpush/snippets/rpush.test.yml | 9 + doc/6/controllers/ms/rpushx/index.md | 41 +++ .../controllers/ms/rpushx/snippets/rpushx.js | 12 + .../ms/rpushx/snippets/rpushx.test.yml | 11 + doc/6/controllers/ms/sadd/index.md | 43 ++++ doc/6/controllers/ms/sadd/snippets/sadd.js | 12 + .../ms/sadd/snippets/sadd.test.yml | 12 + doc/6/controllers/ms/scan/index.md | 52 ++++ doc/6/controllers/ms/scan/snippets/scan.js | 14 ++ .../ms/scan/snippets/scan.test.yml | 11 + doc/6/controllers/ms/scard/index.md | 40 +++ doc/6/controllers/ms/scard/snippets/scard.js | 8 + .../ms/scard/snippets/scard.test.yml | 9 + doc/6/controllers/ms/sdiff/index.md | 41 +++ doc/6/controllers/ms/sdiff/snippets/sdiff.js | 11 + .../ms/sdiff/snippets/sdiff.test.yml | 9 + doc/6/controllers/ms/sdiffstore/index.md | 44 ++++ .../ms/sdiffstore/snippets/sdiffstore.js | 13 + .../sdiffstore/snippets/sdiffstore.test.yml | 9 + doc/6/controllers/ms/set/index.md | 47 ++++ doc/6/controllers/ms/set/snippets/set.js | 8 + .../controllers/ms/set/snippets/set.test.yml | 9 + doc/6/controllers/ms/setex/index.md | 42 ++++ doc/6/controllers/ms/setex/snippets/setex.js | 11 + .../ms/setex/snippets/setex.test.yml | 11 + doc/6/controllers/ms/setnx/index.md | 41 +++ doc/6/controllers/ms/setnx/snippets/setnx.js | 12 + .../ms/setnx/snippets/setnx.test.yml | 12 + doc/6/controllers/ms/sinter/index.md | 40 +++ .../controllers/ms/sinter/snippets/sinter.js | 9 + .../ms/sinter/snippets/sinter.test.yml | 9 + doc/6/controllers/ms/sinterstore/index.md | 43 ++++ .../ms/sinterstore/snippets/sinterstore.js | 12 + .../sinterstore/snippets/sinterstore.test.yml | 11 + doc/6/controllers/ms/sismember/index.md | 41 +++ .../ms/sismember/snippets/sismember.js | 11 + .../ms/sismember/snippets/sismember.test.yml | 11 + doc/6/controllers/ms/smembers/index.md | 40 +++ .../ms/smembers/snippets/smembers.js | 8 + .../ms/smembers/snippets/smembers.test.yml | 9 + doc/6/controllers/ms/smove/index.md | 42 ++++ doc/6/controllers/ms/smove/snippets/smove.js | 14 ++ .../ms/smove/snippets/smove.test.yml | 11 + doc/6/controllers/ms/sort/index.md | 46 ++++ doc/6/controllers/ms/sort/snippets/sort.js | 12 + .../ms/sort/snippets/sort.test.yml | 11 + doc/6/controllers/ms/spop/index.md | 41 +++ doc/6/controllers/ms/spop/snippets/spop.js | 14 ++ .../ms/spop/snippets/spop.test.yml | 12 + doc/6/controllers/ms/srandmember/index.md | 39 +++ .../ms/srandmember/snippets/srandmember.js | 12 + .../srandmember/snippets/srandmember.test.yml | 11 + doc/6/controllers/ms/srem/index.md | 41 +++ doc/6/controllers/ms/srem/snippets/srem.js | 11 + .../ms/srem/snippets/srem.test.yml | 11 + doc/6/controllers/ms/sscan/index.md | 53 ++++ doc/6/controllers/ms/sscan/snippets/sscan.js | 12 + .../ms/sscan/snippets/sscan.test.yml | 11 + doc/6/controllers/ms/strlen/index.md | 40 +++ .../controllers/ms/strlen/snippets/strlen.js | 8 + .../ms/strlen/snippets/strlen.test.yml | 9 + doc/6/controllers/ms/sunion/index.md | 40 +++ .../controllers/ms/sunion/snippets/sunion.js | 10 + .../ms/sunion/snippets/sunion.test.yml | 9 + doc/6/controllers/ms/sunionstore/index.md | 43 ++++ .../ms/sunionstore/snippets/sunionstore.js | 16 ++ .../sunionstore/snippets/sunionstore.test.yml | 11 + doc/6/controllers/ms/time/index.md | 42 ++++ doc/6/controllers/ms/time/snippets/time.js | 8 + .../ms/time/snippets/time.test.yml | 10 + doc/6/controllers/ms/touch/index.md | 40 +++ doc/6/controllers/ms/touch/snippets/touch.js | 9 + .../ms/touch/snippets/touch.test.yml | 9 + doc/6/controllers/ms/ttl/index.md | 40 +++ doc/6/controllers/ms/ttl/snippets/ttl.js | 8 + .../controllers/ms/ttl/snippets/ttl.test.yml | 9 + doc/6/controllers/ms/type/index.md | 40 +++ doc/6/controllers/ms/type/snippets/type.js | 16 ++ .../ms/type/snippets/type.test.yml | 12 + doc/6/controllers/ms/zadd/index.md | 60 +++++ doc/6/controllers/ms/zadd/snippets/zadd.js | 15 ++ .../ms/zadd/snippets/zadd.test.yml | 12 + doc/6/controllers/ms/zcard/index.md | 40 +++ doc/6/controllers/ms/zcard/snippets/zcard.js | 12 + .../ms/zcard/snippets/zcard.test.yml | 9 + doc/6/controllers/ms/zcount/index.md | 42 ++++ .../controllers/ms/zcount/snippets/zcount.js | 13 + .../ms/zcount/snippets/zcount.test.yml | 9 + doc/6/controllers/ms/zincrby/index.md | 42 ++++ .../ms/zincrby/snippets/zincrby.js | 17 ++ .../ms/zincrby/snippets/zincrby.test.yml | 12 + doc/6/controllers/ms/zinterstore/index.md | 43 ++++ .../ms/zinterstore/snippets/zinterstore.js | 34 +++ .../zinterstore/snippets/zinterstore.test.yml | 13 + doc/6/controllers/ms/zlexcount/index.md | 44 ++++ .../ms/zlexcount/snippets/zlexcount.js | 14 ++ .../ms/zlexcount/snippets/zlexcount.test.yml | 9 + doc/6/controllers/ms/zrange/index.md | 42 ++++ .../controllers/ms/zrange/snippets/zrange.js | 14 ++ .../ms/zrange/snippets/zrange.test.yml | 11 + doc/6/controllers/ms/zrangebylex/index.md | 45 ++++ .../ms/zrangebylex/snippets/zrangebylex.js | 14 ++ .../zrangebylex/snippets/zrangebylex.test.yml | 9 + doc/6/controllers/ms/zrangebyscore/index.md | 47 ++++ .../zrangebyscore/snippets/zrangebyscore.js | 14 ++ .../snippets/zrangebyscore.test.yml | 11 + doc/6/controllers/ms/zrank/index.md | 41 +++ doc/6/controllers/ms/zrank/snippets/zrank.js | 15 ++ .../ms/zrank/snippets/zrank.test.yml | 11 + doc/6/controllers/ms/zrem/index.md | 41 +++ doc/6/controllers/ms/zrem/snippets/zrem.js | 14 ++ .../ms/zrem/snippets/zrem.test.yml | 9 + doc/6/controllers/ms/zremrangebylex/index.md | 44 ++++ .../zremrangebylex/snippets/zremrangebylex.js | 14 ++ .../snippets/zremrangebylex.test.yml | 9 + doc/6/controllers/ms/zremrangebyrank/index.md | 44 ++++ .../snippets/zremrangebyrank.js | 14 ++ .../snippets/zremrangebyrank.test.yml | 9 + .../controllers/ms/zremrangebyscore/index.md | 44 ++++ .../snippets/zremrangebyscore.js | 14 ++ .../snippets/zremrangebyscore.test.yml | 9 + doc/6/controllers/ms/zrevrange/index.md | 42 ++++ .../ms/zrevrange/snippets/zrevrange.js | 14 ++ .../ms/zrevrange/snippets/zrevrange.test.yml | 10 + doc/6/controllers/ms/zrevrangebylex/index.md | 45 ++++ .../zrevrangebylex/snippets/zrevrangebylex.js | 14 ++ .../snippets/zrevrangebylex.test.yml | 9 + .../controllers/ms/zrevrangebyscore/index.md | 43 ++++ .../snippets/zrevrangebyscore.js | 14 ++ .../snippets/zrevrangebyscore.test.yml | 12 + doc/6/controllers/ms/zrevrank/index.md | 41 +++ .../ms/zrevrank/snippets/zrevrank.js | 15 ++ .../ms/zrevrank/snippets/zrevrank.test.yml | 12 + doc/6/controllers/ms/zscan/index.md | 53 ++++ doc/6/controllers/ms/zscan/snippets/zscan.js | 16 ++ .../ms/zscan/snippets/zscan.test.yml | 11 + doc/6/controllers/ms/zscore/index.md | 41 +++ .../controllers/ms/zscore/snippets/zscore.js | 15 ++ .../ms/zscore/snippets/zscore.test.yml | 11 + doc/6/controllers/ms/zunionstore/index.md | 43 ++++ .../ms/zunionstore/snippets/zunionstore.js | 35 +++ .../zunionstore/snippets/zunionstore.test.yml | 15 ++ doc/6/controllers/realtime/count/index.md | 39 +++ .../realtime/count/snippets/count.js | 14 ++ .../realtime/count/snippets/count.test.yml | 10 + doc/6/controllers/realtime/index.md | 8 + doc/6/controllers/realtime/publish/index.md | 45 ++++ .../realtime/publish/snippets/publish.js | 13 + .../publish/snippets/publish.test.yml | 10 + doc/6/controllers/realtime/subscribe/index.md | 64 +++++ .../document-notifications-leave-scope.js | 48 ++++ ...ocument-notifications-leave-scope.test.yml | 10 + .../snippets/document-notifications.js | 46 ++++ .../snippets/document-notifications.test.yml | 10 + .../snippets/message-notifications.js | 43 ++++ .../snippets/message-notifications.test.yml | 10 + .../subscribe/snippets/user-notifications.js | 42 ++++ .../snippets/user-notifications.test.yml | 9 + .../controllers/realtime/unsubscribe/index.md | 39 +++ .../unsubscribe/snippets/unsubscribe.js | 14 ++ .../unsubscribe/snippets/unsubscribe.test.yml | 10 + .../controllers/server/admin-exists/index.md | 38 +++ .../admin-exists/snippets/admin-exists.js | 7 + .../snippets/admin-exists.test.yml | 10 + .../controllers/server/get-all-stats/index.md | 46 ++++ .../get-all-stats/snippets/get-all-stats.js | 7 + .../snippets/get-all-stats.test.yml | 10 + doc/6/controllers/server/get-config/index.md | 42 ++++ .../server/get-config/snippets/get-config.js | 7 + .../get-config/snippets/get-config.test.yml | 10 + .../server/get-last-stats/index.md | 47 ++++ .../get-last-stats/snippets/get-last-stats.js | 7 + .../snippets/get-last-stats.test.yml | 10 + doc/6/controllers/server/get-stats/index.md | 48 ++++ .../server/get-stats/snippets/get-stats.js | 7 + .../get-stats/snippets/get-stats.test.yml | 10 + doc/6/controllers/server/index.md | 8 + doc/6/controllers/server/info/index.md | 38 +++ .../controllers/server/info/snippets/info.js | 7 + .../server/info/snippets/info.test.yml | 9 + doc/6/controllers/server/now/index.md | 38 +++ doc/6/controllers/server/now/snippets/now.js | 7 + .../server/now/snippets/now.test.yml | 10 + doc/6/core-classes/base-controller/index.md | 7 + .../base-controller/introduction/index.md | 13 + .../base-controller/properties/index.md | 16 ++ .../base-controller/query/index.md | 55 ++++ doc/6/core-classes/index.md | 7 + doc/6/core-classes/kuzzle-error/index.md | 7 + .../kuzzle-error/introduction/index.md | 13 + .../kuzzle-error/properties/index.md | 16 ++ .../add-listener/index.md | 32 +++ .../add-listener/snippets/add-listener.js | 6 + .../snippets/add-listener.test.yml | 9 + .../add-once-listener/index.md | 33 +++ .../snippets/add-once-listener.js | 11 + .../snippets/add-once-listener.test.yml | 9 + .../kuzzle-event-emitter/emit/index.md | 31 +++ .../emit/snippets/emit.js | 5 + .../emit/snippets/emit.test.yml | 9 + .../kuzzle-event-emitter/index.md | 7 + .../introduction/index.md | 18 ++ .../kuzzle-event-emitter/listeners/index.md | 24 ++ .../listeners/snippets/listeners.js | 8 + .../listeners/snippets/listeners.test.yml | 9 + .../kuzzle-event-emitter/on/index.md | 10 + .../kuzzle-event-emitter/once/index.md | 10 + .../prepend-listener/index.md | 31 +++ .../snippets/prepend-listener.js | 10 + .../snippets/prepend-listener.test.yml | 11 + .../prepend-once-listener/index.md | 32 +++ .../snippets/prepend-once-listener.js | 14 ++ .../snippets/prepend-once-listener.test.yml | 12 + .../remove-all-listener/index.md | 31 +++ .../snippets/remove-all-listeners.js | 18 ++ .../snippets/remove-all-listeners.test.yml | 9 + .../remove-listener/index.md | 31 +++ .../snippets/remove-listener.js | 13 + .../snippets/remove-listener.test.yml | 9 + doc/6/core-classes/kuzzle/connect/index.md | 25 ++ .../kuzzle/connect/snippets/connect.js | 7 + .../kuzzle/connect/snippets/connect.test.yml | 11 + .../core-classes/kuzzle/constructor/index.md | 58 +++++ .../constructor/snippets/constructor.js | 25 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/6/core-classes/kuzzle/disconnect/index.md | 22 ++ .../kuzzle/disconnect/snippets/disconnect.js | 7 + .../disconnect/snippets/disconnect.test.yml | 11 + .../core-classes/kuzzle/flush-queue/index.md | 24 ++ .../flush-queue/snippets/flush-queue.js | 7 + .../flush-queue/snippets/flush-queue.test.yml | 11 + doc/6/core-classes/kuzzle/index.md | 7 + .../core-classes/kuzzle/introduction/index.md | 37 +++ doc/6/core-classes/kuzzle/play-queue/index.md | 25 ++ .../kuzzle/play-queue/snippets/play-queue.js | 7 + .../play-queue/snippets/play-queue.test.yml | 11 + doc/6/core-classes/kuzzle/properties/index.md | 86 +++++++ doc/6/core-classes/kuzzle/query/index.md | 58 +++++ .../kuzzle/query/snippets/query.js | 50 ++++ .../kuzzle/query/snippets/query.test.yml | 14 ++ .../kuzzle/start-queuing/index.md | 25 ++ .../start-queuing/snippets/start-queuing.js | 7 + .../snippets/start-queuing.test.yml | 11 + .../core-classes/kuzzle/stop-queuing/index.md | 25 ++ .../stop-queuing/snippets/stop-queuing.js | 7 + .../snippets/stop-queuing.test.yml | 11 + .../kuzzle/use-controller/index.md | 34 +++ .../use-controller/snippets/use-controller.js | 35 +++ .../snippets/use-controller.test.yml | 11 + doc/6/core-classes/profile/getRoles/index.md | 24 ++ .../profile/getRoles/snippets/getRoles.js | 28 +++ .../getRoles/snippets/getRoles.test.yml | 12 + doc/6/core-classes/profile/index.md | 7 + .../profile/introduction/index.md | 13 + .../core-classes/profile/properties/index.md | 23 ++ doc/6/core-classes/role/index.md | 7 + doc/6/core-classes/role/introduction/index.md | 13 + doc/6/core-classes/role/properties/index.md | 16 ++ doc/6/core-classes/search-result/index.md | 7 + .../search-result/introduction/index.md | 15 ++ .../core-classes/search-result/next/index.md | 63 +++++ .../search-result/next/snippets/fromsize.js | 69 +++++ .../next/snippets/fromsize.test.yml | 13 + .../search-result/next/snippets/scroll.js | 74 ++++++ .../next/snippets/scroll.test.yml | 13 + .../search-result/properties/index.md | 27 ++ doc/6/core-classes/user/getProfiles/index.md | 24 ++ .../user/getProfiles/snippets/getProfiles.js | 24 ++ .../getProfiles/snippets/getProfiles.test.yml | 12 + doc/6/core-classes/user/index.md | 7 + doc/6/core-classes/user/introduction/index.md | 18 ++ doc/6/core-classes/user/properties/index.md | 24 ++ doc/6/essentials/error-handling/index.md | 28 +++ .../snippets/error-handling-async.js | 8 + .../snippets/error-handling-async.test.yml | 10 + .../error-handling/snippets/error-handling.js | 8 + .../snippets/error-handling.test.yml | 10 + doc/6/essentials/events/index.md | 101 ++++++++ doc/6/essentials/extend-sdk/index.md | 102 ++++++++ doc/6/essentials/index.md | 7 + doc/6/essentials/offline-tools/index.md | 98 ++++++++ .../realtime-notifications/index.md | 69 +++++ doc/6/getting-started/index.md | 7 + doc/6/getting-started/node-js/index.md | 157 ++++++++++++ .../node-js/snippets/create.js | 39 +++ .../node-js/snippets/create.test.yml | 11 + .../getting-started/node-js/snippets/init.js | 37 +++ .../node-js/snippets/init.test.yml | 9 + .../node-js/snippets/load-sdk.js | 9 + .../node-js/snippets/load-sdk.test.yml | 9 + .../node-js/snippets/prepare-db.js | 20 ++ .../node-js/snippets/prepare-db.test.yml | 9 + .../node-js/snippets/subscribe.js | 51 ++++ .../node-js/snippets/subscribe.test.yml | 11 + doc/6/getting-started/raw-web/index.md | 168 +++++++++++++ .../raw-web/snippets/create.html | 31 +++ .../raw-web/snippets/create.test.yml | 12 + .../raw-web/snippets/load-sdk.html | 14 ++ .../raw-web/snippets/load-sdk.test.yml | 10 + .../raw-web/snippets/prepare-db.html | 29 +++ .../raw-web/snippets/prepare-db.test.yml | 10 + .../raw-web/snippets/subscribe.html | 32 +++ .../raw-web/snippets/subscribe.test.yml | 12 + doc/6/getting-started/webpack/index.md | 212 ++++++++++++++++ .../webpack/snippets/create.js | 33 +++ .../webpack/snippets/create.test.yml | 13 + .../webpack/snippets/init-kuzzle.js | 38 +++ .../webpack/snippets/init-kuzzle.test.yml | 10 + .../webpack/snippets/subscribe.js | 49 ++++ .../webpack/snippets/subscribe.test.yml | 14 ++ doc/6/index.md | 7 + doc/6/protocols/http/constructor/index.md | 41 +++ .../http/constructor/snippets/constructor.js | 16 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/6/protocols/http/index.md | 7 + doc/6/protocols/http/introduction/index.md | 17 ++ doc/6/protocols/http/properties/index.md | 19 ++ doc/6/protocols/index.md | 7 + doc/6/protocols/socketio/constructor/index.md | 43 ++++ .../constructor/snippets/constructor.js | 16 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/6/protocols/socketio/index.md | 7 + .../protocols/socketio/introduction/index.md | 16 ++ doc/6/protocols/socketio/properties/index.md | 22 ++ .../protocols/websocket/constructor/index.md | 44 ++++ .../constructor/snippets/constructor.js | 16 ++ .../constructor/snippets/constructor.test.yml | 10 + doc/6/protocols/websocket/index.md | 7 + .../protocols/websocket/introduction/index.md | 15 ++ doc/6/protocols/websocket/properties/index.md | 22 ++ package.json | 1 + 723 files changed, 17362 insertions(+), 4 deletions(-) create mode 100644 .ci/doc/config.yml create mode 100644 .ci/doc/docker-compose.yml create mode 100644 .ci/doc/eslint.json create mode 100644 .ci/doc/puppeteer.js create mode 100644 .ci/doc/templates/blank.tpl.js create mode 100644 .ci/doc/templates/catch.tpl.js create mode 100644 .ci/doc/templates/controller.tpl.js create mode 100644 .ci/doc/templates/createDocumentAfterSnippet.tpl.js create mode 100644 .ci/doc/templates/default.tpl.html create mode 100644 .ci/doc/templates/default.tpl.js create mode 100644 .ci/doc/templates/doIt.tpl.js create mode 100644 .ci/doc/templates/empty-realtime.tpl.js create mode 100644 .ci/doc/templates/empty.tpl.js create mode 100644 .ci/doc/templates/eventemitter.tpl.js create mode 100644 .ci/doc/templates/mqtt-end.tpl.js create mode 100644 .ci/doc/templates/realtime.tpl.js create mode 100644 .ci/doc/templates/success.tpl.js create mode 100644 .ci/doc/templates/thencatch.tpl.js create mode 100644 .ci/doc/templates/without-connect.tpl.js create mode 100644 .ci/doc/webpackBuild.js create mode 100644 .vscode/launch.json create mode 100644 doc/6/controllers/auth/check-token/index.md create mode 100644 doc/6/controllers/auth/check-token/snippets/check-token.js create mode 100644 doc/6/controllers/auth/check-token/snippets/check-token.test.yml create mode 100644 doc/6/controllers/auth/create-my-credentials/index.md create mode 100644 doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js create mode 100644 doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml create mode 100644 doc/6/controllers/auth/credentials-exist/index.md create mode 100644 doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.js create mode 100644 doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml create mode 100644 doc/6/controllers/auth/delete-my-credentials/index.md create mode 100644 doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js create mode 100644 doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml create mode 100644 doc/6/controllers/auth/get-current-user/index.md create mode 100644 doc/6/controllers/auth/get-current-user/snippets/get-current-user.js create mode 100644 doc/6/controllers/auth/get-current-user/snippets/get-current-user.test.yml create mode 100644 doc/6/controllers/auth/get-my-credentials/index.md create mode 100644 doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js create mode 100644 doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml create mode 100644 doc/6/controllers/auth/get-my-rights/index.md create mode 100644 doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.js create mode 100644 doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml create mode 100644 doc/6/controllers/auth/get-strategies/index.md create mode 100644 doc/6/controllers/auth/get-strategies/snippets/get-strategies.js create mode 100644 doc/6/controllers/auth/get-strategies/snippets/get-strategies.test.yml create mode 100644 doc/6/controllers/auth/index.md create mode 100644 doc/6/controllers/auth/login/index.md create mode 100644 doc/6/controllers/auth/login/snippets/login.js create mode 100644 doc/6/controllers/auth/login/snippets/login.test.yml create mode 100644 doc/6/controllers/auth/logout/index.md create mode 100644 doc/6/controllers/auth/logout/snippets/logout.js create mode 100644 doc/6/controllers/auth/logout/snippets/logout.test.yml create mode 100644 doc/6/controllers/auth/refresh-token/index.md create mode 100644 doc/6/controllers/auth/refresh-token/snippets/refreshToken.js create mode 100644 doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml create mode 100644 doc/6/controllers/auth/update-my-credentials/index.md create mode 100644 doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.js create mode 100644 doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml create mode 100644 doc/6/controllers/auth/update-self/index.md create mode 100644 doc/6/controllers/auth/update-self/snippets/update-self.js create mode 100644 doc/6/controllers/auth/update-self/snippets/update-self.test.yml create mode 100644 doc/6/controllers/auth/validate-my-credentials/index.md create mode 100644 doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js create mode 100644 doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml create mode 100644 doc/6/controllers/bulk/import/index.md create mode 100644 doc/6/controllers/bulk/import/snippets/import.js create mode 100644 doc/6/controllers/bulk/import/snippets/import.test.yml create mode 100644 doc/6/controllers/bulk/index.md create mode 100644 doc/6/controllers/collection/create/index.md create mode 100644 doc/6/controllers/collection/create/snippets/create.js create mode 100644 doc/6/controllers/collection/create/snippets/create.test.yml create mode 100644 doc/6/controllers/collection/delete-specifications/index.md create mode 100644 doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.js create mode 100644 doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml create mode 100644 doc/6/controllers/collection/exists/index.md create mode 100644 doc/6/controllers/collection/exists/snippets/exists.js create mode 100644 doc/6/controllers/collection/exists/snippets/exists.test.yml create mode 100644 doc/6/controllers/collection/get-mapping/index.md create mode 100644 doc/6/controllers/collection/get-mapping/snippets/get-mapping.js create mode 100644 doc/6/controllers/collection/get-mapping/snippets/get-mapping.test.yml create mode 100644 doc/6/controllers/collection/get-specifications/index.md create mode 100644 doc/6/controllers/collection/get-specifications/snippets/get-specifications.js create mode 100644 doc/6/controllers/collection/get-specifications/snippets/get-specifications.test.yml create mode 100644 doc/6/controllers/collection/index.md create mode 100644 doc/6/controllers/collection/list/index.md create mode 100644 doc/6/controllers/collection/list/snippets/list.js create mode 100644 doc/6/controllers/collection/list/snippets/list.test.yml create mode 100644 doc/6/controllers/collection/search-specifications/index.md create mode 100644 doc/6/controllers/collection/search-specifications/snippets/search-specifications.js create mode 100644 doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml create mode 100644 doc/6/controllers/collection/truncate/index.md create mode 100644 doc/6/controllers/collection/truncate/snippets/truncate.js create mode 100644 doc/6/controllers/collection/truncate/snippets/truncate.test.yml create mode 100644 doc/6/controllers/collection/update-mapping/index.md create mode 100644 doc/6/controllers/collection/update-mapping/snippets/update-mapping.js create mode 100644 doc/6/controllers/collection/update-mapping/snippets/update-mapping.test.yml create mode 100644 doc/6/controllers/collection/update-specifications/index.md create mode 100644 doc/6/controllers/collection/update-specifications/snippets/update-specifications.js create mode 100644 doc/6/controllers/collection/update-specifications/snippets/update-specifications.test.yml create mode 100644 doc/6/controllers/collection/validate-specifications/index.md create mode 100644 doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.js create mode 100644 doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml create mode 100644 doc/6/controllers/document/count/index.md create mode 100644 doc/6/controllers/document/count/snippets/count.js create mode 100644 doc/6/controllers/document/count/snippets/count.test.yml create mode 100644 doc/6/controllers/document/create/index.md create mode 100644 doc/6/controllers/document/create/snippets/create.js create mode 100644 doc/6/controllers/document/create/snippets/create.test.yml create mode 100644 doc/6/controllers/document/createOrReplace/index.md create mode 100644 doc/6/controllers/document/createOrReplace/snippets/create-or-replace.js create mode 100644 doc/6/controllers/document/createOrReplace/snippets/create-or-replace.test.yml create mode 100644 doc/6/controllers/document/delete/index.md create mode 100644 doc/6/controllers/document/delete/snippets/delete.js create mode 100644 doc/6/controllers/document/delete/snippets/delete.test.yml create mode 100644 doc/6/controllers/document/deleteByQuery/index.md create mode 100644 doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.js create mode 100644 doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml create mode 100644 doc/6/controllers/document/get/index.md create mode 100644 doc/6/controllers/document/get/snippets/get.js create mode 100644 doc/6/controllers/document/get/snippets/get.test.yml create mode 100644 doc/6/controllers/document/index.md create mode 100644 doc/6/controllers/document/mCreate/index.md create mode 100644 doc/6/controllers/document/mCreate/snippets/m-create.js create mode 100644 doc/6/controllers/document/mCreate/snippets/m-create.test.yml create mode 100644 doc/6/controllers/document/mCreateOrReplace/index.md create mode 100644 doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js create mode 100644 doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml create mode 100644 doc/6/controllers/document/mDelete/index.md create mode 100644 doc/6/controllers/document/mDelete/snippets/m-delete.js create mode 100644 doc/6/controllers/document/mDelete/snippets/m-delete.test.yml create mode 100644 doc/6/controllers/document/mGet/index.md create mode 100644 doc/6/controllers/document/mGet/snippets/m-get.js create mode 100644 doc/6/controllers/document/mGet/snippets/m-get.test.yml create mode 100644 doc/6/controllers/document/mReplace/index.md create mode 100644 doc/6/controllers/document/mReplace/snippets/m-replace.js create mode 100644 doc/6/controllers/document/mReplace/snippets/m-replace.test.yml create mode 100644 doc/6/controllers/document/mUpdate/index.md create mode 100644 doc/6/controllers/document/mUpdate/snippets/m-update.js create mode 100644 doc/6/controllers/document/mUpdate/snippets/m-update.test.yml create mode 100644 doc/6/controllers/document/replace/index.md create mode 100644 doc/6/controllers/document/replace/snippets/replace.js create mode 100644 doc/6/controllers/document/replace/snippets/replace.test.yml create mode 100644 doc/6/controllers/document/search/index.md create mode 100644 doc/6/controllers/document/search/snippets/search.js create mode 100644 doc/6/controllers/document/search/snippets/search.test.yml create mode 100644 doc/6/controllers/document/update/index.md create mode 100644 doc/6/controllers/document/update/snippets/update.js create mode 100644 doc/6/controllers/document/update/snippets/update.test.yml create mode 100644 doc/6/controllers/document/validate/index.md create mode 100644 doc/6/controllers/document/validate/snippets/validate.js create mode 100644 doc/6/controllers/document/validate/snippets/validate.test.yml create mode 100644 doc/6/controllers/index.md create mode 100644 doc/6/controllers/index/create/index.md create mode 100644 doc/6/controllers/index/create/snippets/create.js create mode 100644 doc/6/controllers/index/create/snippets/create.test.yml create mode 100644 doc/6/controllers/index/delete/index.md create mode 100644 doc/6/controllers/index/delete/snippets/delete.js create mode 100644 doc/6/controllers/index/delete/snippets/delete.test.yml create mode 100644 doc/6/controllers/index/exists/index.md create mode 100644 doc/6/controllers/index/exists/snippets/exists.js create mode 100644 doc/6/controllers/index/exists/snippets/exists.test.yml create mode 100644 doc/6/controllers/index/get-auto-refresh/index.md create mode 100644 doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js create mode 100644 doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml create mode 100644 doc/6/controllers/index/index.md create mode 100644 doc/6/controllers/index/list/index.md create mode 100644 doc/6/controllers/index/list/snippets/list.js create mode 100644 doc/6/controllers/index/list/snippets/list.test.yml create mode 100644 doc/6/controllers/index/m-delete/index.md create mode 100644 doc/6/controllers/index/m-delete/snippets/mDelete.js create mode 100644 doc/6/controllers/index/m-delete/snippets/mDelete.test.yml create mode 100644 doc/6/controllers/index/refresh-internal/index.md create mode 100644 doc/6/controllers/index/refresh-internal/snippets/refreshInternal.js create mode 100644 doc/6/controllers/index/refresh-internal/snippets/refreshInternal.test.yml create mode 100644 doc/6/controllers/index/refresh/index.md create mode 100644 doc/6/controllers/index/refresh/snippets/refresh.js create mode 100644 doc/6/controllers/index/refresh/snippets/refresh.test.yml create mode 100644 doc/6/controllers/index/set-auto-refresh/index.md create mode 100644 doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js create mode 100644 doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml create mode 100644 doc/6/controllers/ms/append/index.md create mode 100644 doc/6/controllers/ms/append/snippets/append.js create mode 100644 doc/6/controllers/ms/append/snippets/append.test.yml create mode 100644 doc/6/controllers/ms/bitcount/index.md create mode 100644 doc/6/controllers/ms/bitcount/snippets/bitcount.js create mode 100644 doc/6/controllers/ms/bitcount/snippets/bitcount.test.yml create mode 100644 doc/6/controllers/ms/bitop/index.md create mode 100644 doc/6/controllers/ms/bitop/snippets/bitop.js create mode 100644 doc/6/controllers/ms/bitop/snippets/bitop.test.yml create mode 100644 doc/6/controllers/ms/bitpos/index.md create mode 100644 doc/6/controllers/ms/bitpos/snippets/bitpos.js create mode 100644 doc/6/controllers/ms/bitpos/snippets/bitpos.test.yml create mode 100644 doc/6/controllers/ms/dbsize/index.md create mode 100644 doc/6/controllers/ms/dbsize/snippets/dbsize.js create mode 100644 doc/6/controllers/ms/dbsize/snippets/dbsize.test.yml create mode 100644 doc/6/controllers/ms/decr/index.md create mode 100644 doc/6/controllers/ms/decr/snippets/decr.js create mode 100644 doc/6/controllers/ms/decr/snippets/decr.test.yml create mode 100644 doc/6/controllers/ms/decrby/index.md create mode 100644 doc/6/controllers/ms/decrby/snippets/decrby.js create mode 100644 doc/6/controllers/ms/decrby/snippets/decrby.test.yml create mode 100644 doc/6/controllers/ms/del/index.md create mode 100644 doc/6/controllers/ms/del/snippets/del.js create mode 100644 doc/6/controllers/ms/del/snippets/del.test.yml create mode 100644 doc/6/controllers/ms/exists/index.md create mode 100644 doc/6/controllers/ms/exists/snippets/exists.js create mode 100644 doc/6/controllers/ms/exists/snippets/exists.test.yml create mode 100644 doc/6/controllers/ms/expire/index.md create mode 100644 doc/6/controllers/ms/expire/snippets/expire.js create mode 100644 doc/6/controllers/ms/expire/snippets/expire.test.yml create mode 100644 doc/6/controllers/ms/expireat/index.md create mode 100644 doc/6/controllers/ms/expireat/snippets/expireat.js create mode 100644 doc/6/controllers/ms/expireat/snippets/expireat.test.yml create mode 100644 doc/6/controllers/ms/flushdb/index.md create mode 100644 doc/6/controllers/ms/flushdb/snippets/flushdb.js create mode 100644 doc/6/controllers/ms/flushdb/snippets/flushdb.test.yml create mode 100644 doc/6/controllers/ms/geoadd/index.md create mode 100644 doc/6/controllers/ms/geoadd/snippets/geoadd.js create mode 100644 doc/6/controllers/ms/geoadd/snippets/geoadd.test.yml create mode 100644 doc/6/controllers/ms/geodist/index.md create mode 100644 doc/6/controllers/ms/geodist/snippets/geodist.js create mode 100644 doc/6/controllers/ms/geodist/snippets/geodist.test.yml create mode 100644 doc/6/controllers/ms/geohash/index.md create mode 100644 doc/6/controllers/ms/geohash/snippets/geohash.js create mode 100644 doc/6/controllers/ms/geohash/snippets/geohash.test.yml create mode 100644 doc/6/controllers/ms/geopos/index.md create mode 100644 doc/6/controllers/ms/geopos/snippets/geopos.js create mode 100644 doc/6/controllers/ms/geopos/snippets/geopos.test.yml create mode 100644 doc/6/controllers/ms/georadius/index.md create mode 100644 doc/6/controllers/ms/georadius/snippets/georadius.js create mode 100644 doc/6/controllers/ms/georadius/snippets/georadius.test.yml create mode 100644 doc/6/controllers/ms/georadiusbymember/index.md create mode 100644 doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.js create mode 100644 doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml create mode 100644 doc/6/controllers/ms/get/index.md create mode 100644 doc/6/controllers/ms/get/snippets/get.js create mode 100644 doc/6/controllers/ms/get/snippets/get.test.yml create mode 100644 doc/6/controllers/ms/getbit/index.md create mode 100644 doc/6/controllers/ms/getbit/snippets/getbit.js create mode 100644 doc/6/controllers/ms/getbit/snippets/getbit.test.yml create mode 100644 doc/6/controllers/ms/getrange/index.md create mode 100644 doc/6/controllers/ms/getrange/snippets/getrange.js create mode 100644 doc/6/controllers/ms/getrange/snippets/getrange.test.yml create mode 100644 doc/6/controllers/ms/getset/index.md create mode 100644 doc/6/controllers/ms/getset/snippets/getset.js create mode 100644 doc/6/controllers/ms/getset/snippets/getset.test.yml create mode 100644 doc/6/controllers/ms/hdel/index.md create mode 100644 doc/6/controllers/ms/hdel/snippets/hdel.js create mode 100644 doc/6/controllers/ms/hdel/snippets/hdel.test.yml create mode 100644 doc/6/controllers/ms/hexists/index.md create mode 100644 doc/6/controllers/ms/hexists/snippets/hexists.js create mode 100644 doc/6/controllers/ms/hexists/snippets/hexists.test.yml create mode 100644 doc/6/controllers/ms/hget/index.md create mode 100644 doc/6/controllers/ms/hget/snippets/hget.js create mode 100644 doc/6/controllers/ms/hget/snippets/hget.test.yml create mode 100644 doc/6/controllers/ms/hgetall/index.md create mode 100644 doc/6/controllers/ms/hgetall/snippets/hgetall.js create mode 100644 doc/6/controllers/ms/hgetall/snippets/hgetall.test.yml create mode 100644 doc/6/controllers/ms/hincrby/index.md create mode 100644 doc/6/controllers/ms/hincrby/snippets/hincrby.js create mode 100644 doc/6/controllers/ms/hincrby/snippets/hincrby.test.yml create mode 100644 doc/6/controllers/ms/hincrbyfloat/index.md create mode 100644 doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js create mode 100644 doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml create mode 100644 doc/6/controllers/ms/hkeys/index.md create mode 100644 doc/6/controllers/ms/hkeys/snippets/hkeys.js create mode 100644 doc/6/controllers/ms/hkeys/snippets/hkeys.test.yml create mode 100644 doc/6/controllers/ms/hlen/index.md create mode 100644 doc/6/controllers/ms/hlen/snippets/hlen.js create mode 100644 doc/6/controllers/ms/hlen/snippets/hlen.test.yml create mode 100644 doc/6/controllers/ms/hmget/index.md create mode 100644 doc/6/controllers/ms/hmget/snippets/hmget.js create mode 100644 doc/6/controllers/ms/hmget/snippets/hmget.test.yml create mode 100644 doc/6/controllers/ms/hmset/index.md create mode 100644 doc/6/controllers/ms/hmset/snippets/hmset.js create mode 100644 doc/6/controllers/ms/hmset/snippets/hmset.test.yml create mode 100644 doc/6/controllers/ms/hscan/index.md create mode 100644 doc/6/controllers/ms/hscan/snippets/hscan.js create mode 100644 doc/6/controllers/ms/hscan/snippets/hscan.test.yml create mode 100644 doc/6/controllers/ms/hset/index.md create mode 100644 doc/6/controllers/ms/hset/snippets/hset.js create mode 100644 doc/6/controllers/ms/hset/snippets/hset.test.yml create mode 100644 doc/6/controllers/ms/hsetnx/index.md create mode 100644 doc/6/controllers/ms/hsetnx/snippets/hsetnx.js create mode 100644 doc/6/controllers/ms/hsetnx/snippets/hsetnx.test.yml create mode 100644 doc/6/controllers/ms/hstrlen/index.md create mode 100644 doc/6/controllers/ms/hstrlen/snippets/hstrlen.js create mode 100644 doc/6/controllers/ms/hstrlen/snippets/hstrlen.test.yml create mode 100644 doc/6/controllers/ms/hvals/index.md create mode 100644 doc/6/controllers/ms/hvals/snippets/hvals.js create mode 100644 doc/6/controllers/ms/hvals/snippets/hvals.test.yml create mode 100644 doc/6/controllers/ms/incr/index.md create mode 100644 doc/6/controllers/ms/incr/snippets/incr.js create mode 100644 doc/6/controllers/ms/incr/snippets/incr.test.yml create mode 100644 doc/6/controllers/ms/incrby/index.md create mode 100644 doc/6/controllers/ms/incrby/snippets/incrby.js create mode 100644 doc/6/controllers/ms/incrby/snippets/incrby.test.yml create mode 100644 doc/6/controllers/ms/incrbyfloat/index.md create mode 100644 doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.js create mode 100644 doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml create mode 100644 doc/6/controllers/ms/index.md create mode 100644 doc/6/controllers/ms/keys/index.md create mode 100644 doc/6/controllers/ms/keys/snippets/keys.js create mode 100644 doc/6/controllers/ms/keys/snippets/keys.test.yml create mode 100644 doc/6/controllers/ms/lindex/index.md create mode 100644 doc/6/controllers/ms/lindex/snippets/lindex.js create mode 100644 doc/6/controllers/ms/lindex/snippets/lindex.test.yml create mode 100644 doc/6/controllers/ms/linsert/index.md create mode 100644 doc/6/controllers/ms/linsert/snippets/linsert.js create mode 100644 doc/6/controllers/ms/linsert/snippets/linsert.test.yml create mode 100644 doc/6/controllers/ms/llen/index.md create mode 100644 doc/6/controllers/ms/llen/snippets/llen.js create mode 100644 doc/6/controllers/ms/llen/snippets/llen.test.yml create mode 100644 doc/6/controllers/ms/lpop/index.md create mode 100644 doc/6/controllers/ms/lpop/snippets/lpop.js create mode 100644 doc/6/controllers/ms/lpop/snippets/lpop.test.yml create mode 100644 doc/6/controllers/ms/lpush/index.md create mode 100644 doc/6/controllers/ms/lpush/snippets/lpush.js create mode 100644 doc/6/controllers/ms/lpush/snippets/lpush.test.yml create mode 100644 doc/6/controllers/ms/lpushx/index.md create mode 100644 doc/6/controllers/ms/lpushx/snippets/lpushx.js create mode 100644 doc/6/controllers/ms/lpushx/snippets/lpushx.test.yml create mode 100644 doc/6/controllers/ms/lrange/index.md create mode 100644 doc/6/controllers/ms/lrange/snippets/lrange.js create mode 100644 doc/6/controllers/ms/lrange/snippets/lrange.test.yml create mode 100644 doc/6/controllers/ms/lrem/index.md create mode 100644 doc/6/controllers/ms/lrem/snippets/lrem.js create mode 100644 doc/6/controllers/ms/lrem/snippets/lrem.test.yml create mode 100644 doc/6/controllers/ms/lset/index.md create mode 100644 doc/6/controllers/ms/lset/snippets/lset.js create mode 100644 doc/6/controllers/ms/lset/snippets/lset.test.yml create mode 100644 doc/6/controllers/ms/ltrim/index.md create mode 100644 doc/6/controllers/ms/ltrim/snippets/ltrim.js create mode 100644 doc/6/controllers/ms/ltrim/snippets/ltrim.test.yml create mode 100644 doc/6/controllers/ms/mget/index.md create mode 100644 doc/6/controllers/ms/mget/snippets/mget.js create mode 100644 doc/6/controllers/ms/mget/snippets/mget.test.yml create mode 100644 doc/6/controllers/ms/mset/index.md create mode 100644 doc/6/controllers/ms/mset/snippets/mset.js create mode 100644 doc/6/controllers/ms/mset/snippets/mset.test.yml create mode 100644 doc/6/controllers/ms/msetnx/index.md create mode 100644 doc/6/controllers/ms/msetnx/snippets/msetnx.js create mode 100644 doc/6/controllers/ms/msetnx/snippets/msetnx.test.yml create mode 100644 doc/6/controllers/ms/object/index.md create mode 100644 doc/6/controllers/ms/object/snippets/object.js create mode 100644 doc/6/controllers/ms/object/snippets/object.test.yml create mode 100644 doc/6/controllers/ms/persist/index.md create mode 100644 doc/6/controllers/ms/persist/snippets/persist.js create mode 100644 doc/6/controllers/ms/persist/snippets/persist.test.yml create mode 100644 doc/6/controllers/ms/pexpire/index.md create mode 100644 doc/6/controllers/ms/pexpire/snippets/pexpire.js create mode 100644 doc/6/controllers/ms/pexpire/snippets/pexpire.test.yml create mode 100644 doc/6/controllers/ms/pexpireat/index.md create mode 100644 doc/6/controllers/ms/pexpireat/snippets/pexpireat.js create mode 100644 doc/6/controllers/ms/pexpireat/snippets/pexpireat.test.yml create mode 100644 doc/6/controllers/ms/pfadd/index.md create mode 100644 doc/6/controllers/ms/pfadd/snippets/pfadd.js create mode 100644 doc/6/controllers/ms/pfadd/snippets/pfadd.test.yml create mode 100644 doc/6/controllers/ms/pfcount/index.md create mode 100644 doc/6/controllers/ms/pfcount/snippets/pfcount.js create mode 100644 doc/6/controllers/ms/pfcount/snippets/pfcount.test.yml create mode 100644 doc/6/controllers/ms/pfmerge/index.md create mode 100644 doc/6/controllers/ms/pfmerge/snippets/pfmerge.js create mode 100644 doc/6/controllers/ms/pfmerge/snippets/pfmerge.test.yml create mode 100644 doc/6/controllers/ms/ping/index.md create mode 100644 doc/6/controllers/ms/ping/snippets/ping.js create mode 100644 doc/6/controllers/ms/ping/snippets/ping.test.yml create mode 100644 doc/6/controllers/ms/psetex/index.md create mode 100644 doc/6/controllers/ms/psetex/snippets/psetex.js create mode 100644 doc/6/controllers/ms/psetex/snippets/psetex.test.yml create mode 100644 doc/6/controllers/ms/pttl/index.md create mode 100644 doc/6/controllers/ms/pttl/snippets/pttl.js create mode 100644 doc/6/controllers/ms/pttl/snippets/pttl.test.yml create mode 100644 doc/6/controllers/ms/randomkey/index.md create mode 100644 doc/6/controllers/ms/randomkey/snippets/randomkey.js create mode 100644 doc/6/controllers/ms/randomkey/snippets/randomkey.test.yml create mode 100644 doc/6/controllers/ms/rename/index.md create mode 100644 doc/6/controllers/ms/rename/snippets/rename.js create mode 100644 doc/6/controllers/ms/rename/snippets/rename.test.yml create mode 100644 doc/6/controllers/ms/renamenx/index.md create mode 100644 doc/6/controllers/ms/renamenx/snippets/renamenx.js create mode 100644 doc/6/controllers/ms/renamenx/snippets/renamenx.test.yml create mode 100644 doc/6/controllers/ms/rpop/index.md create mode 100644 doc/6/controllers/ms/rpop/snippets/rpop.js create mode 100644 doc/6/controllers/ms/rpop/snippets/rpop.test.yml create mode 100644 doc/6/controllers/ms/rpoplpush/index.md create mode 100644 doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.js create mode 100644 doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml create mode 100644 doc/6/controllers/ms/rpush/index.md create mode 100644 doc/6/controllers/ms/rpush/snippets/rpush.js create mode 100644 doc/6/controllers/ms/rpush/snippets/rpush.test.yml create mode 100644 doc/6/controllers/ms/rpushx/index.md create mode 100644 doc/6/controllers/ms/rpushx/snippets/rpushx.js create mode 100644 doc/6/controllers/ms/rpushx/snippets/rpushx.test.yml create mode 100644 doc/6/controllers/ms/sadd/index.md create mode 100644 doc/6/controllers/ms/sadd/snippets/sadd.js create mode 100644 doc/6/controllers/ms/sadd/snippets/sadd.test.yml create mode 100644 doc/6/controllers/ms/scan/index.md create mode 100644 doc/6/controllers/ms/scan/snippets/scan.js create mode 100644 doc/6/controllers/ms/scan/snippets/scan.test.yml create mode 100644 doc/6/controllers/ms/scard/index.md create mode 100644 doc/6/controllers/ms/scard/snippets/scard.js create mode 100644 doc/6/controllers/ms/scard/snippets/scard.test.yml create mode 100644 doc/6/controllers/ms/sdiff/index.md create mode 100644 doc/6/controllers/ms/sdiff/snippets/sdiff.js create mode 100644 doc/6/controllers/ms/sdiff/snippets/sdiff.test.yml create mode 100644 doc/6/controllers/ms/sdiffstore/index.md create mode 100644 doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.js create mode 100644 doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml create mode 100644 doc/6/controllers/ms/set/index.md create mode 100644 doc/6/controllers/ms/set/snippets/set.js create mode 100644 doc/6/controllers/ms/set/snippets/set.test.yml create mode 100644 doc/6/controllers/ms/setex/index.md create mode 100644 doc/6/controllers/ms/setex/snippets/setex.js create mode 100644 doc/6/controllers/ms/setex/snippets/setex.test.yml create mode 100644 doc/6/controllers/ms/setnx/index.md create mode 100644 doc/6/controllers/ms/setnx/snippets/setnx.js create mode 100644 doc/6/controllers/ms/setnx/snippets/setnx.test.yml create mode 100644 doc/6/controllers/ms/sinter/index.md create mode 100644 doc/6/controllers/ms/sinter/snippets/sinter.js create mode 100644 doc/6/controllers/ms/sinter/snippets/sinter.test.yml create mode 100644 doc/6/controllers/ms/sinterstore/index.md create mode 100644 doc/6/controllers/ms/sinterstore/snippets/sinterstore.js create mode 100644 doc/6/controllers/ms/sinterstore/snippets/sinterstore.test.yml create mode 100644 doc/6/controllers/ms/sismember/index.md create mode 100644 doc/6/controllers/ms/sismember/snippets/sismember.js create mode 100644 doc/6/controllers/ms/sismember/snippets/sismember.test.yml create mode 100644 doc/6/controllers/ms/smembers/index.md create mode 100644 doc/6/controllers/ms/smembers/snippets/smembers.js create mode 100644 doc/6/controllers/ms/smembers/snippets/smembers.test.yml create mode 100644 doc/6/controllers/ms/smove/index.md create mode 100644 doc/6/controllers/ms/smove/snippets/smove.js create mode 100644 doc/6/controllers/ms/smove/snippets/smove.test.yml create mode 100644 doc/6/controllers/ms/sort/index.md create mode 100644 doc/6/controllers/ms/sort/snippets/sort.js create mode 100644 doc/6/controllers/ms/sort/snippets/sort.test.yml create mode 100644 doc/6/controllers/ms/spop/index.md create mode 100644 doc/6/controllers/ms/spop/snippets/spop.js create mode 100644 doc/6/controllers/ms/spop/snippets/spop.test.yml create mode 100644 doc/6/controllers/ms/srandmember/index.md create mode 100644 doc/6/controllers/ms/srandmember/snippets/srandmember.js create mode 100644 doc/6/controllers/ms/srandmember/snippets/srandmember.test.yml create mode 100644 doc/6/controllers/ms/srem/index.md create mode 100644 doc/6/controllers/ms/srem/snippets/srem.js create mode 100644 doc/6/controllers/ms/srem/snippets/srem.test.yml create mode 100644 doc/6/controllers/ms/sscan/index.md create mode 100644 doc/6/controllers/ms/sscan/snippets/sscan.js create mode 100644 doc/6/controllers/ms/sscan/snippets/sscan.test.yml create mode 100644 doc/6/controllers/ms/strlen/index.md create mode 100644 doc/6/controllers/ms/strlen/snippets/strlen.js create mode 100644 doc/6/controllers/ms/strlen/snippets/strlen.test.yml create mode 100644 doc/6/controllers/ms/sunion/index.md create mode 100644 doc/6/controllers/ms/sunion/snippets/sunion.js create mode 100644 doc/6/controllers/ms/sunion/snippets/sunion.test.yml create mode 100644 doc/6/controllers/ms/sunionstore/index.md create mode 100644 doc/6/controllers/ms/sunionstore/snippets/sunionstore.js create mode 100644 doc/6/controllers/ms/sunionstore/snippets/sunionstore.test.yml create mode 100644 doc/6/controllers/ms/time/index.md create mode 100644 doc/6/controllers/ms/time/snippets/time.js create mode 100644 doc/6/controllers/ms/time/snippets/time.test.yml create mode 100644 doc/6/controllers/ms/touch/index.md create mode 100644 doc/6/controllers/ms/touch/snippets/touch.js create mode 100644 doc/6/controllers/ms/touch/snippets/touch.test.yml create mode 100644 doc/6/controllers/ms/ttl/index.md create mode 100644 doc/6/controllers/ms/ttl/snippets/ttl.js create mode 100644 doc/6/controllers/ms/ttl/snippets/ttl.test.yml create mode 100644 doc/6/controllers/ms/type/index.md create mode 100644 doc/6/controllers/ms/type/snippets/type.js create mode 100644 doc/6/controllers/ms/type/snippets/type.test.yml create mode 100644 doc/6/controllers/ms/zadd/index.md create mode 100644 doc/6/controllers/ms/zadd/snippets/zadd.js create mode 100644 doc/6/controllers/ms/zadd/snippets/zadd.test.yml create mode 100644 doc/6/controllers/ms/zcard/index.md create mode 100644 doc/6/controllers/ms/zcard/snippets/zcard.js create mode 100644 doc/6/controllers/ms/zcard/snippets/zcard.test.yml create mode 100644 doc/6/controllers/ms/zcount/index.md create mode 100644 doc/6/controllers/ms/zcount/snippets/zcount.js create mode 100644 doc/6/controllers/ms/zcount/snippets/zcount.test.yml create mode 100644 doc/6/controllers/ms/zincrby/index.md create mode 100644 doc/6/controllers/ms/zincrby/snippets/zincrby.js create mode 100644 doc/6/controllers/ms/zincrby/snippets/zincrby.test.yml create mode 100644 doc/6/controllers/ms/zinterstore/index.md create mode 100644 doc/6/controllers/ms/zinterstore/snippets/zinterstore.js create mode 100644 doc/6/controllers/ms/zinterstore/snippets/zinterstore.test.yml create mode 100644 doc/6/controllers/ms/zlexcount/index.md create mode 100644 doc/6/controllers/ms/zlexcount/snippets/zlexcount.js create mode 100644 doc/6/controllers/ms/zlexcount/snippets/zlexcount.test.yml create mode 100644 doc/6/controllers/ms/zrange/index.md create mode 100644 doc/6/controllers/ms/zrange/snippets/zrange.js create mode 100644 doc/6/controllers/ms/zrange/snippets/zrange.test.yml create mode 100644 doc/6/controllers/ms/zrangebylex/index.md create mode 100644 doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.js create mode 100644 doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml create mode 100644 doc/6/controllers/ms/zrangebyscore/index.md create mode 100644 doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.js create mode 100644 doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml create mode 100644 doc/6/controllers/ms/zrank/index.md create mode 100644 doc/6/controllers/ms/zrank/snippets/zrank.js create mode 100644 doc/6/controllers/ms/zrank/snippets/zrank.test.yml create mode 100644 doc/6/controllers/ms/zrem/index.md create mode 100644 doc/6/controllers/ms/zrem/snippets/zrem.js create mode 100644 doc/6/controllers/ms/zrem/snippets/zrem.test.yml create mode 100644 doc/6/controllers/ms/zremrangebylex/index.md create mode 100644 doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.js create mode 100644 doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml create mode 100644 doc/6/controllers/ms/zremrangebyrank/index.md create mode 100644 doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js create mode 100644 doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml create mode 100644 doc/6/controllers/ms/zremrangebyscore/index.md create mode 100644 doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js create mode 100644 doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml create mode 100644 doc/6/controllers/ms/zrevrange/index.md create mode 100644 doc/6/controllers/ms/zrevrange/snippets/zrevrange.js create mode 100644 doc/6/controllers/ms/zrevrange/snippets/zrevrange.test.yml create mode 100644 doc/6/controllers/ms/zrevrangebylex/index.md create mode 100644 doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js create mode 100644 doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml create mode 100644 doc/6/controllers/ms/zrevrangebyscore/index.md create mode 100644 doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js create mode 100644 doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml create mode 100644 doc/6/controllers/ms/zrevrank/index.md create mode 100644 doc/6/controllers/ms/zrevrank/snippets/zrevrank.js create mode 100644 doc/6/controllers/ms/zrevrank/snippets/zrevrank.test.yml create mode 100644 doc/6/controllers/ms/zscan/index.md create mode 100644 doc/6/controllers/ms/zscan/snippets/zscan.js create mode 100644 doc/6/controllers/ms/zscan/snippets/zscan.test.yml create mode 100644 doc/6/controllers/ms/zscore/index.md create mode 100644 doc/6/controllers/ms/zscore/snippets/zscore.js create mode 100644 doc/6/controllers/ms/zscore/snippets/zscore.test.yml create mode 100644 doc/6/controllers/ms/zunionstore/index.md create mode 100644 doc/6/controllers/ms/zunionstore/snippets/zunionstore.js create mode 100644 doc/6/controllers/ms/zunionstore/snippets/zunionstore.test.yml create mode 100644 doc/6/controllers/realtime/count/index.md create mode 100644 doc/6/controllers/realtime/count/snippets/count.js create mode 100644 doc/6/controllers/realtime/count/snippets/count.test.yml create mode 100644 doc/6/controllers/realtime/index.md create mode 100644 doc/6/controllers/realtime/publish/index.md create mode 100644 doc/6/controllers/realtime/publish/snippets/publish.js create mode 100644 doc/6/controllers/realtime/publish/snippets/publish.test.yml create mode 100644 doc/6/controllers/realtime/subscribe/index.md create mode 100644 doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js create mode 100644 doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml create mode 100644 doc/6/controllers/realtime/subscribe/snippets/document-notifications.js create mode 100644 doc/6/controllers/realtime/subscribe/snippets/document-notifications.test.yml create mode 100644 doc/6/controllers/realtime/subscribe/snippets/message-notifications.js create mode 100644 doc/6/controllers/realtime/subscribe/snippets/message-notifications.test.yml create mode 100644 doc/6/controllers/realtime/subscribe/snippets/user-notifications.js create mode 100644 doc/6/controllers/realtime/subscribe/snippets/user-notifications.test.yml create mode 100644 doc/6/controllers/realtime/unsubscribe/index.md create mode 100644 doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.js create mode 100644 doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml create mode 100644 doc/6/controllers/server/admin-exists/index.md create mode 100644 doc/6/controllers/server/admin-exists/snippets/admin-exists.js create mode 100644 doc/6/controllers/server/admin-exists/snippets/admin-exists.test.yml create mode 100644 doc/6/controllers/server/get-all-stats/index.md create mode 100644 doc/6/controllers/server/get-all-stats/snippets/get-all-stats.js create mode 100644 doc/6/controllers/server/get-all-stats/snippets/get-all-stats.test.yml create mode 100644 doc/6/controllers/server/get-config/index.md create mode 100644 doc/6/controllers/server/get-config/snippets/get-config.js create mode 100644 doc/6/controllers/server/get-config/snippets/get-config.test.yml create mode 100644 doc/6/controllers/server/get-last-stats/index.md create mode 100644 doc/6/controllers/server/get-last-stats/snippets/get-last-stats.js create mode 100644 doc/6/controllers/server/get-last-stats/snippets/get-last-stats.test.yml create mode 100644 doc/6/controllers/server/get-stats/index.md create mode 100644 doc/6/controllers/server/get-stats/snippets/get-stats.js create mode 100644 doc/6/controllers/server/get-stats/snippets/get-stats.test.yml create mode 100644 doc/6/controllers/server/index.md create mode 100644 doc/6/controllers/server/info/index.md create mode 100644 doc/6/controllers/server/info/snippets/info.js create mode 100644 doc/6/controllers/server/info/snippets/info.test.yml create mode 100644 doc/6/controllers/server/now/index.md create mode 100644 doc/6/controllers/server/now/snippets/now.js create mode 100644 doc/6/controllers/server/now/snippets/now.test.yml create mode 100644 doc/6/core-classes/base-controller/index.md create mode 100644 doc/6/core-classes/base-controller/introduction/index.md create mode 100644 doc/6/core-classes/base-controller/properties/index.md create mode 100644 doc/6/core-classes/base-controller/query/index.md create mode 100644 doc/6/core-classes/index.md create mode 100644 doc/6/core-classes/kuzzle-error/index.md create mode 100644 doc/6/core-classes/kuzzle-error/introduction/index.md create mode 100644 doc/6/core-classes/kuzzle-error/properties/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-once-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/emit/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/introduction/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/listeners/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/on/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/once/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/prepend-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml create mode 100644 doc/6/core-classes/kuzzle-event-emitter/remove-listener/index.md create mode 100644 doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js create mode 100644 doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml create mode 100644 doc/6/core-classes/kuzzle/connect/index.md create mode 100644 doc/6/core-classes/kuzzle/connect/snippets/connect.js create mode 100644 doc/6/core-classes/kuzzle/connect/snippets/connect.test.yml create mode 100644 doc/6/core-classes/kuzzle/constructor/index.md create mode 100644 doc/6/core-classes/kuzzle/constructor/snippets/constructor.js create mode 100644 doc/6/core-classes/kuzzle/constructor/snippets/constructor.test.yml create mode 100644 doc/6/core-classes/kuzzle/disconnect/index.md create mode 100644 doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.js create mode 100644 doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml create mode 100644 doc/6/core-classes/kuzzle/flush-queue/index.md create mode 100644 doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.js create mode 100644 doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml create mode 100644 doc/6/core-classes/kuzzle/index.md create mode 100644 doc/6/core-classes/kuzzle/introduction/index.md create mode 100644 doc/6/core-classes/kuzzle/play-queue/index.md create mode 100644 doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.js create mode 100644 doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml create mode 100644 doc/6/core-classes/kuzzle/properties/index.md create mode 100644 doc/6/core-classes/kuzzle/query/index.md create mode 100644 doc/6/core-classes/kuzzle/query/snippets/query.js create mode 100644 doc/6/core-classes/kuzzle/query/snippets/query.test.yml create mode 100644 doc/6/core-classes/kuzzle/start-queuing/index.md create mode 100644 doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.js create mode 100644 doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml create mode 100644 doc/6/core-classes/kuzzle/stop-queuing/index.md create mode 100644 doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js create mode 100644 doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml create mode 100644 doc/6/core-classes/kuzzle/use-controller/index.md create mode 100644 doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js create mode 100644 doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml create mode 100644 doc/6/core-classes/profile/getRoles/index.md create mode 100644 doc/6/core-classes/profile/getRoles/snippets/getRoles.js create mode 100644 doc/6/core-classes/profile/getRoles/snippets/getRoles.test.yml create mode 100644 doc/6/core-classes/profile/index.md create mode 100644 doc/6/core-classes/profile/introduction/index.md create mode 100644 doc/6/core-classes/profile/properties/index.md create mode 100644 doc/6/core-classes/role/index.md create mode 100644 doc/6/core-classes/role/introduction/index.md create mode 100644 doc/6/core-classes/role/properties/index.md create mode 100644 doc/6/core-classes/search-result/index.md create mode 100644 doc/6/core-classes/search-result/introduction/index.md create mode 100644 doc/6/core-classes/search-result/next/index.md create mode 100644 doc/6/core-classes/search-result/next/snippets/fromsize.js create mode 100644 doc/6/core-classes/search-result/next/snippets/fromsize.test.yml create mode 100644 doc/6/core-classes/search-result/next/snippets/scroll.js create mode 100644 doc/6/core-classes/search-result/next/snippets/scroll.test.yml create mode 100644 doc/6/core-classes/search-result/properties/index.md create mode 100644 doc/6/core-classes/user/getProfiles/index.md create mode 100644 doc/6/core-classes/user/getProfiles/snippets/getProfiles.js create mode 100644 doc/6/core-classes/user/getProfiles/snippets/getProfiles.test.yml create mode 100644 doc/6/core-classes/user/index.md create mode 100644 doc/6/core-classes/user/introduction/index.md create mode 100644 doc/6/core-classes/user/properties/index.md create mode 100644 doc/6/essentials/error-handling/index.md create mode 100644 doc/6/essentials/error-handling/snippets/error-handling-async.js create mode 100644 doc/6/essentials/error-handling/snippets/error-handling-async.test.yml create mode 100644 doc/6/essentials/error-handling/snippets/error-handling.js create mode 100644 doc/6/essentials/error-handling/snippets/error-handling.test.yml create mode 100644 doc/6/essentials/events/index.md create mode 100644 doc/6/essentials/extend-sdk/index.md create mode 100644 doc/6/essentials/index.md create mode 100644 doc/6/essentials/offline-tools/index.md create mode 100644 doc/6/essentials/realtime-notifications/index.md create mode 100644 doc/6/getting-started/index.md create mode 100644 doc/6/getting-started/node-js/index.md create mode 100644 doc/6/getting-started/node-js/snippets/create.js create mode 100644 doc/6/getting-started/node-js/snippets/create.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/init.js create mode 100644 doc/6/getting-started/node-js/snippets/init.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/load-sdk.js create mode 100644 doc/6/getting-started/node-js/snippets/load-sdk.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/prepare-db.js create mode 100644 doc/6/getting-started/node-js/snippets/prepare-db.test.yml create mode 100644 doc/6/getting-started/node-js/snippets/subscribe.js create mode 100644 doc/6/getting-started/node-js/snippets/subscribe.test.yml create mode 100644 doc/6/getting-started/raw-web/index.md create mode 100644 doc/6/getting-started/raw-web/snippets/create.html create mode 100644 doc/6/getting-started/raw-web/snippets/create.test.yml create mode 100644 doc/6/getting-started/raw-web/snippets/load-sdk.html create mode 100644 doc/6/getting-started/raw-web/snippets/load-sdk.test.yml create mode 100644 doc/6/getting-started/raw-web/snippets/prepare-db.html create mode 100644 doc/6/getting-started/raw-web/snippets/prepare-db.test.yml create mode 100644 doc/6/getting-started/raw-web/snippets/subscribe.html create mode 100644 doc/6/getting-started/raw-web/snippets/subscribe.test.yml create mode 100644 doc/6/getting-started/webpack/index.md create mode 100644 doc/6/getting-started/webpack/snippets/create.js create mode 100644 doc/6/getting-started/webpack/snippets/create.test.yml create mode 100644 doc/6/getting-started/webpack/snippets/init-kuzzle.js create mode 100644 doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml create mode 100644 doc/6/getting-started/webpack/snippets/subscribe.js create mode 100644 doc/6/getting-started/webpack/snippets/subscribe.test.yml create mode 100644 doc/6/index.md create mode 100644 doc/6/protocols/http/constructor/index.md create mode 100644 doc/6/protocols/http/constructor/snippets/constructor.js create mode 100644 doc/6/protocols/http/constructor/snippets/constructor.test.yml create mode 100644 doc/6/protocols/http/index.md create mode 100644 doc/6/protocols/http/introduction/index.md create mode 100644 doc/6/protocols/http/properties/index.md create mode 100644 doc/6/protocols/index.md create mode 100644 doc/6/protocols/socketio/constructor/index.md create mode 100644 doc/6/protocols/socketio/constructor/snippets/constructor.js create mode 100644 doc/6/protocols/socketio/constructor/snippets/constructor.test.yml create mode 100644 doc/6/protocols/socketio/index.md create mode 100644 doc/6/protocols/socketio/introduction/index.md create mode 100644 doc/6/protocols/socketio/properties/index.md create mode 100644 doc/6/protocols/websocket/constructor/index.md create mode 100644 doc/6/protocols/websocket/constructor/snippets/constructor.js create mode 100644 doc/6/protocols/websocket/constructor/snippets/constructor.test.yml create mode 100644 doc/6/protocols/websocket/index.md create mode 100644 doc/6/protocols/websocket/introduction/index.md create mode 100644 doc/6/protocols/websocket/properties/index.md diff --git a/.ci/doc/config.yml b/.ci/doc/config.yml new file mode 100644 index 000000000..4dc83e7d8 --- /dev/null +++ b/.ci/doc/config.yml @@ -0,0 +1,47 @@ +--- + +snippets: + mount: /mnt + path: doc/**/snippets/*.test.yml + templates: /mnt/.ci/doc/templates + +runners: + default: node + + node: + service: doc-runner-node + path: /var/snippets/node + lint: + global: true + cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }} + before: timeout -t 600 ash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done' + run: + cmd: node {{ snippet.source }} + before: timeout -t 600 ash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done' + + web: + service: doc-runner-web + path: /var/snippets/web + lint: + global: true + cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}/*.html + before: timeout 600 bash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done' + run: + cmd: node puppeteer.js {{ snippet.dir }}/{{ snippet.source }} + before: timeout 600 bash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done' + + webpack: + service: doc-runner-webpack + path: /var/snippets/webpack + lint: + global: true + cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }} + before: timeout 600 bash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done' + build: + cmd: node webpackBuild.js {{ snippet.dir }}/{{ snippet.source }} + before: timeout 600 bash -c 'until stat /tmp/runner_is_ready; do sleep 1; done' + run: + cmd: node puppeteer.js /tmp/{{ snippet.name }}/index.html + before: timeout 600 bash -c 'until curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done' + + diff --git a/.ci/doc/docker-compose.yml b/.ci/doc/docker-compose.yml new file mode 100644 index 000000000..d6e1c083e --- /dev/null +++ b/.ci/doc/docker-compose.yml @@ -0,0 +1,138 @@ +version: '3' + +services: + kuzzle: + image: kuzzleio/kuzzle + ports: + - '7512:7512' + cap_add: + - SYS_PTRACE + depends_on: + - redis + - elasticsearch + container_name: kuzzle + environment: + - kuzzle_services__db__client__host=http://elasticsearch:9200 + - kuzzle_services__internalCache__node__host=redis + - kuzzle_services__memoryStorage__node__host=redis + - NODE_ENV=production + + redis: + image: redis:3.2 + + elasticsearch: + image: kuzzleio/elasticsearch:5.6.10 + ulimits: + nofile: 65536 + environment: + - cluster.name=kuzzle + - 'ES_JAVA_OPTS=-Xms256m -Xmx256m' + + doc-tests: + image: kuzzleio/snippets-tests + privileged: true + ports: + - '9229:9229' + depends_on: + - kuzzle + - doc-runner-node + - doc-runner-web + - doc-runner-webpack + volumes: + - ../..:/mnt + - /var/run/docker.sock:/var/run/docker.sock + - snippets:/var/snippets + environment: + - CONFIG_FILE=/mnt/.ci/doc/config.yml + + doc-runner-node: + image: node:10-alpine + volumes: + - ../..:/mnt + - snippets:/var/snippets + command: > + ash -c ' + mkdir -p /var/snippets/node; + apk add --no-cache curl; + npm install -g eslint; + cd /var/snippets/node; + npm install \ + bluebird \ + /mnt/ \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + + doc-runner-web: + image: buildkite/puppeteer:latest + command: > + bash -c ' + mkdir -p /var/snippets/web; + apt-get update; + apt-get install -y curl; + npm install -g \ + eslint; + cd /mnt; + npm install; + cd /var/snippets/web; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/; + npm install \ + /mnt/ \ + puppeteer \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ../..:/mnt + - snippets:/var/snippets + + doc-runner-webpack: + image: buildkite/puppeteer:latest + command: > + bash -c ' + mkdir -p /var/snippets/webpack; + apt-get update; + apt-get install -y curl; + npm install -g \ + eslint; + cd /var/snippets/webpack; + cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/; + cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/; + npm install \ + /mnt/ \ + babel-loader \ + @babel/core \ + puppeteer \ + html-webpack-plugin \ + webpack \ + webpack-cli \ + eslint \ + eslint-plugin-html \ + eslint-plugin-import \ + eslint-plugin-node \ + eslint-plugin-promise \ + eslint-plugin-standard; + touch /tmp/runner_ready_to_lint; + touch /tmp/runner_is_ready; + tail -f /dev/null + ' + volumes: + - ../..:/mnt + - snippets:/var/snippets + +volumes: + snippets: diff --git a/.ci/doc/eslint.json b/.ci/doc/eslint.json new file mode 100644 index 000000000..3424a4451 --- /dev/null +++ b/.ci/doc/eslint.json @@ -0,0 +1,236 @@ +{ + "parserOptions": { + "ecmaVersion": 9, + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "module" + }, + + "env": { + "es6": true, + "node": true, + "browser": true + }, + + "plugins": ["import", "node", "promise", "standard", "html"], + + "globals": { + "document": false, + "navigator": false, + "window": false, + "KuzzleSDK": true + }, + + "rules": { + "accessor-pairs": "error", + "arrow-spacing": ["error", { "before": true, "after": true }], + "block-spacing": ["error", "always"], + "brace-style": ["error", "1tbs", { "allowSingleLine": true }], + "camelcase": ["error", { "properties": "never" }], + "comma-dangle": [ + "error", + { + "arrays": "never", + "objects": "never", + "imports": "never", + "exports": "never", + "functions": "never" + } + ], + "comma-spacing": ["error", { "before": false, "after": true }], + "comma-style": ["error", "last"], + "constructor-super": "error", + "curly": ["error", "multi-line"], + "dot-location": ["error", "property"], + "eol-last": "error", + "eqeqeq": ["error", "always", { "null": "ignore" }], + "func-call-spacing": ["error", "never"], + "generator-star-spacing": ["error", { "before": true, "after": true }], + "handle-callback-err": ["error", "^(err|error)$"], + "indent": [ + "error", + 2, + { + "SwitchCase": 1, + "VariableDeclarator": 1, + "outerIIFEBody": 1, + "MemberExpression": 1, + "FunctionDeclaration": { "parameters": 1, "body": 1 }, + "FunctionExpression": { "parameters": 1, "body": 1 }, + "CallExpression": { "arguments": 1 }, + "ArrayExpression": 1, + "ObjectExpression": 1, + "ImportDeclaration": 1, + "flatTernaryExpressions": false, + "ignoreComments": false + } + ], + "key-spacing": ["error", { "beforeColon": false, "afterColon": true }], + "keyword-spacing": ["error", { "before": true, "after": true }], + "new-cap": ["error", { "newIsCap": true, "capIsNew": false }], + "new-parens": "error", + "no-array-constructor": "error", + "no-caller": "error", + "no-class-assign": "error", + "no-compare-neg-zero": "error", + "no-cond-assign": "error", + "no-const-assign": "error", + "no-constant-condition": ["error", { "checkLoops": false }], + "no-control-regex": "error", + "no-debugger": "error", + "no-delete-var": "error", + "no-dupe-args": "error", + "no-dupe-class-members": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-empty-character-class": "error", + "no-empty-pattern": "error", + "no-eval": "error", + "no-ex-assign": "error", + "no-extend-native": "error", + "no-extra-bind": "error", + "no-extra-boolean-cast": "error", + "no-extra-parens": ["error", "functions"], + "no-fallthrough": "error", + "no-floating-decimal": "error", + "no-func-assign": "error", + "no-global-assign": "error", + "no-implied-eval": "error", + "no-inner-declarations": ["error", "functions"], + "no-invalid-regexp": "error", + "no-irregular-whitespace": "error", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": ["error", { "allowLoop": false, "allowSwitch": false }], + "no-lone-blocks": "error", + "no-mixed-operators": [ + "error", + { + "groups": [ + ["==", "!=", "===", "!==", ">", ">=", "<", "<="], + ["&&", "||"], + ["in", "instanceof"] + ], + "allowSamePrecedence": true + } + ], + "no-mixed-spaces-and-tabs": "error", + "no-multi-spaces": "error", + "no-multi-str": "error", + "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }], + "no-negated-in-lhs": "error", + "no-new": "error", + "no-new-func": "error", + "no-new-object": "error", + "no-new-require": "error", + "no-new-symbol": "error", + "no-new-wrappers": "error", + "no-obj-calls": "error", + "no-octal": "error", + "no-octal-escape": "error", + "no-path-concat": "error", + "no-proto": "error", + "no-redeclare": "error", + "no-regex-spaces": "error", + "no-return-assign": ["error", "except-parens"], + "no-return-await": "error", + "no-self-assign": "error", + "no-self-compare": "error", + "no-sequences": "error", + "no-shadow-restricted-names": "error", + "no-sparse-arrays": "error", + "no-tabs": "error", + "no-template-curly-in-string": "error", + "no-this-before-super": "error", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef": "error", + "no-undef-init": "error", + "no-unexpected-multiline": "error", + "no-unmodified-loop-condition": "error", + "no-unneeded-ternary": ["error", { "defaultAssignment": false }], + "no-unreachable": "error", + "no-unsafe-finally": "error", + "no-unsafe-negation": "error", + "no-unused-expressions": [ + "error", + { + "allowShortCircuit": true, + "allowTernary": true, + "allowTaggedTemplates": true + } + ], + "no-use-before-define": [ + "error", + { "functions": false, "classes": false, "variables": false } + ], + "no-useless-call": "error", + "no-useless-computed-key": "error", + "no-useless-constructor": "error", + "no-useless-escape": "error", + "no-useless-rename": "error", + "no-useless-return": "error", + "no-whitespace-before-property": "error", + "no-with": "error", + "object-property-newline": [ + "error", + { "allowMultiplePropertiesPerLine": true } + ], + "one-var": ["error", { "initialized": "never" }], + "operator-linebreak": [ + "error", + "after", + { "overrides": { "?": "before", ":": "before" } } + ], + "prefer-promise-reject-errors": "error", + "quotes": [ + "error", + "single", + { "avoidEscape": true, "allowTemplateLiterals": true } + ], + "rest-spread-spacing": ["error", "never"], + "semi-spacing": ["error", { "before": false, "after": true }], + "space-before-blocks": ["error", "always"], + "space-before-function-paren": ["error", "always"], + "space-in-parens": ["error", "never"], + "space-infix-ops": "error", + "space-unary-ops": ["error", { "words": true, "nonwords": false }], + "spaced-comment": [ + "error", + "always", + { + "line": { "markers": ["*package", "!", "/", ",", "="] }, + "block": { + "balanced": true, + "markers": ["*package", "!", ",", ":", "::", "flow-include"], + "exceptions": ["*"] + } + } + ], + "symbol-description": "error", + "template-curly-spacing": ["error", "never"], + "template-tag-spacing": ["error", "never"], + "unicode-bom": ["error", "never"], + "use-isnan": "error", + "valid-typeof": ["error", { "requireStringLiterals": true }], + "wrap-iife": ["error", "any", { "functionPrototypeMethods": true }], + "yield-star-spacing": ["error", "both"], + "yoda": ["error", "never"], + + "import/export": "error", + "import/first": "error", + "import/no-duplicates": "error", + "import/no-webpack-loader-syntax": "error", + + "node/no-deprecated-api": "error", + "node/process-exit-as-throw": "error", + + "promise/param-names": "error", + + "standard/array-bracket-even-spacing": ["error", "either"], + "standard/computed-property-even-spacing": ["error", "even"], + "standard/no-callback-literal": "error", + "standard/object-curly-even-spacing": ["error", "either"] + } +} diff --git a/.ci/doc/puppeteer.js b/.ci/doc/puppeteer.js new file mode 100644 index 000000000..6e7ef84b1 --- /dev/null +++ b/.ci/doc/puppeteer.js @@ -0,0 +1,38 @@ +const puppeteer = require('puppeteer'); +const renderedSnippetPath = process.argv[2]; + +const runInBrowser = async snippetPath => { + let browser; + + try { + browser = await puppeteer.launch({ + dumpio: true, + args: ['--no-sandbox'] + }); + } catch (error) { + console.error(error); + return; + } + + try { + const page = await browser.newPage(); + + page.on('error', err => { + console.error(err); + }); + + page.on('pageerror', err => { + console.error(err); + }); + + await page.goto(`file:${snippetPath}`, { + waitUntil: 'networkidle0' + }); + } catch (error) { + console.error(error); + } finally { + await browser.close(); + } +}; + +runInBrowser(renderedSnippetPath); diff --git a/.ci/doc/templates/blank.tpl.js b/.ci/doc/templates/blank.tpl.js new file mode 100644 index 000000000..351ecaebe --- /dev/null +++ b/.ci/doc/templates/blank.tpl.js @@ -0,0 +1,14 @@ +// load the Kuzzle SDK module +const + { + Kuzzle, + WebSocket, + Http + } = require('kuzzle-sdk'); + +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +[snippet-code] +console.log('Everything is ok'); diff --git a/.ci/doc/templates/catch.tpl.js b/.ci/doc/templates/catch.tpl.js new file mode 100644 index 000000000..888ecdc2a --- /dev/null +++ b/.ci/doc/templates/catch.tpl.js @@ -0,0 +1,31 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + try { + [snippet-code] + } catch (e) { + console.log('Success'); + } finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/templates/controller.tpl.js b/.ci/doc/templates/controller.tpl.js new file mode 100644 index 000000000..17a2ff24e --- /dev/null +++ b/.ci/doc/templates/controller.tpl.js @@ -0,0 +1,11 @@ +// load the Kuzzle SDK module +const + { + Kuzzle, + WebSocket, + BaseController + } = require('kuzzle-sdk'); + +BaseController.prototype.query = () => Promise.resolve(null); + +[snippet-code] diff --git a/.ci/doc/templates/createDocumentAfterSnippet.tpl.js b/.ci/doc/templates/createDocumentAfterSnippet.tpl.js new file mode 100644 index 000000000..4327ab128 --- /dev/null +++ b/.ci/doc/templates/createDocumentAfterSnippet.tpl.js @@ -0,0 +1,27 @@ +// This template imports the snippet and then creates a document in the +// 'yellow-taxi collection in the `nyc-open-data` index. + +[snippet-code] + +// Require a kuzzle instance assigning it to a weird variable to avoid collisions and create the instance. +const $k = require('kuzzle-sdk'); +const $kInstance = new $k.Kuzzle(new $k.WebSocket('kuzzle')); + +// add a listener to detect any connection problems +$kInstance.on('networkError', error => { + console.error(`[doItAndCreateDocument.tpl] Network Error: ${error}`); +}); + +$kInstance.connect().then(() => { + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + return $kInstance.document.create('nyc-open-data', 'yellow-taxi', driver); +}).catch(error => { + console.error(`[doItAndCreateDocument.tpl] Error creating document: ${error}`); +}).finally(() => { + $kInstance.disconnect(); +}); diff --git a/.ci/doc/templates/default.tpl.html b/.ci/doc/templates/default.tpl.html new file mode 100644 index 000000000..e19296a86 --- /dev/null +++ b/.ci/doc/templates/default.tpl.html @@ -0,0 +1,12 @@ + + + + + + Snippet testing + + + + [snippet-code] + + diff --git a/.ci/doc/templates/default.tpl.js b/.ci/doc/templates/default.tpl.js new file mode 100644 index 000000000..116a1203e --- /dev/null +++ b/.ci/doc/templates/default.tpl.js @@ -0,0 +1,27 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + [snippet-code] finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/templates/doIt.tpl.js b/.ci/doc/templates/doIt.tpl.js new file mode 100644 index 000000000..9194dec7a --- /dev/null +++ b/.ci/doc/templates/doIt.tpl.js @@ -0,0 +1,5 @@ +// This template expects a snippet that declares a function called doIt function +// which it calls. +[snippet-code] + +doIt(); diff --git a/.ci/doc/templates/empty-realtime.tpl.js b/.ci/doc/templates/empty-realtime.tpl.js new file mode 100644 index 000000000..f8139c144 --- /dev/null +++ b/.ci/doc/templates/empty-realtime.tpl.js @@ -0,0 +1,23 @@ +function sleep (ms, i = 0) { + setTimeout(() => { + if (i >= 150 || outputs.length > 0) { + console.log = consoleLog; + console.log(...outputs); + + // force exit: do not wait for the event loop to be empty + process.exit(0); + } + sleep(ms, ++i); + }, ms); +} + +const consoleLog = console.log; +const outputs = []; + +console.log = (...args) => { + outputs.push(...args); +}; + +[snippet-code] + +sleep(200); diff --git a/.ci/doc/templates/empty.tpl.js b/.ci/doc/templates/empty.tpl.js new file mode 100644 index 000000000..3da052031 --- /dev/null +++ b/.ci/doc/templates/empty.tpl.js @@ -0,0 +1,3 @@ +[snippet-code] + +console.log('Success'); diff --git a/.ci/doc/templates/eventemitter.tpl.js b/.ci/doc/templates/eventemitter.tpl.js new file mode 100644 index 000000000..df1a48f9f --- /dev/null +++ b/.ci/doc/templates/eventemitter.tpl.js @@ -0,0 +1,6 @@ +const + { + KuzzleEventEmitter + } = require('kuzzle-sdk'); + +[snippet-code] diff --git a/.ci/doc/templates/mqtt-end.tpl.js b/.ci/doc/templates/mqtt-end.tpl.js new file mode 100644 index 000000000..4b051836c --- /dev/null +++ b/.ci/doc/templates/mqtt-end.tpl.js @@ -0,0 +1,4 @@ +[snippet-code] finally { + console.log('Success'); + client.end(); +} diff --git a/.ci/doc/templates/realtime.tpl.js b/.ci/doc/templates/realtime.tpl.js new file mode 100644 index 000000000..2ef73a8b6 --- /dev/null +++ b/.ci/doc/templates/realtime.tpl.js @@ -0,0 +1,47 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +function sleep (ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +(async () => { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Cannot connect to Kuzzle: ${error.message}`); + } + + const consoleLog = console.log; + const outputs = []; + + console.log = (...args) => { + outputs.push(...args); + }; + + [snippet-code] finally { + for (let i = 150; i > 0 && outputs.length <= 0; --i) { + await sleep(200); + } + + console.log = consoleLog; + console.log(...outputs); + + // force exit: do not wait for the event loop to be empty + process.exit(0); + } +})(); diff --git a/.ci/doc/templates/success.tpl.js b/.ci/doc/templates/success.tpl.js new file mode 100644 index 000000000..a697cd07f --- /dev/null +++ b/.ci/doc/templates/success.tpl.js @@ -0,0 +1,32 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async function run () { + try { + await kuzzle.connect(); + } catch (error) { + console.log(`Can not connect to Kuzzle: ${error.message}`); + } + try { + [snippet-code] + console.log('Success'); + } catch (e) { + console.log(e); + } finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/templates/thencatch.tpl.js b/.ci/doc/templates/thencatch.tpl.js new file mode 100644 index 000000000..562702342 --- /dev/null +++ b/.ci/doc/templates/thencatch.tpl.js @@ -0,0 +1,28 @@ +const Bluebird = require('bluebird'); + +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +Bluebird.resolve( + kuzzle + .connect() + .then(() => { + return [snippet-code] + }) +) + .catch(() => 'nothing') + .finally(() => kuzzle.disconnect()); diff --git a/.ci/doc/templates/without-connect.tpl.js b/.ci/doc/templates/without-connect.tpl.js new file mode 100644 index 000000000..abd722bb2 --- /dev/null +++ b/.ci/doc/templates/without-connect.tpl.js @@ -0,0 +1,22 @@ +// Loads the Kuzzle SDK module and the websocket protocol +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client +const + kuzzle = new Kuzzle( + new WebSocket('kuzzle', { autoReconnect: false }) + ); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error.message}`); +}); + +(async () => { + [snippet-code] finally { + kuzzle.disconnect(); + } +})(); diff --git a/.ci/doc/webpackBuild.js b/.ci/doc/webpackBuild.js new file mode 100644 index 000000000..72038a3c2 --- /dev/null +++ b/.ci/doc/webpackBuild.js @@ -0,0 +1,53 @@ +const path = require('path'); +const webpack = require('webpack'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +const build = async file => { + const config = { + entry: file, + output: { + path: path.resolve('/tmp', path.basename(file).replace(/\.[^.]+$/, '')), + filename: 'build.js' + }, + module: { + rules: [ + { + test: /\.js$/, + loader: 'babel-loader' + } + ] + }, + devtool: 'eval-source-map', + plugins: [new HtmlWebpackPlugin()] + }; + + return new Promise((resolve, reject) => { + webpack(config, (err, stats) => { + if (err) { + if (err.details) { + return reject(err.details); + } + return reject(err.stack || err); + } + const info = stats.toJson(); + + if (stats.hasErrors()) { + return reject(info.errors); + } + + if (stats.hasWarnings()) { + return resolve(info.warnings); + } + resolve(true); + }); + }); +}; + +(async () => { + try { + await build(process.argv[2]); + } catch (e) { + console.error(e); + throw e; + } +})(); diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 4e8befb88..50c1e4867 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3' services: kuzzle: @@ -10,7 +10,6 @@ services: depends_on: - redis - elasticsearch - container_name: kuzzle environment: - kuzzle_services__db__client__host=http://elasticsearch:9200 - kuzzle_services__internalCache__node__host=redis @@ -21,9 +20,13 @@ services: image: redis:3.2 elasticsearch: - image: kuzzleio/elasticsearch:5.4.1 + image: kuzzleio/elasticsearch:5.6.10 ulimits: nofile: 65536 environment: - cluster.name=kuzzle - "ES_JAVA_OPTS=-Xms256m -Xmx256m" + +volumes: + snippets: + diff --git a/.travis.yml b/.travis.yml index ddace1a2e..03958bd10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ jobs: include: - - stage: Tests + - name: Sdk tests + stage: Tests sudo: false language: node_js node_js: 8 @@ -32,6 +33,14 @@ jobs: after_success: - cat ./coverage/lcov.info | ./node_modules/.bin/codecov + - name: Documentation tests + stage: Tests + language: node_js + node_js: 8 + + script: + - docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index + - stage: "Deploy Stable release on NPM" if: type != pull_request && branch = master sudo: false diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..a4b5bd3e9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/index.js" + } + ] +} \ No newline at end of file diff --git a/doc/6/controllers/auth/check-token/index.md b/doc/6/controllers/auth/check-token/index.md new file mode 100644 index 000000000..896cf22f4 --- /dev/null +++ b/doc/6/controllers/auth/check-token/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: checkToken +description: Checks a JWT's validity. +--- + +# checkToken + +Checks a token validity. + +If no token is provided, the SDK checks its internal authentication token. + +
+ +```js +checkToken([token]); +``` + +
+ +| Property | Type | Description | +| -------- | ----------------- | ----------- | +| `token` |
string
| Optional authentication token | + +## Resolves + +An `object` representing the token validity status + +| Name | Type | Description | +| ------------- | ------------------ | --------------------------------- | +| `valid` |
boolean
| Tell if the token is valid or not | +| `state` |
string
| Explain why the token is invalid | +|  `expires_at` |
number
| Token expiration timestamp | + +## Usage + +<<< ./snippets/check-token.js diff --git a/doc/6/controllers/auth/check-token/snippets/check-token.js b/doc/6/controllers/auth/check-token/snippets/check-token.js new file mode 100644 index 000000000..44202a1c5 --- /dev/null +++ b/doc/6/controllers/auth/check-token/snippets/check-token.js @@ -0,0 +1,23 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + const jwt = await kuzzle.auth.login('local', credentials); + + // Check the internal jwt validity + await kuzzle.auth.checkToken(); + + // Check the jwt validity + const result = await kuzzle.auth.checkToken(jwt); + console.log(result); + /* + { valid: true, expiresAt: 1540824822897 } + */ + + if (result.valid) { + console.log('Token is valid'); + } else { + console.error(`Token is invalid: ${result.state}`); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/check-token/snippets/check-token.test.yml b/doc/6/controllers/auth/check-token/snippets/check-token.test.yml new file mode 100644 index 000000000..1e603a0d7 --- /dev/null +++ b/doc/6/controllers/auth/check-token/snippets/check-token.test.yml @@ -0,0 +1,11 @@ +--- +name: auth#checkToken +description: Checks a JWT token's validity. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Token is valid + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/create-my-credentials/index.md b/doc/6/controllers/auth/create-my-credentials/index.md new file mode 100644 index 000000000..57c5954ea --- /dev/null +++ b/doc/6/controllers/auth/create-my-credentials/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: createMyCredentials +description: Create the current user's credentials for the specified strategy. +--- + +# createMyCredentials + +Creates new credentials for the specified strategy for the current user. + +
+ +```js +createMyCredentials(strategy, credentials, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `credentials` |
object
| New credentials | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +An `object` representing the new credentials. +The content depends on the authentication strategy. + +## Usage + +<<< ./snippets/create-my-credentials.js diff --git a/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js new file mode 100644 index 000000000..e2213a48c --- /dev/null +++ b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.js @@ -0,0 +1,11 @@ +const credentials = { username: 'foo', password: 'bar' }; + +await kuzzle.auth.login('local', credentials); + +const response = await kuzzle.auth.createMyCredentials('other', credentials); +console.log(response); +/* + { username: 'foo', kuid: 'AVkDBl3YsT6qHI7MxLz0' } +*/ + +console.log('Credentials successfully created'); diff --git a/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml new file mode 100644 index 000000000..fe731bd48 --- /dev/null +++ b/doc/6/controllers/auth/create-my-credentials/snippets/create-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#createMyCredentials +description: Creates the current user's credentials for the specified strategy +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: catch +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/credentials-exist/index.md b/doc/6/controllers/auth/credentials-exist/index.md new file mode 100644 index 000000000..9c7d5c198 --- /dev/null +++ b/doc/6/controllers/auth/credentials-exist/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: credentialsExist +description: Check that the current user has credentials for the specified strategy +--- + +# credentialsExist + +Checks that the current authenticated user has credentials for the specified authentication strategy. + +
+ +```js +credentialsExist(strategy, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | --------------- | +| `local` |
string
| Strategy to use | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to `true` if the credentials exist, `false` otherwise. + +## Usage + +<<< ./snippets/credentials-exist.js diff --git a/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.js b/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.js new file mode 100644 index 000000000..e194679cd --- /dev/null +++ b/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.js @@ -0,0 +1,13 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const exists = await kuzzle.auth.credentialsExist('local'); + + if (exists === true) { + console.log('Credentials exist'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml b/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml new file mode 100644 index 000000000..a1e62d66d --- /dev/null +++ b/doc/6/controllers/auth/credentials-exist/snippets/credentials-exist.test.yml @@ -0,0 +1,10 @@ +name: auth#credentialsExist +description: Checks a JWT token's validity. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Credentials exist + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/delete-my-credentials/index.md b/doc/6/controllers/auth/delete-my-credentials/index.md new file mode 100644 index 000000000..a465a5b00 --- /dev/null +++ b/doc/6/controllers/auth/delete-my-credentials/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: deleteMyCredentials +description: Deletes credentials for a specific strategy, associated to the current user +--- + +# deleteMyCredentials + +Deletes credentials for a specific strategy associated to the current user. + +Deleting credantials, doesn't revoke existing/active JWT tokens. + +If the credentials that generated the current JWT are removed, the user will remain logged in until they log out or their session expire. After that, they will no longer be able to log in with the deleted credentials. + +
+ +```js +deleteMyCredentials(strategy, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +A `boolean` indicating if the credentials are being deleted. + +## Usage + +<<< ./snippets/delete-my-credentials.js diff --git a/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js b/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js new file mode 100644 index 000000000..fc0ac408b --- /dev/null +++ b/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.js @@ -0,0 +1,13 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const success = await kuzzle.auth.deleteMyCredentials('local'); + console.log(success); + if (success === true) { + console.log('Credentials successfully deleted'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml b/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml new file mode 100644 index 000000000..2b5b741ae --- /dev/null +++ b/doc/6/controllers/auth/delete-my-credentials/snippets/delete-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#deleteMyCredentials +description: Deletes the current user's credentials for the specified strategy +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Credentials successfully deleted + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/get-current-user/index.md b/doc/6/controllers/auth/get-current-user/index.md new file mode 100644 index 000000000..d7cec9938 --- /dev/null +++ b/doc/6/controllers/auth/get-current-user/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: getCurrentUser +description: Returns the profile object for the user linked to the json web token +--- + +# getCurrentUser + +Returns information about the currently logged in user. + +
+ +```js +getCurrentUser([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +A [User](/sdk/js/6/core-classes/user) representing the current user logged with the SDK. + +## Usage + +<<< ./snippets/get-current-user.js diff --git a/doc/6/controllers/auth/get-current-user/snippets/get-current-user.js b/doc/6/controllers/auth/get-current-user/snippets/get-current-user.js new file mode 100644 index 000000000..ee93620ed --- /dev/null +++ b/doc/6/controllers/auth/get-current-user/snippets/get-current-user.js @@ -0,0 +1,23 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.getCurrentUser(); + console.log(user); + /* + User { + _id: 'foo', + content: + { profileIds: [ 'default' ], + _kuzzle_info: + { author: '-1', + createdAt: 1540210776636, + updatedAt: null, + updater: null } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/get-current-user/snippets/get-current-user.test.yml b/doc/6/controllers/auth/get-current-user/snippets/get-current-user.test.yml new file mode 100644 index 000000000..dc3dcf93f --- /dev/null +++ b/doc/6/controllers/auth/get-current-user/snippets/get-current-user.test.yml @@ -0,0 +1,10 @@ +name: auth#getCurrentUser +description: Returns the profile object for the user linked to the `json web token` +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/get-my-credentials/index.md b/doc/6/controllers/auth/get-my-credentials/index.md new file mode 100644 index 000000000..a5a4a3aef --- /dev/null +++ b/doc/6/controllers/auth/get-my-credentials/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: getMyCredentials +description: Returns the current user's credential information for the specified strategy. +--- + +# getMyCredentials + +Returns credentials information for the currently logged in user. + +The returned data depends on the given authentication strategy, and should never include any sensitive information. + +The result can be an empty object. + +
+ +```js +getMyCredentials(strategy, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +An `object` representing the credentials for the provided authentication strategy. +Its content depends on the authentication strategy. + +## Usage + +<<< ./snippets/get-my-credentials.js diff --git a/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js new file mode 100644 index 000000000..9f6888f41 --- /dev/null +++ b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.js @@ -0,0 +1,15 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const localCredentials = await kuzzle.auth.getMyCredentials('local'); + console.log(localCredentials); + /* + { username: 'foo', kuid: 'AVkDBl3YsT6qHI7MxLz0' } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml new file mode 100644 index 000000000..e43b7ca38 --- /dev/null +++ b/doc/6/controllers/auth/get-my-credentials/snippets/get-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#getMyCredentials +description: Returns the current user's credential information for the specified ``. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/get-my-rights/index.md b/doc/6/controllers/auth/get-my-rights/index.md new file mode 100644 index 000000000..f8fa73bdb --- /dev/null +++ b/doc/6/controllers/auth/get-my-rights/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: getMyRights +description: Returns the rights for the user linked to the `JSON Web Token`. +--- + +# getMyRights + +Returns the exhaustive list of granted or denied rights for the currently logged in user. + +
+ +```js +getMyRights([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +An `object[]` containing: + +| Property | Type | Description | +| ------------- | ----------------- | ------------------------------------------- | +| `controller` |
string
| Controller on wich the rights are applied | +| `action` |
string
| Action on wich the rights are applied | +| `index` |
string
| Index on wich the rights are applied | +|  `collection` |
string
| Collection on wich the rights are applied | +|  `value` |
string
| Rights (`allowed`, `denied`, `conditional`) | + +## Usage + +<<< ./snippets/get-my-rights.js diff --git a/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.js b/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.js new file mode 100644 index 000000000..e61d723d6 --- /dev/null +++ b/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.js @@ -0,0 +1,19 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const rights = await kuzzle.auth.getMyRights(); + console.log(rights); + /* + [ { controller: '*', + action: '*', + collection: '*', + index: '*', + value: 'allowed' } ] + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml b/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml new file mode 100644 index 000000000..059f24813 --- /dev/null +++ b/doc/6/controllers/auth/get-my-rights/snippets/get-my-rights.test.yml @@ -0,0 +1,10 @@ +name: auth#getMyRights +description: Returns the rights for the user linked to the json web token +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/get-strategies/index.md b/doc/6/controllers/auth/get-strategies/index.md new file mode 100644 index 000000000..9581ee667 --- /dev/null +++ b/doc/6/controllers/auth/get-strategies/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: getStrategies +description: Get all authentication strategies registered in Kuzzle. +--- + +# getStrategies + +Gets the exhaustive list of registered authentication strategies. + +
+ +```js +getStrategies([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type | Description | Default | +| ---------- | ------------------------------- | --------------------------------- | ------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +An array of available strategies names. + +## Usage + +<<< ./snippets/get-strategies.js diff --git a/doc/6/controllers/auth/get-strategies/snippets/get-strategies.js b/doc/6/controllers/auth/get-strategies/snippets/get-strategies.js new file mode 100644 index 000000000..ad8cb4034 --- /dev/null +++ b/doc/6/controllers/auth/get-strategies/snippets/get-strategies.js @@ -0,0 +1,15 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const strategies = await kuzzle.auth.getStrategies(); + console.log(strategies); + /* + [ 'local', 'facebook' ] + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/get-strategies/snippets/get-strategies.test.yml b/doc/6/controllers/auth/get-strategies/snippets/get-strategies.test.yml new file mode 100644 index 000000000..993d67742 --- /dev/null +++ b/doc/6/controllers/auth/get-strategies/snippets/get-strategies.test.yml @@ -0,0 +1,10 @@ +name: auth#getStrategies +description: Get all authentication strategies registered in Kuzzle +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/index.md b/doc/6/controllers/auth/index.md new file mode 100644 index 000000000..f2c86af03 --- /dev/null +++ b/doc/6/controllers/auth/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: auth +description: auth controller documentation +--- diff --git a/doc/6/controllers/auth/login/index.md b/doc/6/controllers/auth/login/index.md new file mode 100644 index 000000000..22446d6b7 --- /dev/null +++ b/doc/6/controllers/auth/login/index.md @@ -0,0 +1,51 @@ +--- +code: true +type: page +title: login +description: Authenticate a user +--- + +# login + +Authenticates a user. + +If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is set to the new authentication token. + +All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout](/sdk/js/6/controllers/auth/logout) action is called, or the `jwt` property is manually set to another value. + +## Arguments + +```js +login(strategy, [credentials], [expiresIn]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | -------------------------------------------------------------------------------------- | +| `strategy` |
string
| Name of the strategy to use | +| `credentials` |
object
|  Credentials for the strategy | +| `expiresIn` |
string
|  Expiration time in [ms library](https://www.npmjs.com/package/ms) format. (e.g. `2h`) | + +### strategy + +The name of the [authentication strategy](/core/1/guides/kuzzle-depth/authentication/) used to log the user in. + +Depending on the chosen authentication strategy, additional credential arguments may be required. +The API request example in this page provides the necessary arguments for the [`local` authentication plugin](https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local). + +Check the appropriate [authentication plugin](/core/1/plugins/guides/strategies/overview/) documentation to get the list of additional arguments to provide. + +### expiresIn + + The default value for the `expiresIn` option is defined at server level, in Kuzzle's [configuration file](/core/1/guides/essentials/configuration/). + +## Resolves + +The **login** action returns the encrypted JSON Web Token. + +## Usage + +_Local strategy login example_ + +<<< ./snippets/login.js diff --git a/doc/6/controllers/auth/login/snippets/login.js b/doc/6/controllers/auth/login/snippets/login.js new file mode 100644 index 000000000..90d725579 --- /dev/null +++ b/doc/6/controllers/auth/login/snippets/login.js @@ -0,0 +1,12 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + const jwt = await kuzzle.auth.login('local', credentials); + console.log(jwt); + /* + 'eyJhbGciOiJIUzI1NiIsIkpXVCJ9.eyJfaWQiOiJmb28iLCJpYXQiOjE.wSPmb0z2tErRdYEg' + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/login/snippets/login.test.yml b/doc/6/controllers/auth/login/snippets/login.test.yml new file mode 100644 index 000000000..8c986543f --- /dev/null +++ b/doc/6/controllers/auth/login/snippets/login.test.yml @@ -0,0 +1,11 @@ +--- +name: auth#login +description: Authenticate a user +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/logout/index.md b/doc/6/controllers/auth/logout/index.md new file mode 100644 index 000000000..42d67866c --- /dev/null +++ b/doc/6/controllers/auth/logout/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: logout +description: Revokes the user's token & unsubscribe them from registered rooms. +--- + +# logout + +Revokes the current authentication token. + +If there were any, real-time subscriptions are cancelled. + +If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is unset. + +
+ +```js +logout(); +``` + +## Usage + +<<< ./snippets/logout.js diff --git a/doc/6/controllers/auth/logout/snippets/logout.js b/doc/6/controllers/auth/logout/snippets/logout.js new file mode 100644 index 000000000..c5f06be4b --- /dev/null +++ b/doc/6/controllers/auth/logout/snippets/logout.js @@ -0,0 +1,11 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + await kuzzle.auth.logout(); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/logout/snippets/logout.test.yml b/doc/6/controllers/auth/logout/snippets/logout.test.yml new file mode 100644 index 000000000..cf6a09c0e --- /dev/null +++ b/doc/6/controllers/auth/logout/snippets/logout.test.yml @@ -0,0 +1,10 @@ +name: auth#logout +description: Revokes the user's token & unsubscribe them from registered rooms. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/refresh-token/index.md b/doc/6/controllers/auth/refresh-token/index.md new file mode 100644 index 000000000..a0b517989 --- /dev/null +++ b/doc/6/controllers/auth/refresh-token/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: refreshToken +description: Refresh an authentication token +--- + +# refreshToken + + + +Refreshes a valid, non-expired authentication token. + +If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is set to the new authentication token. + +All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout](/sdk/js/6/controllers/auth/logout) action is called, or the `jwt` property is manually set to another value. + + +## Arguments + +```js +refreshToken ([options]) +``` + +
+ +| Arguments | Type | Description | +|--------------|---------|-------------| +| `options` |
object
| Query options | + + +### options + +Additional query options + +| Property | Type
(default) | Description | +| -------------- | --------- | ------------- | +| `expiresIn` |
string
| Expiration time in [ms library](https://www.npmjs.com/package/ms) format. (e.g. `2h`) | +| `queuable` |
boolean

(`true`)| If true, queues the request during downtime, until connected to Kuzzle again | + +### expiresIn + +The default value for the `expiresIn` option is defined at server level, in Kuzzle's [configuration file](/core/1/guides/essentials/configuration/). + +## Resolves + +The `refreshToken` action resolves to a token object with the following properties: + +| Property | Type | Description | +|--------------|---------|-------------| +| `_id` |
string
| User unique identifier ([kuid](/core/1/guides/essentials/user-authentication/#kuzzle-user-identifier-kuid)) | +| `expiresAt` |
number
| Expiration timestamp in Epoch-millis format (UTC) | +| `jwt` |
string
| Authentication token | +| `ttl` |
number
| Time to live of the authentication token, in milliseconds | + +## Usage + +<<< ./snippets/refreshToken.js diff --git a/doc/6/controllers/auth/refresh-token/snippets/refreshToken.js b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.js new file mode 100644 index 000000000..778869426 --- /dev/null +++ b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.js @@ -0,0 +1,22 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + const jwt = await kuzzle.auth.login('local', credentials); + + // Prints the encrypted authentication token + console.log(jwt); + + // Note: to get a different token, you actually need to wait at least + // 1 second. Otherwise you do receive a refreshed token, but with the exact + // same caracteristics, as the key depends on the timestamp in Epoch format + await new Promise(resolve => setTimeout(resolve, 1000)); + + // Prints: + // { _id: '', + // jwt: '' + // expiresAt: 1553185334220, + // ttl: 3600000 } + console.log(await kuzzle.auth.refreshToken()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml new file mode 100644 index 000000000..be2ec825c --- /dev/null +++ b/doc/6/controllers/auth/refresh-token/snippets/refreshToken.test.yml @@ -0,0 +1,15 @@ +--- +name: auth#refreshtoken +description: Refresh a user's token +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: + - ^.*\..*$ + - ^{ _id: 'foo' + - ^\s*jwt: '.*\..*' + - ^\s*expiresAt: \d+ + - ^\s*ttl: \d+ } +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/update-my-credentials/index.md b/doc/6/controllers/auth/update-my-credentials/index.md new file mode 100644 index 000000000..06bf649ec --- /dev/null +++ b/doc/6/controllers/auth/update-my-credentials/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: updateMyCredentials +description: Update the current user's credentials for the specified strategy. +--- + +# updateMyCredentials + +Updates the credentials of the currently logged in user for the specified strategy. + +
+ +```js +updateMyCredentials(strategy, credentials, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `credentials` |
object
| New credentials | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +An `object` representing the new credentials. +The content depends on the authentication strategy. + +## Usage + +<<< ./snippets/update-my-credentials.js diff --git a/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.js b/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.js new file mode 100644 index 000000000..faa96bf0c --- /dev/null +++ b/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.js @@ -0,0 +1,18 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const response = await kuzzle.auth.updateMyCredentials( + 'local', + { password: 'worakls' } + ); + console.log(response); + /* + { username: 'foo' } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml b/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml new file mode 100644 index 000000000..43f5545c9 --- /dev/null +++ b/doc/6/controllers/auth/update-my-credentials/snippets/update-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#updateMyCredentials +description: Update the current user's credentials for the specified ``. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/update-self/index.md b/doc/6/controllers/auth/update-self/index.md new file mode 100644 index 000000000..3a041ecd7 --- /dev/null +++ b/doc/6/controllers/auth/update-self/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: updateSelf +description: Updates the current user object in Kuzzle. +--- + +# updateSelf + +Updates the currently logged in user content. + +This route cannot update the list of associated security profiles. To change a user's security profiles, the route [security:updateUser](/core/1/api/controllers/security/update-user/) must be used instead. + +
+ +```js +updateSelf(content, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ----------------------- | +| `content` |
object
| User custom information | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +A [User](/sdk/js/6/core-classes/user) representing the current user logged with the SDK. + +## Usage + +<<< ./snippets/update-self.js diff --git a/doc/6/controllers/auth/update-self/snippets/update-self.js b/doc/6/controllers/auth/update-self/snippets/update-self.js new file mode 100644 index 000000000..9be64a2da --- /dev/null +++ b/doc/6/controllers/auth/update-self/snippets/update-self.js @@ -0,0 +1,24 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.updateSelf({ hungry: 'music' }); + console.log(user); + /* + User { + _id: 'foo', + content: + { profileIds: [ 'default' ], + hungry: 'music', + _kuzzle_info: + { author: '-1', + createdAt: 1540210776636, + updatedAt: null, + updater: null } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/update-self/snippets/update-self.test.yml b/doc/6/controllers/auth/update-self/snippets/update-self.test.yml new file mode 100644 index 000000000..ac9007638 --- /dev/null +++ b/doc/6/controllers/auth/update-self/snippets/update-self.test.yml @@ -0,0 +1,10 @@ +name: auth#updateSelf +description: Updates the current user object in Kuzzle +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/auth/validate-my-credentials/index.md b/doc/6/controllers/auth/validate-my-credentials/index.md new file mode 100644 index 000000000..5ebcda913 --- /dev/null +++ b/doc/6/controllers/auth/validate-my-credentials/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: validateMyCredentials +description: Validate the current user's credentials for the specified strategy. +--- + +# validateMyCredentials + +Validates the provided credentials against a specified authentication strategy. + +This route neither creates nor modifies credentials. + +
+ +```js +validateMyCredentials(strategy, [credentials], [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ----------------- | --------------- | +| `strategy` |
string
| Strategy to use | +| `credentials` |
object
| Credentials | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to `true` if the credentials are valid, `false` otherwise. + +## Usage + +<<< ./snippets/validate-my-credentials.js diff --git a/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js b/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js new file mode 100644 index 000000000..84a5d4b0e --- /dev/null +++ b/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.js @@ -0,0 +1,13 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const valid = await kuzzle.auth.validateMyCredentials('local', credentials); + + if (valid === true) { + console.log('Credentials are valid'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml b/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml new file mode 100644 index 000000000..0f62e9367 --- /dev/null +++ b/doc/6/controllers/auth/validate-my-credentials/snippets/validate-my-credentials.test.yml @@ -0,0 +1,10 @@ +name: auth#validateMyCredentials +description: Validate the current user's credentials for the specified ``. +hooks: + before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: curl -X DELETE kuzzle:7512/users/foo +template: default +expected: Credentials are valid + +sdk: js +version: 6 diff --git a/doc/6/controllers/bulk/import/index.md b/doc/6/controllers/bulk/import/index.md new file mode 100644 index 000000000..6e53b196b --- /dev/null +++ b/doc/6/controllers/bulk/import/index.md @@ -0,0 +1,85 @@ +--- +code: true +type: page +title: import +description: Performs a bulk import on a collection +--- + +# Import + +Create, update or delete large amount of documents as fast as possible. + +This route is faster than the `document:m*` routes family (e.g. [document:mCreate](/sdk/js/6/controllers/document/mCreate)), but no real-time notifications will be generated, even if some of the documents in the import match subscription filters. + +If some documents actions fail, the client will receive a [PartialError](/core/1/api/essentials/errors/#partialerror) error. + +
+ +```js +import (bulkData, [options]) +``` + +
+ +| Arguments | Type | Description | +| ---------- | ------------------- | ----------------------------------------------- | +| `bulkData` |
object[]
| List of documents to be added to the collection | +| `options` |
object
| Query options | + +### bulkData + +This API takes a JSON array containing a list of objects working in pairs. +In each pair, the first object specifies the action to perform (the most common is `create`) and the second specifies the document itself, like in the example below: + +```js +[ + // The action object + { create: { _id: 'id', _index: 'index', _type: 'collection' } }, + // The document object + { myField: 'myValue', myOtherField: 'myOtherValue' }, + // Another action object + { create: { _id: 'another-id', _index: 'index', _type: 'collection' } }, + // Another document object + { myField: 'anotherValue', myOtherField: 'yetAnotherValue' } +]; +``` + +Note that the action object always has an attribute whose key specifies the action to take and whose value is an object specifying the location of ano object in the database (the `_index`, `_type` and `_id` tuple). Also note that, in Elasticsearch, the field `_type` correspond to `collection` in Kuzzle. + +Possible actions are `create`, `index`, `update`, `delete`. + +Learn more at [Elasticsearch Bulk API](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-bulk.html) + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +--- + +## Resolves + +An object containing information about the import status for each document. + +| Property | Type | Description | +| -------- | ------------------- | --------------------------------------------------- | +| `errors` |
boolean
| `true` if there is some errors with the import | +| `items` |
object[]
| Array of object containing document import statuses | + +Each object has the following structure: + +```js +{ + "": { + _id: "another-id", + status: 201 + } +} +``` + +## Usage + +<<< ./snippets/import.js diff --git a/doc/6/controllers/bulk/import/snippets/import.js b/doc/6/controllers/bulk/import/snippets/import.js new file mode 100644 index 000000000..a0011e997 --- /dev/null +++ b/doc/6/controllers/bulk/import/snippets/import.js @@ -0,0 +1,40 @@ +const bulkData = [ + { create: { _id: '1', _index: 'nyc-open-data', _type: 'yellow-taxi' } }, + { a: 'document', with: 'any', number: 'of fields' }, + { create: { _id: '2', _index: 'nyc-open-data', _type: 'yellow-taxi' } }, + { another: 'document' }, + { create: { _id: '3', _index: 'nyc-open-data', _type: 'yellow-taxi' } }, + { and: { another: 'one' } } +]; + +try { + const response = await kuzzle.bulk.import(bulkData); + console.log(response); + /* + { errors: false, + items: + [ { + create: { + _id: "uniq-id-1", + status: 201 + } + }, + { + create: { + _id: "uniq-id-2", + status: 201 + } + }, + { + create: { + _id: "uniq-id-3", + status: 206 + } + } ] } + */ + const successfulImport = response.items.filter(item => item.create.status === 201); + + console.log(`Successfully imported ${successfulImport.length} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/bulk/import/snippets/import.test.yml b/doc/6/controllers/bulk/import/snippets/import.test.yml new file mode 100644 index 000000000..72ef6d02f --- /dev/null +++ b/doc/6/controllers/bulk/import/snippets/import.test.yml @@ -0,0 +1,13 @@ +--- +name: bulk#import +description: Bulk imports three documents into Kuzzle +hooks: + before: | + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: curl -X DELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully imported 3 documents + +sdk: js +version: 6 diff --git a/doc/6/controllers/bulk/index.md b/doc/6/controllers/bulk/index.md new file mode 100644 index 000000000..33c10f9c7 --- /dev/null +++ b/doc/6/controllers/bulk/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: bulk +description: bulk controller documentation +--- diff --git a/doc/6/controllers/collection/create/index.md b/doc/6/controllers/collection/create/index.md new file mode 100644 index 000000000..ece434f22 --- /dev/null +++ b/doc/6/controllers/collection/create/index.md @@ -0,0 +1,67 @@ +--- +code: true +type: page +title: create +description: Create a new collection +--- + +# create + +Creates a new [collection](/core/1/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided index. + +You can also provide an optional data mapping that allow you to exploit the full capabilities of our +persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html)). + +This method will only update the mapping if the collection already exists. + +
+ +```js +create(index, collection, [mapping], [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `mapping` |
object
| Describes the data mapping to associate to the new collection, using Elasticsearch [mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html) | +| `options` |
object
| Query options | + +### mapping + +An object representing the data mapping of the collection. + +The mapping must have a root field `properties` that contain the mapping definition: + +```js +const mapping = { + properties: { + field1: { type: 'text' }, + field2: { + properties: { + nestedField: { type: 'keyword' } + } + } + } +}; +``` + +More informations about database mappings [here](/core/1/guides/essentials/database-mappings). + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves if the collection is successfully created. + +## Usage + +<<< ./snippets/create.js diff --git a/doc/6/controllers/collection/create/snippets/create.js b/doc/6/controllers/collection/create/snippets/create.js new file mode 100644 index 000000000..4c10502d6 --- /dev/null +++ b/doc/6/controllers/collection/create/snippets/create.js @@ -0,0 +1,19 @@ +const mapping = { + properties: { + license: { type: 'keyword' }, + driver: { + properties: { + name: { type: 'keyword' }, + curriculum: { type: 'text' } + } + } + } +}; + +try { + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi', mapping); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/create/snippets/create.test.yml b/doc/6/controllers/collection/create/snippets/create.test.yml new file mode 100644 index 000000000..15793fcf0 --- /dev/null +++ b/doc/6/controllers/collection/create/snippets/create.test.yml @@ -0,0 +1,10 @@ +name: collection#create +description: Create a new collection +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/delete-specifications/index.md b/doc/6/controllers/collection/delete-specifications/index.md new file mode 100644 index 000000000..3445f924b --- /dev/null +++ b/doc/6/controllers/collection/delete-specifications/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: deleteSpecifications +description: Delete validation specifications for a collection +--- + +# deleteSpecifications + +Deletes validation specifications for a collection. + +
+ +```js +deleteSpecifications(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves if successful. + +## Usage + +<<< ./snippets/delete-specifications.js diff --git a/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.js b/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.js new file mode 100644 index 000000000..6672ffd79 --- /dev/null +++ b/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.js @@ -0,0 +1,7 @@ +try { + await kuzzle.collection.deleteSpecifications('nyc-open-data', 'yellow-taxi'); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml b/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml new file mode 100644 index 000000000..5542ecfe0 --- /dev/null +++ b/doc/6/controllers/collection/delete-specifications/snippets/delete-specifications.test.yml @@ -0,0 +1,10 @@ +name: collection#deleteSpecifications +description: Delete validation specifications for a collection +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/exists/index.md b/doc/6/controllers/collection/exists/index.md new file mode 100644 index 000000000..8a8000677 --- /dev/null +++ b/doc/6/controllers/collection/exists/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: exists +description: Check if collection exists +--- + +# exists + +Check if a collection exists in Kuzzle. + +
+ +```js +exists(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to `true` if the collection exists, `false` otherwise. + +## Usage + +<<< ./snippets/exists.js diff --git a/doc/6/controllers/collection/exists/snippets/exists.js b/doc/6/controllers/collection/exists/snippets/exists.js new file mode 100644 index 000000000..167a241af --- /dev/null +++ b/doc/6/controllers/collection/exists/snippets/exists.js @@ -0,0 +1,9 @@ +try { + const exists = kuzzle.collection.exists('nyc-open-data', 'green-taxi'); + + if (exists) { + console.log('Success'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/exists/snippets/exists.test.yml b/doc/6/controllers/collection/exists/snippets/exists.test.yml new file mode 100644 index 000000000..3c3c4e32d --- /dev/null +++ b/doc/6/controllers/collection/exists/snippets/exists.test.yml @@ -0,0 +1,10 @@ +name: collection#exists +description: Check if collection exists +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/get-mapping/index.md b/doc/6/controllers/collection/get-mapping/index.md new file mode 100644 index 000000000..0f0fdcade --- /dev/null +++ b/doc/6/controllers/collection/get-mapping/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: getMapping +description: Return collection mapping +--- + +# getMapping + +Returns the collection mapping. + +
+ +```js +getMapping(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an `object` representing the collection mapping. + +## Usage + +<<< ./snippets/get-mapping.js diff --git a/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js new file mode 100644 index 000000000..772aa3455 --- /dev/null +++ b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.js @@ -0,0 +1,31 @@ +try { + const mapping = await kuzzle.collection.getMapping('nyc-open-data', 'yellow-taxi'); + console.log(mapping); + /* + { + "nyc-open-data": { + "mappings": { + "yellow-taxi": { + dynamic: 'false', + _meta: { + area: 'Panipokhari + }, + properties: { + license: { type: 'keyword' }, + driver: { + properties: { + name: { type: 'keyword' }, + curriculum: { type: 'text' } + } + } + } + } + } + } + } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/get-mapping/snippets/get-mapping.test.yml b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.test.yml new file mode 100644 index 000000000..3d0570200 --- /dev/null +++ b/doc/6/controllers/collection/get-mapping/snippets/get-mapping.test.yml @@ -0,0 +1,10 @@ +name: collection#getMapping +description: Return collection mapping +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/get-specifications/index.md b/doc/6/controllers/collection/get-specifications/index.md new file mode 100644 index 000000000..955197268 --- /dev/null +++ b/doc/6/controllers/collection/get-specifications/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: getSpecifications +description: Returns the validation specifications +--- + +# getSpecifications + +Returns the validation specifications associated to the given index and collection. + +
+ +```js +getSpecifications(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve to an object representing the collection specifications. + +## Usage + +<<< ./snippets/get-specifications.js diff --git a/doc/6/controllers/collection/get-specifications/snippets/get-specifications.js b/doc/6/controllers/collection/get-specifications/snippets/get-specifications.js new file mode 100644 index 000000000..14d0f14c7 --- /dev/null +++ b/doc/6/controllers/collection/get-specifications/snippets/get-specifications.js @@ -0,0 +1,23 @@ +try { + const specifications = await kuzzle.collection.getSpecifications('nyc-open-data', 'yellow-taxi'); + console.log(specifications); + /* + { + "collection": "yellow-taxi", + "index": "nyc-open-data", + "validation": { + "fields": { + "age": { + "defaultValue": 42, + "mandatory": true, + "type": "integer" + } + }, + "strict": true + } + } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/get-specifications/snippets/get-specifications.test.yml b/doc/6/controllers/collection/get-specifications/snippets/get-specifications.test.yml new file mode 100644 index 000000000..a50f49c51 --- /dev/null +++ b/doc/6/controllers/collection/get-specifications/snippets/get-specifications.test.yml @@ -0,0 +1,9 @@ +name: collection#getSpecifications +description: Returns the validation specifications +hooks: + before: "curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi && curl -X PUT -H \"Content-Type: application/json\" -d '{\"nyc-open-data\": {\"yellow-taxi\": {\"strict\": false,\"fields\": {\"license\": {\"type\": \"string\"}}}}}' kuzzle:7512/_specifications" + after: +template: default +expected: Success +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/index.md b/doc/6/controllers/collection/index.md new file mode 100644 index 000000000..a263a05db --- /dev/null +++ b/doc/6/controllers/collection/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: collection +description: collection controller documentation +--- diff --git a/doc/6/controllers/collection/list/index.md b/doc/6/controllers/collection/list/index.md new file mode 100644 index 000000000..c6b5f6d55 --- /dev/null +++ b/doc/6/controllers/collection/list/index.md @@ -0,0 +1,56 @@ +--- +code: true +type: page +title: list +description: Returns the collection list of an index +--- + +# list + +Returns the list of collections associated to a provided index. +The returned list is sorted in alphanumerical order. + +
+ +```js +list(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `from` |
number

(`0`) | Offset of the first result | +| `size` |
number

(`10`) | Maximum number of returned results | + +## Resolves + +Resolves to an object containing the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ------------------------------------------------------------------ | +| `type` |
string
| Types of returned collections
(`all`, `realtime` or `stored`) | +| `collections` |
object[]
| List of collections | +| `from` |
number
| Offset of the first result | +| `size` |
number
| Maximum number of returned results | + +Each object in the `collections` array contains the following properties: + +| Property | Type | Description | +| -------- | ----------------- | ---------------------------------------- | +| `name` |
string
| Collection name | +| `type` |
string
| Collection type (`realtime` or `stored`) | + +## Usage + +<<< ./snippets/list.js diff --git a/doc/6/controllers/collection/list/snippets/list.js b/doc/6/controllers/collection/list/snippets/list.js new file mode 100644 index 000000000..aa6388f3c --- /dev/null +++ b/doc/6/controllers/collection/list/snippets/list.js @@ -0,0 +1,18 @@ +try { + const options = { from: 1, size: 1 }; + + const collectionList = await kuzzle.collection.list('mtp-open-data', options); + console.log(collectionList); + /* + { + type: 'all', + collections: [ { name: 'pink-taxi', type: 'stored' } ], + from: 1, + size: 1 + } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/list/snippets/list.test.yml b/doc/6/controllers/collection/list/snippets/list.test.yml new file mode 100644 index 000000000..39641aa7b --- /dev/null +++ b/doc/6/controllers/collection/list/snippets/list.test.yml @@ -0,0 +1,10 @@ +name: collection#list +description: Returns the collection list of an index +hooks: + before: curl -X POST kuzzle:7512/mtp-open-data/_create && curl -X PUT kuzzle:7512/mtp-open-data/pink-taxi && curl -X PUT kuzzle:7512/mtp-open-data/dark-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/search-specifications/index.md b/doc/6/controllers/collection/search-specifications/index.md new file mode 100644 index 000000000..89ba5727a --- /dev/null +++ b/doc/6/controllers/collection/search-specifications/index.md @@ -0,0 +1,70 @@ +--- +code: true +type: page +title: searchSpecifications +description: Search for specifications +--- + +# searchSpecifications + + + +Searches collection specifications. + +There is a limit to how many items can be returned by a single search query. +That limit is by default set at 10000, and you can't get over it even with the from and size pagination options. + +:::info +When processing a large number of items (i.e. more than 1000), it is advised to paginate the results using [SearchResult.next](/sdk/js/6/core-classes/search-result/next/) rather than increasing the size parameter. +::: + +
+ +```js +searchSpecifications([body], [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------------------- | +| `body` |
object
| An object containing the search query | +| `options` |
object
| Query options | + +### body + +The body is a set of filters using [Elasticsearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-body.html) to match the documents you are looking for. +The filters must be inside the `query` property of the body. + +Example: + +```js +const body = { + query: { + match_all: { + boost: 1 + } + } +}; +``` + +### options + +| Arguments | Type | Description | +| ---------- | ------------------------------- | ------------------------------------ | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | +| `from` |
number

(`0`) | Offset of the first document | +| `size` |
number

(`10`) | Maximum number of documents returned | +| `scroll` |
string

| Maximum duration for scroll session | + +- `size` controls the maximum number of documents returned in the response +- `from` is usually used with the `size` argument, and defines the offset from the first result you want to fetch +- `scroll` is used to fetch large result sets, and it must be set with a [time duration](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#time-units). If set, a forward-only cursor will be created (and automatically destroyed at the end of the set duration), and its identifier will be returned in the `scrollId` property, along with the first page of the results. + +## Resolves + +Resolve to a [SpecificationsSearchResult](/sdk/js/6/core-classes/search-result). + +## Usage + +<<< ./snippets/search-specifications.js diff --git a/doc/6/controllers/collection/search-specifications/snippets/search-specifications.js b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.js new file mode 100644 index 000000000..af3c1bb4b --- /dev/null +++ b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.js @@ -0,0 +1,47 @@ +try { + const body = { + query: { + match_all: { + boost: 1 + } + } + }; + + const options = { + size: 50, + offset: 0, + scroll: '10m' + }; + + const searchResult = await kuzzle.collection.searchSpecifications(body, options); + console.log(searchResult); + /* + { + "total": 1, + "max_score": 1, + "hits": [ + { + "_index": "%kuzzle", + "_type": "validations", + "_id": "nyc-open-data#yellow-taxi", + "_score": 1, + "_source": { + "validation": { + "strict": false, + "fields": { + "license": { + "type": "string" + } + } + }, + "index": "nyc-open-data", + "collection": "yellow-taxi" + } + } + ], + "scrollId": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAACSFlgtZTJFYjNiU1FxQzhSNUFpNlZHZGcAAAAAAAAAkxZYLWUyRWIzYlNRcUM4UjVBaTZWR2RnAAAAAAAAAJQWWC1lMkViM2JTUXFDOFI1QWk2VkdkZwAAAAAAAACVFlgtZTJFYjNiU1FxQzhSNUFpNlZHZGcAAAAAAAAAlhZYLWUyRWIzYlNRcUM4UjVBaTZWR2Rn" + } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml new file mode 100644 index 000000000..f32b7aa16 --- /dev/null +++ b/doc/6/controllers/collection/search-specifications/snippets/search-specifications.test.yml @@ -0,0 +1,23 @@ +name: collection#searchSpecifications +description: Search for specifications +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -X PUT -H "Content-Type: application/json" -d '{ + "nyc-open-data": { + "yellow-taxi": { + "strict": false, + "fields": { + "license": { + "type": "string" + } + } + } + } + }' kuzzle:7512/_specifications?refresh=wait_for +template: default +expected: 'fetched: 1' +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/truncate/index.md b/doc/6/controllers/collection/truncate/index.md new file mode 100644 index 000000000..0f38bac7f --- /dev/null +++ b/doc/6/controllers/collection/truncate/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: truncate +description: Remove all documents from collection +--- + +# truncate + +Removes all documents from a collection, while keeping the associated mapping. + +
+ +```js +truncate(index, collection, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves when the collection is successfully truncated. + +## Usage + +<<< ./snippets/truncate.js diff --git a/doc/6/controllers/collection/truncate/snippets/truncate.js b/doc/6/controllers/collection/truncate/snippets/truncate.js new file mode 100644 index 000000000..84c9f8ff1 --- /dev/null +++ b/doc/6/controllers/collection/truncate/snippets/truncate.js @@ -0,0 +1,7 @@ +try { + await kuzzle.collection.truncate('nyc-open-data', 'yellow-taxi'); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/truncate/snippets/truncate.test.yml b/doc/6/controllers/collection/truncate/snippets/truncate.test.yml new file mode 100644 index 000000000..f34edd066 --- /dev/null +++ b/doc/6/controllers/collection/truncate/snippets/truncate.test.yml @@ -0,0 +1,10 @@ +name: collection#truncate +description: Remove all documents from collection +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/update-mapping/index.md b/doc/6/controllers/collection/update-mapping/index.md new file mode 100644 index 000000000..f01043b23 --- /dev/null +++ b/doc/6/controllers/collection/update-mapping/index.md @@ -0,0 +1,66 @@ +--- +code: true +type: page +title: updateMapping +description: Update the collection mapping +--- + +# updateMapping + + + +You can define the collection [dynamic mapping policy](/core/1/guides/essentials/database-mappings/#dynamic-mapping-policy) by setting the `dynamic` field to the desired value. + +You can define [collection additional metadata](/core/1/guides/essentials/database-mappings/#collection-metadata) within the `_meta` root field. + +
+ +```js +updateMapping(index, collection, mapping, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `mapping` |
object
| Describes the collection mapping | +| `options` |
object
| Query options | + +### mapping + +An object representing the collection data mapping. + +This object must have a root field `properties` that contain the mapping definition: + +```js +const mapping = { + properties: { + field1: { type: 'text' }, + field2: { + properties: { + nestedField: { type: 'keyword' } + } + } + } +}; +``` + +More informations about database mappings [here](/core/1/guides/essentials/database-mappings). + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve if the collection is successfully updated. + +## Usage + +<<< ./snippets/update-mapping.js diff --git a/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js new file mode 100644 index 000000000..d286a6c0a --- /dev/null +++ b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.js @@ -0,0 +1,17 @@ +const mapping = { + dynamic: 'false', + _meta: { + area: 'Panipokhari' + }, + properties: { + plate: { type: 'keyword' } + } +}; + +try { + await kuzzle.collection.updateMapping('nyc-open-data', 'yellow-taxi', mapping); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/update-mapping/snippets/update-mapping.test.yml b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.test.yml new file mode 100644 index 000000000..272e5e002 --- /dev/null +++ b/doc/6/controllers/collection/update-mapping/snippets/update-mapping.test.yml @@ -0,0 +1,10 @@ +name: collection#updateMapping +description: Update the collection mapping +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/update-specifications/index.md b/doc/6/controllers/collection/update-specifications/index.md new file mode 100644 index 000000000..229434640 --- /dev/null +++ b/doc/6/controllers/collection/update-specifications/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: updateSpecifications +description: Update the validation specifications +--- + +# updateSpecifications + +The updateSpecifications method allows you to create or update the validation specifications for a collection. + +When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug. + +
+ +```js +updateSpecifications(index, collection, specifications, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------------- | ----------------- | ------------------------ | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `specifications` |
object
| Specifications to update | +| `options` |
object
| Query options | + +### specifications + +An object representing the specifications. + +This object must follow the [Specification Structure](/core/1/guides/essentials/data-validation/): + +```js +{ + strict: , + fields: { + // ... specification for each field + } +} +``` + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve to an object containing the specifications. + +## Usage + +<<< ./snippets/update-specifications.js diff --git a/doc/6/controllers/collection/update-specifications/snippets/update-specifications.js b/doc/6/controllers/collection/update-specifications/snippets/update-specifications.js new file mode 100644 index 000000000..af495e99a --- /dev/null +++ b/doc/6/controllers/collection/update-specifications/snippets/update-specifications.js @@ -0,0 +1,25 @@ +const specifications = { + strict: false, + fields: { + license: { + mandatory: true, + type: 'string' + } + } +}; + +try { + const result = await kuzzle.collection.updateSpecifications('nyc-open-data', 'yellow-taxi', specifications); + console.log(result); + /* + { strict: false, + fields: { + license: { + mandatory: true, + type: 'string' } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/update-specifications/snippets/update-specifications.test.yml b/doc/6/controllers/collection/update-specifications/snippets/update-specifications.test.yml new file mode 100644 index 000000000..9a9ef7582 --- /dev/null +++ b/doc/6/controllers/collection/update-specifications/snippets/update-specifications.test.yml @@ -0,0 +1,10 @@ +name: collection#updateSpecifications +description: Update the validation specifications +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi + after: curl -X DELETE kuzzle:7512/nyc-open-data/yellow-taxi/_specifications +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/collection/validate-specifications/index.md b/doc/6/controllers/collection/validate-specifications/index.md new file mode 100644 index 000000000..23d96e712 --- /dev/null +++ b/doc/6/controllers/collection/validate-specifications/index.md @@ -0,0 +1,66 @@ +--- +code: true +type: page +title: validateSpecifications +description: Validate specifications format +--- + +# validateSpecifications + +The validateSpecifications method checks if a validation specification is well formatted. It does not store or modify the existing specification. + +When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug. + +
+ +```js +validateSpecifications(index, collection, specifications, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------------- | ----------------- | -------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `specifications` |
object
| Specifications to validate | +| `options` |
object
| Query options | + +### specifications + +An object representing the specifications. + +This object must follow the [Specification Structure](/core/1/guides/cookbooks/datavalidation): + +```js +{ + strict: , + fields: { + // ... specification for each field + } +} +``` + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an object which contain information about the specifications validity. + +It contains the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ---------------------------- | +| `valid` |
boolean
| Specifications validity | +| `details` |
string[]
| Specifications errors | +| `description` |
string
| Global description of errors | + +## Usage + +<<< ./snippets/validate-specifications.js diff --git a/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.js b/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.js new file mode 100644 index 000000000..772108c04 --- /dev/null +++ b/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.js @@ -0,0 +1,29 @@ +try { + const specifications = { + strict: false, + fields: { + license: { + mandatory: true, + type: 'symbol' // symbol is not a recognized type + } + } + }; + + const result = await kuzzle.collection.validateSpecifications('nyc-open-data', 'yellow-taxi', specifications); + console.log(result); + /* + { + valid: false, + details: [ + 'In nyc-open-data.yellow-taxi.license: symbol is not a recognized type.' + ], + description: 'Some errors with provided specifications.' + } + */ + + if (result.valid === false) { + console.log(result.description); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml b/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml new file mode 100644 index 000000000..9f7b8a750 --- /dev/null +++ b/doc/6/controllers/collection/validate-specifications/snippets/validate-specifications.test.yml @@ -0,0 +1,10 @@ +name: collection#validateSpecifications +description: Validate specifications format +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi + after: +template: default +expected: Some errors with provided specifications. + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/count/index.md b/doc/6/controllers/document/count/index.md new file mode 100644 index 000000000..9b4bb5660 --- /dev/null +++ b/doc/6/controllers/document/count/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: count +description: Count documents matching the given query +--- + +# count + +Counts documents in a collection. + +A query can be provided to alter the count result, otherwise returns the total number of documents in the collection. + +Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax. + +
+ +```js +count(index, collection, query, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `query` |
object
| Query to match | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to the number of matched documents. + +## Usage + +<<< ./snippets/count.js diff --git a/doc/6/controllers/document/count/snippets/count.js b/doc/6/controllers/document/count/snippets/count.js new file mode 100644 index 000000000..ae59873a8 --- /dev/null +++ b/doc/6/controllers/document/count/snippets/count.js @@ -0,0 +1,15 @@ +try { + const count = await kuzzle.document.count( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { license: 'valid' } + } + } + ); + + console.log(`Found ${count} documents matching license:valid`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/count/snippets/count.test.yml b/doc/6/controllers/document/count/snippets/count.test.yml new file mode 100644 index 000000000..0ff409fe9 --- /dev/null +++ b/doc/6/controllers/document/count/snippets/count.test.yml @@ -0,0 +1,22 @@ +--- +name: document#count +description: Count documents matching the given query +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"license": "valid"}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + curl -XPOST kuzzle:7512/nyc-open-data/_refresh + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Found 5 documents matching license:valid + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/create/index.md b/doc/6/controllers/document/create/index.md new file mode 100644 index 000000000..8515405eb --- /dev/null +++ b/doc/6/controllers/document/create/index.md @@ -0,0 +1,51 @@ +--- +code: true +type: page +title: create +description: Create a new document +--- + +# create + +Creates a new document in the persistent data storage. + +Throws an error if the document already exists. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (indexed documents are available for `search`). + +
+ +```js +create(index, collection, document, [id], [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | -------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `document` |
object
| Document content | +| `id` |
string
| Optional document ID | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the document creation result. + +| Name | Type | Description | +| --------- | ----------------- | ------------------------------------------------------ | +| \_id |
string
| ID of the newly created document | +| \_version |
number
| Version of the document in the persistent data storage | +| \_source |
object
| Created document | + +## Usage + +<<< ./snippets/create.js diff --git a/doc/6/controllers/document/create/snippets/create.js b/doc/6/controllers/document/create/snippets/create.js new file mode 100644 index 000000000..b9dccf166 --- /dev/null +++ b/doc/6/controllers/document/create/snippets/create.js @@ -0,0 +1,33 @@ +try { + const response = await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + { lastName: 'Eggins' }, + 'some-id' + ); + + if (response._id === 'some-id') { + console.log('Success'); + } + /* + response = + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 1, + result: 'created', + _shards: { total: 2, successful: 1, failed: 0 }, + created: true, + _source: + { lastName: 'Eggins', + _kuzzle_info: + { author: '-1', + createdAt: 1537443212089, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/create/snippets/create.test.yml b/doc/6/controllers/document/create/snippets/create.test.yml new file mode 100644 index 000000000..a70c73244 --- /dev/null +++ b/doc/6/controllers/document/create/snippets/create.test.yml @@ -0,0 +1,14 @@ +name: document#create +description: Create a new document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/createOrReplace/index.md b/doc/6/controllers/document/createOrReplace/index.md new file mode 100644 index 000000000..1851b8ed4 --- /dev/null +++ b/doc/6/controllers/document/createOrReplace/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: createOrReplace +description: Creates or replaces a document +--- + +# createOrReplace + +Creates a new document in the persistent data storage, or replaces its content if it already exists. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (indexed documents are available for `search`). + +
+ +```js +createOrReplace(index, collection, id, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | ---------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `document` |
object
| Document content | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the document creation result. + +| Name | Type | Description | +| --------- | ----------------- | ---------------------------------------------------------- | +| \_id |
string
| The id of the newly created document | +| \_version |
number
| The version of the document in the persistent data storage | +| \_source |
object
| The created document | + +## Usage + +<<< ./snippets/create-or-replace.js diff --git a/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.js b/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.js new file mode 100644 index 000000000..0aeac5744 --- /dev/null +++ b/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.js @@ -0,0 +1,33 @@ +try { + const response = await kuzzle.document.createOrReplace( + 'nyc-open-data', + 'yellow-taxi', + 'some-id', + { lastName: 'McHan' } + ); + + if (response._id === 'some-id') { + console.log('Success'); + } + /* + response = + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 1, + result: 'created', + _shards: { total: 2, successful: 1, failed: 0 }, + created: true, + _source: + { lastName: 'McHan', + _kuzzle_info: + { author: '-1', + createdAt: 1537443212089, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.test.yml b/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.test.yml new file mode 100644 index 000000000..a6302a57c --- /dev/null +++ b/doc/6/controllers/document/createOrReplace/snippets/create-or-replace.test.yml @@ -0,0 +1,14 @@ +name: document#createOrReplace +description: Creates or replaces a document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/delete/index.md b/doc/6/controllers/document/delete/index.md new file mode 100644 index 000000000..f93577750 --- /dev/null +++ b/doc/6/controllers/document/delete/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: delete +description: Deletes a document from kuzzle +--- + +# delete + +Deletes a document. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document to be indexed (and to no longer be available in search). + +
+ +```js +delete (index, collection, id, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to the id of the deleted document. + +## Usage + +<<< ./snippets/delete.js diff --git a/doc/6/controllers/document/delete/snippets/delete.js b/doc/6/controllers/document/delete/snippets/delete.js new file mode 100644 index 000000000..a1700237a --- /dev/null +++ b/doc/6/controllers/document/delete/snippets/delete.js @@ -0,0 +1,9 @@ +try { + const id = await kuzzle.document.delete('nyc-open-data', 'yellow-taxi', 'some-id'); + + if (id === 'some-id') { + console.log('Success'); + } +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/document/delete/snippets/delete.test.yml b/doc/6/controllers/document/delete/snippets/delete.test.yml new file mode 100644 index 000000000..3b885c736 --- /dev/null +++ b/doc/6/controllers/document/delete/snippets/delete.test.yml @@ -0,0 +1,15 @@ +name: document#delete +description: Deletes a document from kuzzle +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -H "Content-type: application/json" -XPUT -d '{}' kuzzle:7512/nyc-open-data/yellow-taxi/some-id + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/deleteByQuery/index.md b/doc/6/controllers/document/deleteByQuery/index.md new file mode 100644 index 000000000..2cec180a0 --- /dev/null +++ b/doc/6/controllers/document/deleteByQuery/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: deleteByQuery +description: Delete documents matching query +--- + +# deleteByQuery + +Deletes documents matching the provided search query. + +Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax. + +An empty or null query will match all documents in the collection. + +
+ +```js +deleteByQuery(index, collection, [query], [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `query` |
object
| Query to match | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an array of strings containing the deleted document ids. + +## Usage + +<<< ./snippets/delete-by-query.js diff --git a/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.js b/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.js new file mode 100644 index 000000000..ad36861b6 --- /dev/null +++ b/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.js @@ -0,0 +1,15 @@ +try { + const deleted = await kuzzle.document.deleteByQuery( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + term: { capacity: 7 } + } + } + ); + + console.log(`Successfully deleted ${deleted.length} documents`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml b/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml new file mode 100644 index 000000000..f7889d668 --- /dev/null +++ b/doc/6/controllers/document/deleteByQuery/snippets/delete-by-query.test.yml @@ -0,0 +1,24 @@ +name: document#deleteByQuery +description: Delete documents matching query +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"capacity": 4}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + + for i in 1 2 3 4 5; do + curl -H "Content-type: application/json" -d '{"capacity": 7}' kuzzle:7512/nyc-open-data/yellow-taxi/_create + done + + curl -XPOST kuzzle:7512/nyc-open-data/_refresh + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully deleted 5 documents + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/get/index.md b/doc/6/controllers/document/get/index.md new file mode 100644 index 000000000..2f58324f2 --- /dev/null +++ b/doc/6/controllers/document/get/index.md @@ -0,0 +1,37 @@ +--- +code: true +type: page +title: get +description: Get a document from kuzzle +--- + +# get + +Gets a document. + +
+ +```js +get(index, collection, id, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +## Usage + +<<< ./snippets/get.js diff --git a/doc/6/controllers/document/get/snippets/get.js b/doc/6/controllers/document/get/snippets/get.js new file mode 100644 index 000000000..e5e33c88e --- /dev/null +++ b/doc/6/controllers/document/get/snippets/get.js @@ -0,0 +1,30 @@ +try { + await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + { capacity: 4 }, + 'some-id' + ); + + const response = await kuzzle.document.get('nyc-open-data', 'yellow-taxi', 'some-id'); + /* + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 1, + found: true, + _source: + { capacity: 4, + _kuzzle_info: + { author: '-1', + createdAt: 1538409095673, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } + */ + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/get/snippets/get.test.yml b/doc/6/controllers/document/get/snippets/get.test.yml new file mode 100644 index 000000000..8ba2e38a2 --- /dev/null +++ b/doc/6/controllers/document/get/snippets/get.test.yml @@ -0,0 +1,14 @@ +name: document#get +description: Get a document from kuzzle +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/index.md b/doc/6/controllers/document/index.md new file mode 100644 index 000000000..e06e625ab --- /dev/null +++ b/doc/6/controllers/document/index.md @@ -0,0 +1,8 @@ +--- +code: true +type: branch +title: document +description: Document controller +--- + +# Document Controller diff --git a/doc/6/controllers/document/mCreate/index.md b/doc/6/controllers/document/mCreate/index.md new file mode 100644 index 000000000..c6ab42416 --- /dev/null +++ b/doc/6/controllers/document/mCreate/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mCreate +description: Create multiple documents in kuzzle +--- + +# mCreate + +Creates multiple documents. + +Throws a partial error (error code 206) if one or more documents creations fail. + +
+ +```js +mCreate(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to create | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing created documents. + +| Property | Type | Description | +| -------- | --------------- | --------------------------------- | +| `hits` | `array` | Created documents | +| `total` | `number` | Total number of created documents | + +## Usage + +<<< ./snippets/m-create.js diff --git a/doc/6/controllers/document/mCreate/snippets/m-create.js b/doc/6/controllers/document/mCreate/snippets/m-create.js new file mode 100644 index 000000000..d3446a457 --- /dev/null +++ b/doc/6/controllers/document/mCreate/snippets/m-create.js @@ -0,0 +1,78 @@ +try { + const documents = [ + { + _id: 'some-id', + body: { 'capacity': 4 } + }, + { + body: { this: 'document id is auto-computed' } + } + ]; + const response = await kuzzle.document.mCreate( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(response); + /* + { + "hits": [ + { + "_id": "some-id", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036563677 + }, + "capacity": 4 + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + }, + { + "_id": "AWcIiqbeBiYFF8kkRLKg", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036563677 + }, + "this": "document id is auto-computed" + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + } + ], + "total": 2 + } + */ + console.log(`Successfully created ${response.total} documents`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/document/mCreate/snippets/m-create.test.yml b/doc/6/controllers/document/mCreate/snippets/m-create.test.yml new file mode 100644 index 000000000..f1007f6bf --- /dev/null +++ b/doc/6/controllers/document/mCreate/snippets/m-create.test.yml @@ -0,0 +1,14 @@ +name: document#mCreate +description: Create multiple documents in kuzzle +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully created 2 documents + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/mCreateOrReplace/index.md b/doc/6/controllers/document/mCreateOrReplace/index.md new file mode 100644 index 000000000..a4b757831 --- /dev/null +++ b/doc/6/controllers/document/mCreateOrReplace/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mCreateOrReplace +description: Create or replace documents +--- + +# mCreateOrReplace + +Creates or replaces multiple documents. + +Throws a partial error (error code 206) if one or more document creations/replacements fail. + +
+ +```js +mCreateOrReplace(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to create | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing created documents. + +| Property | Type | Description | +| -------- | --------------- | --------------------------------- | +| `hits` | `array` | Created documents | +| `total` | `number` | Total number of created documents | + +## Usage + +<<< ./snippets/m-create-or-replace.js diff --git a/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js b/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js new file mode 100644 index 000000000..5bc7e3011 --- /dev/null +++ b/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.js @@ -0,0 +1,80 @@ +try { + const documents = [ + { + _id: 'some-id', + body: { 'capacity': 4 } + }, + { + _id: 'some-other-id', + body: { 'capacity': 4 } + } + ]; + + const response = await kuzzle.document.mCreateOrReplace( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(JSON.stringify(response)); + /* + { + "hits": [ + { + "_id": "some-id", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036740596 + }, + "capacity": 4 + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + }, + { + "_id": "some-other-id", + "_source": { + "_kuzzle_info": { + "active": true, + "author": "-1", + "updater": null, + "updatedAt": null, + "deletedAt": null, + "createdAt": 1542036740596 + }, + "capacity": 4 + }, + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "created": true, + "status": 201 + } + ], + "total": 2 + } + */ + console.log(`Successfully createOrReplace ${response.total} documents`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml b/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml new file mode 100644 index 000000000..c12b79ed6 --- /dev/null +++ b/doc/6/controllers/document/mCreateOrReplace/snippets/m-create-or-replace.test.yml @@ -0,0 +1,14 @@ +name: document#mCreateOrReplace +description: Create or replace documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully createOrReplace 2 documents + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/mDelete/index.md b/doc/6/controllers/document/mDelete/index.md new file mode 100644 index 000000000..8f15386ed --- /dev/null +++ b/doc/6/controllers/document/mDelete/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: mDelete +description: Delete documents +--- + +# mDelete + +Deletes multiple documents. + +Throws a partial error (error code 206) if one or more document deletions fail. + +The optional parameter `refresh` can be used with the value `wait_for` in order to wait for the document indexation (indexed documents are available for `search`). + +
+ +```js +mDelete(index, collection, ids, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ------------------------------ | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `ids` | `array` | IDs of the documents to delete | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an array of objects representing the deleted documents. + +## Usage + +<<< ./snippets/m-delete.js diff --git a/doc/6/controllers/document/mDelete/snippets/m-delete.js b/doc/6/controllers/document/mDelete/snippets/m-delete.js new file mode 100644 index 000000000..5a865a222 --- /dev/null +++ b/doc/6/controllers/document/mDelete/snippets/m-delete.js @@ -0,0 +1,14 @@ +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-other-id'); + + const deleted = await kuzzle.document.mDelete( + 'nyc-open-data', + 'yellow-taxi', + ['some-id', 'some-other-id'] + ); + + console.log(`Successfully deleted ${deleted.length} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/mDelete/snippets/m-delete.test.yml b/doc/6/controllers/document/mDelete/snippets/m-delete.test.yml new file mode 100644 index 000000000..70ef6ef2d --- /dev/null +++ b/doc/6/controllers/document/mDelete/snippets/m-delete.test.yml @@ -0,0 +1,14 @@ +name: document#mDelete +description: Delete documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully deleted 2 documents + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/mGet/index.md b/doc/6/controllers/document/mGet/index.md new file mode 100644 index 000000000..95c9009f2 --- /dev/null +++ b/doc/6/controllers/document/mGet/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: mGet +description: Get multiple documents +--- + +# mGet + +Gets multiple documents. + +Throws a partial error (error code 206) if one or more document can not be retrieved. + +
+ +```js +mGet(index, collection, ids, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | --------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `ids` | `array` | Document ids | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an object containing the retrieved documents. + +| Property | Type | Description | +| -------- | --------------- | ------------------------- | +| `hits` | `array` | Retrieved documents | +| `total` | `number` | Total retrieved documents | + +## Usage + +<<< ./snippets/m-get.js diff --git a/doc/6/controllers/document/mGet/snippets/m-get.js b/doc/6/controllers/document/mGet/snippets/m-get.js new file mode 100644 index 000000000..bca631dac --- /dev/null +++ b/doc/6/controllers/document/mGet/snippets/m-get.js @@ -0,0 +1,61 @@ +const doc1 = { capacity: 4 }; +const doc2 = { capacity: 7 }; + +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc1, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc2, 'some-other-id'); + + const response = await kuzzle.document.mGet( + 'nyc-open-data', + 'yellow-taxi', + ['some-id', 'some-other-id'] + ); + + console.log(response); + /* + { + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "some-id", + "_version": 1, + "found": true, + "_source": { + "capacity": 4, + "_kuzzle_info": { + "author": "-1", + "createdAt": 1542036871353, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "some-other-id", + "_version": 1, + "found": true, + "_source": { + "capacity": 7, + "_kuzzle_info": { + "author": "-1", + "createdAt": 1542036871374, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + } + ], + "total": 2 + } + */ + console.log(`Successfully get ${response.total} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/mGet/snippets/m-get.test.yml b/doc/6/controllers/document/mGet/snippets/m-get.test.yml new file mode 100644 index 000000000..d5222f8aa --- /dev/null +++ b/doc/6/controllers/document/mGet/snippets/m-get.test.yml @@ -0,0 +1,14 @@ +name: document#mGet +description: Get multiple documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully get 2 documents + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/mReplace/index.md b/doc/6/controllers/document/mReplace/index.md new file mode 100644 index 000000000..c05a6c58c --- /dev/null +++ b/doc/6/controllers/document/mReplace/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: mReplace +description: Replace documents +--- + +# mReplace + +Replaces multiple documents. + +Throws a partial error (error code 206) if one or more documents can not be replaced. + +
+ +```js +mReplace(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to update | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the replaced documents. + +| Property | Type | Description | +| -------- | --------------- | ------------------------ | +| `hits` | `array` | Replaced documents | +| `total` | `number` | Total replaced documents | + +## Usage + +<<< ./snippets/m-replace.js diff --git a/doc/6/controllers/document/mReplace/snippets/m-replace.js b/doc/6/controllers/document/mReplace/snippets/m-replace.js new file mode 100644 index 000000000..52a1821e3 --- /dev/null +++ b/doc/6/controllers/document/mReplace/snippets/m-replace.js @@ -0,0 +1,64 @@ +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', {}, 'some-other-id'); + + const documents = [ + { + _id: 'some-id', + body: { capacity: 4 } + }, + { + _id: 'some-other-id', + body: { capacity: 4 } + } + ]; + + const response = await kuzzle.document.mReplace( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(response); + /* + { hits: + [ { _id: 'some-id', + _source: + { _kuzzle_info: + { active: true, + author: '-1', + updater: null, + updatedAt: null, + deletedAt: null, + createdAt: 1538639586995 }, + capacity: 4 }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 }, + { _id: 'some-other-id', + _source: + { _kuzzle_info: + { active: true, + author: '-1', + updater: null, + updatedAt: null, + deletedAt: null, + createdAt: 1538639586995 }, + capacity: 4 }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 } ], + total: 2 } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/mReplace/snippets/m-replace.test.yml b/doc/6/controllers/document/mReplace/snippets/m-replace.test.yml new file mode 100644 index 000000000..fe7320540 --- /dev/null +++ b/doc/6/controllers/document/mReplace/snippets/m-replace.test.yml @@ -0,0 +1,14 @@ +name: document#mReplace +description: Replace documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/mUpdate/index.md b/doc/6/controllers/document/mUpdate/index.md new file mode 100644 index 000000000..28dd2ec8e --- /dev/null +++ b/doc/6/controllers/document/mUpdate/index.md @@ -0,0 +1,52 @@ +--- +code: true +type: page +title: mUpdate +description: Update documents +--- + +# mUpdate + +Updates multiple documents. + +Returns a partial error (error code 206) if one or more documents can not be updated. + +Conflicts may occur if the same document gets updated multiple times within a short timespan in a database cluster. + +You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error. + +
+ +```js +mUpdate(index, collection, documents, [options]); +``` + +| Argument | Type | Description | +| ------------ | --------------- | ---------------------------- | +| `index` | `string` | Index name | +| `collection` | `string` | Collection name | +| `documents` | `array` | Array of documents to update | +| `options` | `object` | Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ----------------- | ---------------------- | ---------------------------------------------------------------------------------- | +| `queuable` | `boolean`
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` | `string`
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | +| `retryOnConflict` | `int`
(`0`) | The number of times the database layer should retry in case of version conflict | + +## Resolves + +Resolves to an object containing the updated documents. + +| Property | Type | Description | +| -------- | --------------- | ----------------------- | +| `hits` | `array` | Updated documents | +| `total` | `number` | Total updated documents | + +## Usage + +<<< ./snippets/m-update.js diff --git a/doc/6/controllers/document/mUpdate/snippets/m-update.js b/doc/6/controllers/document/mUpdate/snippets/m-update.js new file mode 100644 index 000000000..10a7910b9 --- /dev/null +++ b/doc/6/controllers/document/mUpdate/snippets/m-update.js @@ -0,0 +1,51 @@ +const doc1 = { capacity: 4 }; +const doc2 = { capacity: 7 }; + +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc1, 'some-id'); + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc2, 'some-other-id'); + + const documents = [ + { + _id: 'some-id', + body: { category: 'sedan' } + }, + { + _id: 'some-other-id', + body: { category: 'limousine' } + } + ]; + + const response = await kuzzle.document.mReplace( + 'nyc-open-data', + 'yellow-taxi', + documents + ); + + console.log(response); + /* + { hits: + [ { _id: 'some-id', + _source: { _kuzzle_info: [Object], category: 'sedan' }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 }, + { _id: 'some-other-id', + _source: { _kuzzle_info: [Object], category: 'limousine' }, + _index: 'nyc-open-data', + _type: 'yellow-taxi', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + status: 200 } ], + total: 2 } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/mUpdate/snippets/m-update.test.yml b/doc/6/controllers/document/mUpdate/snippets/m-update.test.yml new file mode 100644 index 000000000..58ade7ff0 --- /dev/null +++ b/doc/6/controllers/document/mUpdate/snippets/m-update.test.yml @@ -0,0 +1,14 @@ +name: document#mUpdate +description: Update documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/replace/index.md b/doc/6/controllers/document/replace/index.md new file mode 100644 index 000000000..f219be349 --- /dev/null +++ b/doc/6/controllers/document/replace/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: replace +description: Replace a document +--- + +# replace + +Replaces the content of an existing document. + +
+ +```js +replace(index, collection, id, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | ------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `document` |
object
| New content of the document to update | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | + +## Resolves + +Resolves to an object containing the the document update result. + +| Name | Type | Description | +| --------- | ----------------- | ------------------------------------------------------ | +| \_id |
string
| ID of the newly created document | +| \_version |
number
| Version of the document in the persistent data storage | +| \_source |
object
| The updated document | + +## Usage + +<<< ./snippets/replace.js diff --git a/doc/6/controllers/document/replace/snippets/replace.js b/doc/6/controllers/document/replace/snippets/replace.js new file mode 100644 index 000000000..be26e5ed2 --- /dev/null +++ b/doc/6/controllers/document/replace/snippets/replace.js @@ -0,0 +1,36 @@ +const doc = { color: 'yellow' }; + +try { + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', doc, 'some-id'); + + const response = await kuzzle.document.replace( + 'nyc-open-data', + 'yellow-taxi', + 'some-id', + { capacity: 4, category: 'sedan' } + ); + + console.log(response); + /* + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 }, + created: false, + _source: + { capacity: 4, + category: 'sedan', + _kuzzle_info: + { author: '-1', + createdAt: 1538654776456, + updatedAt: 1538654776456, + updater: '-1', + active: true, + deletedAt: null } } } + */ + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/replace/snippets/replace.test.yml b/doc/6/controllers/document/replace/snippets/replace.test.yml new file mode 100644 index 000000000..2159e6a89 --- /dev/null +++ b/doc/6/controllers/document/replace/snippets/replace.test.yml @@ -0,0 +1,13 @@ +name: document#replace +description: Replace a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/search/index.md b/doc/6/controllers/document/search/index.md new file mode 100644 index 000000000..d55ddf8e3 --- /dev/null +++ b/doc/6/controllers/document/search/index.md @@ -0,0 +1,59 @@ +--- +code: true +type: page +title: search +description: Search for documents +--- + +# search + +Searches documents. + +There is a limit to how many documents can be returned by a single search query. +That limit is by default set at 10000 documents, and you can't get over it even with the from and size pagination options. + +:::info +When processing a large number of documents (i.e. more than 1000), it is advised to paginate the results using [SearchResult.next](/sdk/js/6/core-classes/search-result/next/) rather than increasing the size parameter. +::: + +
+ +```js +search(index, collection, [query], [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `query` |
object
| Search query | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `from` |
number

(`0`) | Offset of the first document to fetch | +| `size` |
number

(`10`) | Maximum number of documents to retrieve per page | +| `scroll` |
string

(`""`) | When set, gets a forward-only cursor having its ttl set to the given value (ie `30s`; cf [elasticsearch time limits](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#time-units)) | + +## Body properties + +### Optional: + +- `query`: the search query itself, using the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl.html) syntax. +- `aggregations`: control how the search results should be [aggregated](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations.html) +- `sort`: contains a list of fields, used to [sort search results](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-sort.html), in order of importance. + +An empty body matches all documents in the queried collection. + +## Resolves + +Resolves to a [SearchResult](/sdk/js/6/core-classes/search-result) object. + +## Usage + +<<< ./snippets/search.js diff --git a/doc/6/controllers/document/search/snippets/search.js b/doc/6/controllers/document/search/snippets/search.js new file mode 100644 index 000000000..97d037cd2 --- /dev/null +++ b/doc/6/controllers/document/search/snippets/search.js @@ -0,0 +1,61 @@ +const suv = { category: 'suv' }; +const limousine = { category: 'limousine' }; + +try { + const requests = []; + + for (let i = 0; i < 5; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); + } + for (let i = 0; i < 10; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', limousine)); + } + await Promise.all(requests); + + await kuzzle.index.refresh('nyc-open-data'); + + const results = await kuzzle.document.search( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + category: 'suv' + } + } + } + ); + + console.log(results); + /* + { + "aggregations": undefined, + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "AWgi6A1POQUM6ucJ3q06", + "_score": 0.046520017, + "_source": { + "category": "suv", + "_kuzzle_info": { + "author": "-1", + "createdAt": 1546773859655, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + ... + ] + }, + "total": 5, + "fetched": 5, + "scroll_id": undefined + */ + console.log(`Successfully retrieved ${results.total} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/search/snippets/search.test.yml b/doc/6/controllers/document/search/snippets/search.test.yml new file mode 100644 index 000000000..be1107e88 --- /dev/null +++ b/doc/6/controllers/document/search/snippets/search.test.yml @@ -0,0 +1,13 @@ +name: document#search +description: Search for documents +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully retrieved 5 documents +sdk: js +version: 6 diff --git a/doc/6/controllers/document/update/index.md b/doc/6/controllers/document/update/index.md new file mode 100644 index 000000000..a2587af85 --- /dev/null +++ b/doc/6/controllers/document/update/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: update +description: Update a document +--- + +# update + +Updates a document content. + +Conflicts may occur if the same document gets updated multiple times within a short timespan, in a database cluster. +You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error. + +
+ +```js +update(index, collection, id, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | ----------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `id` |
string
| Document ID | +| `document` |
object
| Partial content of the document to update | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ----------------- | ------------------------------- | ---------------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | +| `refresh` |
string

(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) | +| `retryOnConflict` |
int

(`0`) | The number of times the database layer should retry in case of version conflict | + +## Resolves + +Resolves to an object containing the the document update result. + +## Usage + +<<< ./snippets/update.js diff --git a/doc/6/controllers/document/update/snippets/update.js b/doc/6/controllers/document/update/snippets/update.js new file mode 100644 index 000000000..76d587a5f --- /dev/null +++ b/doc/6/controllers/document/update/snippets/update.js @@ -0,0 +1,27 @@ +try { + await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + { capacity: 4 }, + 'some-id' + ); + + const response = await kuzzle.document.update( + 'nyc-open-data', + 'yellow-taxi', + 'some-id', + { category: 'suv' } + ); + + console.log(response); + /* + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'some-id', + _version: 2, + result: 'updated', + _shards: { total: 2, successful: 1, failed: 0 } } + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/document/update/snippets/update.test.yml b/doc/6/controllers/document/update/snippets/update.test.yml new file mode 100644 index 000000000..de65fb652 --- /dev/null +++ b/doc/6/controllers/document/update/snippets/update.test.yml @@ -0,0 +1,14 @@ +name: document#update +description: Update a document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: "result: 'updated'" + +sdk: js +version: 6 diff --git a/doc/6/controllers/document/validate/index.md b/doc/6/controllers/document/validate/index.md new file mode 100644 index 000000000..e274a21c1 --- /dev/null +++ b/doc/6/controllers/document/validate/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: validate +description: Validate a document +--- + +# validate + +Validates data against existing validation rules. + +Note that if no validation specifications are set for the ``/``, the document will always be valid. + +This request does **not** store or publish the document. + +
+ +```js +validate(index, collection, document, [options]); +``` + +| Argument | Type | Description | +| ------------ | ----------------- | -------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `document` |
object
| Document to validate | +| `options` |
object
| Query options | + +### Options + +Additional query options + +| Options | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a boolean value set to true if the document is valid and false otherwise. + +## Usage + +<<< ./snippets/validate.js diff --git a/doc/6/controllers/document/validate/snippets/validate.js b/doc/6/controllers/document/validate/snippets/validate.js new file mode 100644 index 000000000..b2073205c --- /dev/null +++ b/doc/6/controllers/document/validate/snippets/validate.js @@ -0,0 +1,13 @@ +try { + const valid = await kuzzle.document.validate( + 'nyc-open-data', + 'yellow-taxi', + { capacity: 4 } + ); + + if (valid) { + console.log('Success'); + } +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/document/validate/snippets/validate.test.yml b/doc/6/controllers/document/validate/snippets/validate.test.yml new file mode 100644 index 000000000..7de251334 --- /dev/null +++ b/doc/6/controllers/document/validate/snippets/validate.test.yml @@ -0,0 +1,14 @@ +name: document#validate +description: Validate a document +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/index.md b/doc/6/controllers/index.md new file mode 100644 index 000000000..18fd371b3 --- /dev/null +++ b/doc/6/controllers/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 400 +title: Controllers +description: Javascript SDK v6.x controllers +--- diff --git a/doc/6/controllers/index/create/index.md b/doc/6/controllers/index/create/index.md new file mode 100644 index 000000000..6fd496175 --- /dev/null +++ b/doc/6/controllers/index/create/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: create +description: Creates an index +--- + +# create + +Creates a new index. + +
+ +```js +create(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an `object` containing the index creation status + +| Name | Type | Description | +| --------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------- | +| `acknowledged` |
boolean
| Indicates whether the index was successfully created in the Elastic cluster | +| `shards_acknowledged` |
boolean
| Indicates whether the requisite number of shard copies were started for each shard in the index before timing out | + +## Usage + +<<< ./snippets/create.js diff --git a/doc/6/controllers/index/create/snippets/create.js b/doc/6/controllers/index/create/snippets/create.js new file mode 100644 index 000000000..e1ce98080 --- /dev/null +++ b/doc/6/controllers/index/create/snippets/create.js @@ -0,0 +1,12 @@ +try { + const response = await kuzzle.index.create('nyc-open-data'); + console.log(response); + /* + { acknowledged: true, + shards_acknowledged: true } + */ + + console.log('Index created'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/create/snippets/create.test.yml b/doc/6/controllers/index/create/snippets/create.test.yml new file mode 100644 index 000000000..9437cac16 --- /dev/null +++ b/doc/6/controllers/index/create/snippets/create.test.yml @@ -0,0 +1,12 @@ +--- +name: index#create +description: Creates a new index +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: default +expected: + - "acknowledged: true" + - "Index created" +sdk: js +version: 6 diff --git a/doc/6/controllers/index/delete/index.md b/doc/6/controllers/index/delete/index.md new file mode 100644 index 000000000..29e082d6d --- /dev/null +++ b/doc/6/controllers/index/delete/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: delete +description: Deletes an index +--- + +# delete + +Deletes a index. + +
+ +```js +delete (index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves if the index was successfully deleted in the Elasticsearch cluster. + +## Usage + +<<< ./snippets/delete.js diff --git a/doc/6/controllers/index/delete/snippets/delete.js b/doc/6/controllers/index/delete/snippets/delete.js new file mode 100644 index 000000000..ee0771bf9 --- /dev/null +++ b/doc/6/controllers/index/delete/snippets/delete.js @@ -0,0 +1,7 @@ +try { + kuzzle.index.delete('nyc-open-data'); + + console.log('Index deleted'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/delete/snippets/delete.test.yml b/doc/6/controllers/index/delete/snippets/delete.test.yml new file mode 100644 index 000000000..75385676a --- /dev/null +++ b/doc/6/controllers/index/delete/snippets/delete.test.yml @@ -0,0 +1,11 @@ +--- +name: index#delete +description: Deletes an index +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Index deleted + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/exists/index.md b/doc/6/controllers/index/exists/index.md new file mode 100644 index 000000000..c16e4e312 --- /dev/null +++ b/doc/6/controllers/index/exists/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: exists +description: Check for index existence +--- + +# exists + +Checks if the given index exists. + +
+ +```js +exists(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` that indicate whether the index exists or not. + +## Usage + +<<< ./snippets/exists.js diff --git a/doc/6/controllers/index/exists/snippets/exists.js b/doc/6/controllers/index/exists/snippets/exists.js new file mode 100644 index 000000000..5fdc1199d --- /dev/null +++ b/doc/6/controllers/index/exists/snippets/exists.js @@ -0,0 +1,11 @@ +try { + const exists = await kuzzle.index.exists('nyc-open-data'); + + if (exists === true) { + console.log('Index exists'); + } else { + console.log('Index does not exists'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/exists/snippets/exists.test.yml b/doc/6/controllers/index/exists/snippets/exists.test.yml new file mode 100644 index 000000000..55257010d --- /dev/null +++ b/doc/6/controllers/index/exists/snippets/exists.test.yml @@ -0,0 +1,11 @@ +--- +name: index#exists +description: Tests if an index exists +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Index exists + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/get-auto-refresh/index.md b/doc/6/controllers/index/get-auto-refresh/index.md new file mode 100644 index 000000000..46c82aa47 --- /dev/null +++ b/doc/6/controllers/index/get-auto-refresh/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: getAutoRefresh +description: Returns the status of autorefresh flag +--- + +# getAutoRefresh + +This action returns the current autorefresh status of a index. + +Each index has an autorefresh flag. +When set to true, each write request triggers a [refresh](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html) action in Elasticsearch. +Without a refresh after a write request, the documents may not be immediately visible in search. + +:::info +A refresh operation comes with some performance costs. +While forcing the autoRefresh can be convenient on a development or test environment, +we recommend that you avoid using it in production or at least carefully monitor its implications before using it. +::: + +
+ +```js +getAutoRefresh(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `index` |
string
| Index name | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` that indicate the status of the **autoRefresh** flag. + +## Usage + +<<< ./snippets/getAutoRefresh.js diff --git a/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js b/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js new file mode 100644 index 000000000..0197ea180 --- /dev/null +++ b/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.js @@ -0,0 +1,7 @@ +try { + const status = await kuzzle.index.getAutoRefresh('nyc-open-data'); + + console.log(`autorefresh is ${status}`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml b/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml new file mode 100644 index 000000000..e8117816b --- /dev/null +++ b/doc/6/controllers/index/get-auto-refresh/snippets/getAutoRefresh.test.yml @@ -0,0 +1,11 @@ +--- +name: index#getAutoRefresh +description: Return autorefresh status for index +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data && curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: autorefresh is false + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/index.md b/doc/6/controllers/index/index.md new file mode 100644 index 000000000..a9e958562 --- /dev/null +++ b/doc/6/controllers/index/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: index +description: index controller documentation +--- diff --git a/doc/6/controllers/index/list/index.md b/doc/6/controllers/index/list/index.md new file mode 100644 index 000000000..8e0cdb985 --- /dev/null +++ b/doc/6/controllers/index/list/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: list +description: Lists the indexes +--- + +# list + +Returns the complete list of indexes. + +
+ +```js +list([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an array of index names. + +## Usage + +<<< ./snippets/list.js diff --git a/doc/6/controllers/index/list/snippets/list.js b/doc/6/controllers/index/list/snippets/list.js new file mode 100644 index 000000000..3a05ff38e --- /dev/null +++ b/doc/6/controllers/index/list/snippets/list.js @@ -0,0 +1,11 @@ +try { + const indexes = await kuzzle.index.list(); + console.log(indexes); + /* + [ 'nyc-open-data', 'mtp-open-data' ] + */ + + console.log(`Kuzzle contains ${indexes.length} indexes`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/list/snippets/list.test.yml b/doc/6/controllers/index/list/snippets/list.test.yml new file mode 100644 index 000000000..6981feadf --- /dev/null +++ b/doc/6/controllers/index/list/snippets/list.test.yml @@ -0,0 +1,14 @@ +--- +name: index#list +description: Lists indexes handled by kuzzle +hooks: + before: | + curl -X POST kuzzle:7512/admin/_resetDatabase + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X POST kuzzle:7512/mtp-open-data/_create + after: +template: default +expected: Kuzzle contains 2 indexes + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/m-delete/index.md b/doc/6/controllers/index/m-delete/index.md new file mode 100644 index 000000000..fbd825509 --- /dev/null +++ b/doc/6/controllers/index/m-delete/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: mDelete +description: Deletes multiple indexes +--- + +# mDelete + +Deletes multiple indexes. + +
+ +```js +mDelete(indexes, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ----------------------------- | +| `indexes` |
string[]
| List of index names to delete | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an array of Successfully deleted indexes. + +## Usage + +<<< ./snippets/mDelete.js diff --git a/doc/6/controllers/index/m-delete/snippets/mDelete.js b/doc/6/controllers/index/m-delete/snippets/mDelete.js new file mode 100644 index 000000000..be18a7a57 --- /dev/null +++ b/doc/6/controllers/index/m-delete/snippets/mDelete.js @@ -0,0 +1,11 @@ +try { + const indexes = await kuzzle.index.mDelete(['nyc-open-data', 'mtp-open-data']); + console.log(indexes); + /* + [ 'nyc-open-data', 'mtp-open-data' ] + */ + + console.log(`Successfully deleted ${indexes.length} indexes`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/m-delete/snippets/mDelete.test.yml b/doc/6/controllers/index/m-delete/snippets/mDelete.test.yml new file mode 100644 index 000000000..8f9334ad1 --- /dev/null +++ b/doc/6/controllers/index/m-delete/snippets/mDelete.test.yml @@ -0,0 +1,13 @@ +--- +name: index#mDelete +description: Delete multiple indexes +hooks: + before: | + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X POST kuzzle:7512/mtp-open-data/_create + after: +template: default +expected: Successfully deleted 2 indexes + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/refresh-internal/index.md b/doc/6/controllers/index/refresh-internal/index.md new file mode 100644 index 000000000..e09917b8d --- /dev/null +++ b/doc/6/controllers/index/refresh-internal/index.md @@ -0,0 +1,48 @@ +--- +code: true +type: page +title: refreshInternal +description: Forces an immediate reindexation of Kuzzle internal storage. +--- + +# refreshInternal + +When writing or deleting security and internal documents (users, roles, profiles, configuration, etc.) in Kuzzle, the update needs to be indexed before being reflected in the search index. + +The `refreshInternal` action forces a [refresh](//sdk/js/6/controllers/index/refresh), on the internal index, making the documents available to search immediately. + +:::info +A refresh operation comes with some performance costs. + +From the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html): +> "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." + +::: + +## Arguments + +```js +refreshInternal([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` containing the refresh status. + +## Usage + +<<< ./snippets/refreshInternal.js diff --git a/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.js b/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.js new file mode 100644 index 000000000..4febc0507 --- /dev/null +++ b/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.js @@ -0,0 +1,9 @@ +try { + const success = await kuzzle.index.refreshInternal(); + + if (success) { + console.log('Internal index successfully refreshed'); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.test.yml b/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.test.yml new file mode 100644 index 000000000..372fe4208 --- /dev/null +++ b/doc/6/controllers/index/refresh-internal/snippets/refreshInternal.test.yml @@ -0,0 +1,11 @@ +--- +name: index#refreshInternal +description: Forces an immediate reindexation of Kuzzle internal storage. +hooks: + before: + after: +template: default +expected: Internal index successfully refreshed + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/refresh/index.md b/doc/6/controllers/index/refresh/index.md new file mode 100644 index 000000000..cb338cfe4 --- /dev/null +++ b/doc/6/controllers/index/refresh/index.md @@ -0,0 +1,52 @@ +--- +code: true +type: page +title: refresh +description: Forces an Elasticsearch search index update +--- + +# refresh + +When writing or deleting documents in Kuzzle, the update needs to be indexed before being available in search results. + +:::info +A refresh operation comes with some performance costs. + +From the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-refresh.html): +> "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it." + +::: + +
+ +```js +refresh(index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to an `object` containing the refresh status on shards. + +| Name | Type | Description | +| ------------ | ----------------- | ----------------------------- | +| `total` |
number
| Total number of shards | +| `successful` |
number
| Successfully refreshed shards | +| `failed` |
number
| Shards that failed to refresh | + +## Usage + +<<< ./snippets/refresh.js diff --git a/doc/6/controllers/index/refresh/snippets/refresh.js b/doc/6/controllers/index/refresh/snippets/refresh.js new file mode 100644 index 000000000..97190974a --- /dev/null +++ b/doc/6/controllers/index/refresh/snippets/refresh.js @@ -0,0 +1,11 @@ +try { + const status = await kuzzle.index.refresh('nyc-open-data'); + console.log(status); + /* + { total: 5, successful: 5, failed: 0 } + */ + + console.log(`${status.failed} shards fail to refresh`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/refresh/snippets/refresh.test.yml b/doc/6/controllers/index/refresh/snippets/refresh.test.yml new file mode 100644 index 000000000..2121be65c --- /dev/null +++ b/doc/6/controllers/index/refresh/snippets/refresh.test.yml @@ -0,0 +1,11 @@ +--- +name: index#refresh +description: Forces an Elasticsearch search index update +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: 0 shards fail to refresh + +sdk: js +version: 6 diff --git a/doc/6/controllers/index/set-auto-refresh/index.md b/doc/6/controllers/index/set-auto-refresh/index.md new file mode 100644 index 000000000..9f21a040d --- /dev/null +++ b/doc/6/controllers/index/set-auto-refresh/index.md @@ -0,0 +1,50 @@ +--- +code: true +type: page +title: setAutoRefresh +description: Set the autorefresh flag +--- + +# setAutoRefresh + +The setAutoRefresh action allows to set the autorefresh flag for a index. + +Each index has an autorefresh flag. +When set to true, each write request trigger a [refresh](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html) action on Elasticsearch. +Without a refresh after a write request, the documents may not be immediately visible in search. + +:::info +A refresh operation comes with performance costs. +While forcing the autoRefresh can be convenient on a development or test environment, +we recommend that you avoid using it in production or at least carefully monitor its implications before using it. +::: + +
+ +```js +setAutoRefresh(index, autoRefresh, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------- | ------------------ | ----------------- | +| `index` |
string
| Index name | +| `autoRefresh` |
boolean
| AutoRefresh value | +| `options` |
number
| Query options | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolves to a `boolean` representing the new value of the autorefresh flag. + +## Usage + +<<< ./snippets/setAutoRefresh.js diff --git a/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js b/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js new file mode 100644 index 000000000..75d8736de --- /dev/null +++ b/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.js @@ -0,0 +1,9 @@ +try { + const autoRefresh = await kuzzle.index.setAutoRefresh('nyc-open-data', true); + + if (autoRefresh === true) { + console.log(`Autorefresh flag is set to true`); + } +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml b/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml new file mode 100644 index 000000000..3a89cb389 --- /dev/null +++ b/doc/6/controllers/index/set-auto-refresh/snippets/setAutoRefresh.test.yml @@ -0,0 +1,13 @@ +--- +name: index#setAutoRefresh +description: Set the autorefresh flag for the index +hooks: + before: | + curl -X DELETE kuzzle:7512/nyc-open-data + curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Autorefresh flag is set to true + +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/append/index.md b/doc/6/controllers/ms/append/index.md new file mode 100644 index 000000000..bf8994f93 --- /dev/null +++ b/doc/6/controllers/ms/append/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: append +--- + +# append + +Appends a value to a key. If the key does not exist, it is created. + +[[_Redis documentation_]](https://redis.io/commands/append) + +## Arguments + +```js +append(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
string
| Value to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Returns the updated value length. + +## Usage + +<<< ./snippets/append.js diff --git a/doc/6/controllers/ms/append/snippets/append.js b/doc/6/controllers/ms/append/snippets/append.js new file mode 100644 index 000000000..01c747745 --- /dev/null +++ b/doc/6/controllers/ms/append/snippets/append.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('hw', 'Hello'); + + await kuzzle.ms.append('hw', ' World'); + + // Prints: Hello World + console.log(await kuzzle.ms.get('hw')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/append/snippets/append.test.yml b/doc/6/controllers/ms/append/snippets/append.test.yml new file mode 100644 index 000000000..1b778932d --- /dev/null +++ b/doc/6/controllers/ms/append/snippets/append.test.yml @@ -0,0 +1,9 @@ +name: ms#append +description: Appends a value to a key. If the key does not exist, it is created +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: Hello World +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/bitcount/index.md b/doc/6/controllers/ms/bitcount/index.md new file mode 100644 index 000000000..db719f134 --- /dev/null +++ b/doc/6/controllers/ms/bitcount/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: bitcount +--- + +# bitcount + +Counts the number of set bits (population counting) in a string. + +[[_Redis documentation_]](https://redis.io/commands/bitcount) + +## Arguments + +```js +bitcount(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `end` |
integer
| Count ends at the provided offset | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `start` |
integer
| Count starts at the provided offset | + +## Resolve + +Resolves to the number of set bits. + +## Usage + +<<< ./snippets/bitcount.js diff --git a/doc/6/controllers/ms/bitcount/snippets/bitcount.js b/doc/6/controllers/ms/bitcount/snippets/bitcount.js new file mode 100644 index 000000000..0d598a8df --- /dev/null +++ b/doc/6/controllers/ms/bitcount/snippets/bitcount.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('key', 'foobar'); + + // Prints: 26 + console.log(await kuzzle.ms.bitcount('key')); + + // Prints: 4 + console.log(await kuzzle.ms.bitcount('key', {start: 0, end: 0})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/bitcount/snippets/bitcount.test.yml b/doc/6/controllers/ms/bitcount/snippets/bitcount.test.yml new file mode 100644 index 000000000..887b5762e --- /dev/null +++ b/doc/6/controllers/ms/bitcount/snippets/bitcount.test.yml @@ -0,0 +1,11 @@ +name: ms#bitcount +description: Counts the number of set bits (population counting) in a string +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - 26 + - 4 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/bitop/index.md b/doc/6/controllers/ms/bitop/index.md new file mode 100644 index 000000000..60a5eb03f --- /dev/null +++ b/doc/6/controllers/ms/bitop/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: bitop +--- + +# bitop + +Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key. + +[[_Redis documentation_]](https://redis.io/commands/bitop) + +## Arguments + +```js +bitop(key, operation, keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | ----------------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `operation` |
string
| The bitwise operand to use to combine keys.
Allowed values: `AND`, `NOT`, `OR`, `XOR` | +| `keys` |
string[]
| The list of keys to combine | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the new destination key length. + +## Usage + +<<< ./snippets/bitop.js diff --git a/doc/6/controllers/ms/bitop/snippets/bitop.js b/doc/6/controllers/ms/bitop/snippets/bitop.js new file mode 100644 index 000000000..47bb01c41 --- /dev/null +++ b/doc/6/controllers/ms/bitop/snippets/bitop.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('key1', 'foobar'); + await kuzzle.ms.set('key2', 'abcdef'); + + await kuzzle.ms.bitop('dest', 'AND', ['key1', 'key2']); + + // Prints: `bc`ab + console.log(await kuzzle.ms.get('dest')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/bitop/snippets/bitop.test.yml b/doc/6/controllers/ms/bitop/snippets/bitop.test.yml new file mode 100644 index 000000000..34f2b6513 --- /dev/null +++ b/doc/6/controllers/ms/bitop/snippets/bitop.test.yml @@ -0,0 +1,9 @@ +name: ms#bitop +description: Performs a bitwise operation between multiple keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "`bc`ab" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/bitpos/index.md b/doc/6/controllers/ms/bitpos/index.md new file mode 100644 index 000000000..1c3ba80db --- /dev/null +++ b/doc/6/controllers/ms/bitpos/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: bitpos +--- + +# bitpos + +Returns the position of the first bit set to 1 or 0 in a string, or in a substring. + +[[_Redis documentation_]](https://redis.io/commands/bitpos) + +## Arguments + +```js +bitpos(key, bit, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ---------------------------------------------- | +| `key` |
string
| Key | +| `bit` |
integer
| Bit to look for.
Accepted values: `0`, `1` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `end` |
integer
| Search ends at the provided offset | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `start` |
integer
| Search starts at the provided offset | + +## Resolve + +Resolves to the position of the first bit found matching the searched value. + +## Usage + +<<< ./snippets/bitpos.js diff --git a/doc/6/controllers/ms/bitpos/snippets/bitpos.js b/doc/6/controllers/ms/bitpos/snippets/bitpos.js new file mode 100644 index 000000000..a5250bbbe --- /dev/null +++ b/doc/6/controllers/ms/bitpos/snippets/bitpos.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('key', '\x00\x00\x01'); + + // Prints: 23 + console.log(await kuzzle.ms.bitpos('key', 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/bitpos/snippets/bitpos.test.yml b/doc/6/controllers/ms/bitpos/snippets/bitpos.test.yml new file mode 100644 index 000000000..42aa3d157 --- /dev/null +++ b/doc/6/controllers/ms/bitpos/snippets/bitpos.test.yml @@ -0,0 +1,9 @@ +name: ms#bitpos +description: Returns the position of the first bit set to 1 or 0 in a string, or in a substring +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 23 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/dbsize/index.md b/doc/6/controllers/ms/dbsize/index.md new file mode 100644 index 000000000..24d1c804d --- /dev/null +++ b/doc/6/controllers/ms/dbsize/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: dbsize +--- + +# dbsize + +Returns the number of keys in the application database. + +[[_Redis documentation_]](https://redis.io/commands/dbsize) + +## Arguments + +```js +dbsize([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of found keys. + +## Usage + +<<< ./snippets/dbsize.js diff --git a/doc/6/controllers/ms/dbsize/snippets/dbsize.js b/doc/6/controllers/ms/dbsize/snippets/dbsize.js new file mode 100644 index 000000000..25df85e10 --- /dev/null +++ b/doc/6/controllers/ms/dbsize/snippets/dbsize.js @@ -0,0 +1,6 @@ +try { + const size = await kuzzle.ms.dbsize(); + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/dbsize/snippets/dbsize.test.yml b/doc/6/controllers/ms/dbsize/snippets/dbsize.test.yml new file mode 100644 index 000000000..21811fa67 --- /dev/null +++ b/doc/6/controllers/ms/dbsize/snippets/dbsize.test.yml @@ -0,0 +1,9 @@ +name: ms#dbsize +description: Returns the number of keys in the application database +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: Success +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/decr/index.md b/doc/6/controllers/ms/decr/index.md new file mode 100644 index 000000000..9492718e1 --- /dev/null +++ b/doc/6/controllers/ms/decr/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: decr +--- + +# decr + +Decrements the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/decr) + +## Arguments + +```js +decr(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated key value. + +## Usage + +<<< ./snippets/decr.js diff --git a/doc/6/controllers/ms/decr/snippets/decr.js b/doc/6/controllers/ms/decr/snippets/decr.js new file mode 100644 index 000000000..681cb503a --- /dev/null +++ b/doc/6/controllers/ms/decr/snippets/decr.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('val', 43); + + // Prints: 42 + console.log(await kuzzle.ms.decr('val')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/decr/snippets/decr.test.yml b/doc/6/controllers/ms/decr/snippets/decr.test.yml new file mode 100644 index 000000000..f515ac10c --- /dev/null +++ b/doc/6/controllers/ms/decr/snippets/decr.test.yml @@ -0,0 +1,9 @@ +name: ms#decr +description: Decrements the number stored at `key` by 1 +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 42 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/decrby/index.md b/doc/6/controllers/ms/decrby/index.md new file mode 100644 index 000000000..1a5301d88 --- /dev/null +++ b/doc/6/controllers/ms/decrby/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: decrby +--- + +# decrby + +Decrements the number stored at `key` by a provided integer value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/decrby) + +## Arguments + +```js +decrby(key, decrement, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `decrement` |
integer
| Decrement value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated key value. + +## Usage + +<<< ./snippets/decrby.js diff --git a/doc/6/controllers/ms/decrby/snippets/decrby.js b/doc/6/controllers/ms/decrby/snippets/decrby.js new file mode 100644 index 000000000..49bb332b1 --- /dev/null +++ b/doc/6/controllers/ms/decrby/snippets/decrby.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('val', 12); + + // Prints: 42 + console.log(await kuzzle.ms.decrby('val', -30)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/decrby/snippets/decrby.test.yml b/doc/6/controllers/ms/decrby/snippets/decrby.test.yml new file mode 100644 index 000000000..63ce294a4 --- /dev/null +++ b/doc/6/controllers/ms/decrby/snippets/decrby.test.yml @@ -0,0 +1,9 @@ +name: ms#decrby +description: Decrements the number stored at key by a provided integer value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 42 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/del/index.md b/doc/6/controllers/ms/del/index.md new file mode 100644 index 000000000..ce4ad6873 --- /dev/null +++ b/doc/6/controllers/ms/del/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: del +--- + +# del + +Deletes a list of keys. + +[[_Redis documentation_]](https://redis.io/commands/del) + +## Arguments + +```js +del(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| Keys to delete | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of deleted keys. + +## Usage + +<<< ./snippets/del.js diff --git a/doc/6/controllers/ms/del/snippets/del.js b/doc/6/controllers/ms/del/snippets/del.js new file mode 100644 index 000000000..e6b0ea88e --- /dev/null +++ b/doc/6/controllers/ms/del/snippets/del.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + await kuzzle.ms.del(['foo']); + + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/del/snippets/del.test.yml b/doc/6/controllers/ms/del/snippets/del.test.yml new file mode 100644 index 000000000..fc4ff56b2 --- /dev/null +++ b/doc/6/controllers/ms/del/snippets/del.test.yml @@ -0,0 +1,9 @@ +name: ms#del +description: Deletes a list of keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 0 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/exists/index.md b/doc/6/controllers/ms/exists/index.md new file mode 100644 index 000000000..ce8355dc8 --- /dev/null +++ b/doc/6/controllers/ms/exists/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: exists +--- + +# exists + +Checks if the specified keys exist in the database. + +[[_Redis documentation_]](https://redis.io/commands/exists) + +## Arguments + +```js +exists(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | --------------------------- | +| `keys` |
string[]
| Keys to check for existence | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of existing keys. + +## Usage + +<<< ./snippets/exists.js diff --git a/doc/6/controllers/ms/exists/snippets/exists.js b/doc/6/controllers/ms/exists/snippets/exists.js new file mode 100644 index 000000000..3266a19bb --- /dev/null +++ b/doc/6/controllers/ms/exists/snippets/exists.js @@ -0,0 +1,13 @@ +try { + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); + + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/exists/snippets/exists.test.yml b/doc/6/controllers/ms/exists/snippets/exists.test.yml new file mode 100644 index 000000000..8c0752b08 --- /dev/null +++ b/doc/6/controllers/ms/exists/snippets/exists.test.yml @@ -0,0 +1,11 @@ +name: ms#exists +description: Checks if the specified keys exist in the database +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^1$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/expire/index.md b/doc/6/controllers/ms/expire/index.md new file mode 100644 index 000000000..0c34e8d80 --- /dev/null +++ b/doc/6/controllers/ms/expire/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: expire +--- + +# expire + +Sets a timeout (in seconds) on a key. After the timeout has expired, the key is automatically deleted. + +[[_Redis documentation_]](https://redis.io/commands/expire) + +## Arguments + +```js +expire(key, seconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ---------------------------------------- | +| `key` |
string
| Key | +| `seconds` |
integer
| Number of seconds before the key expires | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation was successful or not. + +## Usage + +<<< ./snippets/expire.js diff --git a/doc/6/controllers/ms/expire/snippets/expire.js b/doc/6/controllers/ms/expire/snippets/expire.js new file mode 100644 index 000000000..ff0720951 --- /dev/null +++ b/doc/6/controllers/ms/expire/snippets/expire.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: -1 + console.log(await kuzzle.ms.ttl('foo')); + + await kuzzle.ms.expire('foo', 10); + + // Prints: 10 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/expire/snippets/expire.test.yml b/doc/6/controllers/ms/expire/snippets/expire.test.yml new file mode 100644 index 000000000..fac040455 --- /dev/null +++ b/doc/6/controllers/ms/expire/snippets/expire.test.yml @@ -0,0 +1,11 @@ +name: ms#expire +description: Sets a timeout (in seconds) on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - -1 + - ^[1-9]+ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/expireat/index.md b/doc/6/controllers/ms/expireat/index.md new file mode 100644 index 000000000..0995e3b00 --- /dev/null +++ b/doc/6/controllers/ms/expireat/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: expireat +--- + +# expireat + +Sets an expiration timestamp on a key. After the timestamp has been reached, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/expireat) + +## Arguments + +```js +expireat(key, timestamp, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------------------------------------------------------------ | +| `key` |
string
| Key | +| `timestamp` |
integer
| Expiration timestamp ([Epoch](https://en.wikipedia.org/wiki/Unix_time) format) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation was successful or not. + +## Usage + +<<< ./snippets/expireat.js diff --git a/doc/6/controllers/ms/expireat/snippets/expireat.js b/doc/6/controllers/ms/expireat/snippets/expireat.js new file mode 100644 index 000000000..c40f69d65 --- /dev/null +++ b/doc/6/controllers/ms/expireat/snippets/expireat.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + // Oct. 12, 2011 + await kuzzle.ms.expireat('foo', 1318425955); + + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/expireat/snippets/expireat.test.yml b/doc/6/controllers/ms/expireat/snippets/expireat.test.yml new file mode 100644 index 000000000..735ea84da --- /dev/null +++ b/doc/6/controllers/ms/expireat/snippets/expireat.test.yml @@ -0,0 +1,11 @@ +name: ms#expireat +description: Sets an expiration timestamp on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^1$ + - ^0$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/flushdb/index.md b/doc/6/controllers/ms/flushdb/index.md new file mode 100644 index 000000000..f0c7cd774 --- /dev/null +++ b/doc/6/controllers/ms/flushdb/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: flushdb +--- + +# flushdb + +Empties the database dedicated to client applications (the reserved space for Kuzzle is unaffected). + +[[_Redis documentation_]](https://redis.io/commands/flushdb) + +## Arguments + +```js +flushdb([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to `undefined` once the operation completes. + +## Usage + +<<< ./snippets/flushdb.js diff --git a/doc/6/controllers/ms/flushdb/snippets/flushdb.js b/doc/6/controllers/ms/flushdb/snippets/flushdb.js new file mode 100644 index 000000000..ceb31b43a --- /dev/null +++ b/doc/6/controllers/ms/flushdb/snippets/flushdb.js @@ -0,0 +1,6 @@ +try { + await kuzzle.ms.flushdb(); + console.log('Success'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/flushdb/snippets/flushdb.test.yml b/doc/6/controllers/ms/flushdb/snippets/flushdb.test.yml new file mode 100644 index 000000000..ae2331836 --- /dev/null +++ b/doc/6/controllers/ms/flushdb/snippets/flushdb.test.yml @@ -0,0 +1,9 @@ +name: ms#flushdb +description: Empties the database dedicated to client applications +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: Success +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/geoadd/index.md b/doc/6/controllers/ms/geoadd/index.md new file mode 100644 index 000000000..85899b4f0 --- /dev/null +++ b/doc/6/controllers/ms/geoadd/index.md @@ -0,0 +1,51 @@ +--- +code: true +type: page +title: geoadd +--- + +# geoadd + +Adds geospatial points to the specified key. + +[[_Redis documentation_]](https://redis.io/commands/geoadd) + +## Arguments + +```js +geoadd(key, geopoints, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | ------------------------ | +| `key` |
string
| Key | +| `geopoints` |
object[]
| List of geopoints to add | +| `options` |
object
| Optional query arguments | + +### geopoints + +List of objects, each one of those being a geopoint to be added, with the following properties: + +| Properties | Type | Description | +| ---------- | ----------------- | ----------------------------------------- | +| `lat` |
number
| Latitude | +| `lon` |
number
| Longitude | +| `name` |
string
| Unique point name (used as an identifier) | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of points added. + +## Usage + +<<< ./snippets/geoadd.js diff --git a/doc/6/controllers/ms/geoadd/snippets/geoadd.js b/doc/6/controllers/ms/geoadd/snippets/geoadd.js new file mode 100644 index 000000000..7bd4badde --- /dev/null +++ b/doc/6/controllers/ms/geoadd/snippets/geoadd.js @@ -0,0 +1,19 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + const result = await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: 2 + console.log(result); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/geoadd/snippets/geoadd.test.yml b/doc/6/controllers/ms/geoadd/snippets/geoadd.test.yml new file mode 100644 index 000000000..ab30f799c --- /dev/null +++ b/doc/6/controllers/ms/geoadd/snippets/geoadd.test.yml @@ -0,0 +1,9 @@ +name: ms#geoadd +description: Adds geospatial points to the specified key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: 2 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/geodist/index.md b/doc/6/controllers/ms/geodist/index.md new file mode 100644 index 000000000..2e07b878f --- /dev/null +++ b/doc/6/controllers/ms/geodist/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: geodist +--- + +# geodist + +Returns the distance between two geospatial members of a key (see [geoadd](/sdk/js/6/controllers/ms/geoadd)). + +The returned distance is expressed in meters by default. + +[[_Redis documentation_]](https://redis.io/commands/geodist) + +## Arguments + +```js +geodist(key, geopoint1, geopoint2, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ----------------- | -------------------------- | +| `key` |
string
| Key | +| `geopoint1` |
string
| First geopoint identifier | +| `geopoint2` |
string
| Second geopoint identifier | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `unit` |
string ('m')
| The unit used for the returned calculated distance.
Accepted values: `m`, `km`, `mi`, `ft` | + +## Resolve + +Resolves to the calculated distance. + +## Usage + +<<< ./snippets/geodist.js diff --git a/doc/6/controllers/ms/geodist/snippets/geodist.js b/doc/6/controllers/ms/geodist/snippets/geodist.js new file mode 100644 index 000000000..3d0346846 --- /dev/null +++ b/doc/6/controllers/ms/geodist/snippets/geodist.js @@ -0,0 +1,28 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; + +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: 1367.8521 + console.log(await kuzzle.ms.geodist('geofoo', 'HQ', 'other HQ')); + + // Prints: 4487.7038 + console.log(await kuzzle.ms.geodist( + 'geofoo', + 'HQ', + 'other HQ', + {unit: 'ft'} + )); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/geodist/snippets/geodist.test.yml b/doc/6/controllers/ms/geodist/snippets/geodist.test.yml new file mode 100644 index 000000000..8b97f33bb --- /dev/null +++ b/doc/6/controllers/ms/geodist/snippets/geodist.test.yml @@ -0,0 +1,11 @@ +name: ms#geodist +description: Returns the distance between two geospatial members of a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - 1367.8521 + - 4487.7038 +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/geohash/index.md b/doc/6/controllers/ms/geohash/index.md new file mode 100644 index 000000000..f807cbb5d --- /dev/null +++ b/doc/6/controllers/ms/geohash/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: geohash +--- + +# geohash + +Converts a key's geopoints (see [geoadd](/sdk/js/6/controllers/ms/geoadd)) into [geohashes](https://en.wikipedia.org/wiki/Geohash). + +[[_Redis documentation_]](https://redis.io/commands/geohash) + +## Arguments + +```js +geohash(key, geopoints, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | ---------------------------- | +| `key` |
string
| Key | +| `geopoints` |
string[]
| List of geopoints to convert | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of converted geohashes, in the same order than the one provided in the query. + +## Usage + +<<< ./snippets/geohash.js diff --git a/doc/6/controllers/ms/geohash/snippets/geohash.js b/doc/6/controllers/ms/geohash/snippets/geohash.js new file mode 100644 index 000000000..b15d82316 --- /dev/null +++ b/doc/6/controllers/ms/geohash/snippets/geohash.js @@ -0,0 +1,20 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; + +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: [ 'spfb0frz6x0', 'spfb09jv9n0' ] + console.log(await kuzzle.ms.geohash('geofoo', ['HQ', 'other HQ'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/geohash/snippets/geohash.test.yml b/doc/6/controllers/ms/geohash/snippets/geohash.test.yml new file mode 100644 index 000000000..a7c97b3d6 --- /dev/null +++ b/doc/6/controllers/ms/geohash/snippets/geohash.test.yml @@ -0,0 +1,9 @@ +name: ms#geohash +description: Converts a key's geopoints into geohashes +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "[ 'spfb0frz6x0', 'spfb09jv9n0' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/geopos/index.md b/doc/6/controllers/ms/geopos/index.md new file mode 100644 index 000000000..8603ee29c --- /dev/null +++ b/doc/6/controllers/ms/geopos/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: geopos +--- + +# geopos + +Returns the positions of the provided key's members (see [geoadd](/sdk/js/6/controllers/ms/geoadd)). + +[[_Redis documentation_]](https://redis.io/commands/geopos) + +## Arguments + +```js +geopos(key, geopoints, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------- | --------------------------- | +| `key` |
string
| Key | +| `geopoints` |
string[]
| List of geopoints to return | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the members positions (`[longitude, latitude]`), in the same order than the one provided in the query. + +## Usage + +<<< ./snippets/geopos.js diff --git a/doc/6/controllers/ms/geopos/snippets/geopos.js b/doc/6/controllers/ms/geopos/snippets/geopos.js new file mode 100644 index 000000000..3eb931671 --- /dev/null +++ b/doc/6/controllers/ms/geopos/snippets/geopos.js @@ -0,0 +1,24 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; + +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: + // [ + // [ 3.910904824733734, 43.607392252329916 ], + // [ 3.8971075415611267, 43.600221526170145 ] + // ] + console.log(await kuzzle.ms.geopos('geofoo', ['HQ', 'other HQ'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/geopos/snippets/geopos.test.yml b/doc/6/controllers/ms/geopos/snippets/geopos.test.yml new file mode 100644 index 000000000..322cc82c4 --- /dev/null +++ b/doc/6/controllers/ms/geopos/snippets/geopos.test.yml @@ -0,0 +1,11 @@ +name: ms#geopos +description: Returns the positions of the provided key's members +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ \\[ 3.910904824733734, 43.607392252329916 ]," + - "\\[ 3.8971075415611267, 43.600221526170145 ] ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/georadius/index.md b/doc/6/controllers/ms/georadius/index.md new file mode 100644 index 000000000..c605cb6ec --- /dev/null +++ b/doc/6/controllers/ms/georadius/index.md @@ -0,0 +1,56 @@ +--- +code: true +type: page +title: georadius +--- + +# georadius + +Returns the members (added with [geoadd](/sdk/js/6/controllers/ms/geoadd)) of a given key inside the provided geospatial radius. + +[[_Redis documentation_]](https://redis.io/commands/georadius) + +## Arguments + +```js +georadius(key, lon, lat, dist, unit, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `lon` |
number
| Longitude of the center | +| `lat` |
number
| Latitude of the center | +| `dist` |
number
| Distance from the center | +| `unit` |
string
| Unit of the distance parameter value.
Allowed values: `m`, `km`, `mi`, `ft` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | -------------------------- | -------------------------------------------------------------------------------------- | +| `count` |
integer
| Limit the number of returned geopoints to the provided value | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `sort` |
string
| Sort the result by distance, relative to the center.
Allowed values: `ASC`, `DESC` | +| `withcoord` |
boolean (false)
| Include the position of the matched geopoint in the result | +| `withdist` |
boolean (false)
| Include the calculated distance from the matched geopoint to center | + +## Resolve + +Resolves to an array of matched geopoints. + +Each returned geopoint is an object with the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ----------------------------------------------------------------------------------------------------------- | +| `name` |
string
| Geopoint identifier | +| `coordinates` |
number[]
| Geopoint coordinates in the following format: `[lon, lat]`. Only available if the option `withcoord` is set | +| `distance` |
number
| Distance from the center. Only available if the option `withdist` is set | + +## Usage + +<<< ./snippets/georadius.js diff --git a/doc/6/controllers/ms/georadius/snippets/georadius.js b/doc/6/controllers/ms/georadius/snippets/georadius.js new file mode 100644 index 000000000..0dba84211 --- /dev/null +++ b/doc/6/controllers/ms/georadius/snippets/georadius.js @@ -0,0 +1,61 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: [ { name: 'other HQ' }, { name: 'HQ' } ] + console.log(await kuzzle.ms.georadius( + 'geofoo', + 3.948711, + 43.5764455, + 20, + 'km' + )); + + // Prints: + // [ + // { name: 'other HQ', distance: 4.9271 }, + // { name: 'HQ', distance: 4.596 } + // ] + console.log(await kuzzle.ms.georadius( + 'geofoo', + 3.948711, + 43.5764455, + 20, + 'km', + {withdist: true, sort: 'desc'} + )); + + // Prints: + // [ + // { + // name: 'HQ', + // distance: 4.596, + // coordinates: [ 3.910904824733734, 43.607392252329916 ] + // }, + // { + // name: 'other HQ', + // distance: 4.9271, + // coordinates: [ 3.8971075415611267, 43.600221526170145 ] + // } + // ] + console.log(await kuzzle.ms.georadius( + 'geofoo', + 3.948711, + 43.5764455, + 20, + 'km', + {withcoord: true, withdist: true, sort: 'asc'} + )); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/georadius/snippets/georadius.test.yml b/doc/6/controllers/ms/georadius/snippets/georadius.test.yml new file mode 100644 index 000000000..c3ca8f98b --- /dev/null +++ b/doc/6/controllers/ms/georadius/snippets/georadius.test.yml @@ -0,0 +1,18 @@ +name: ms#georadius +description: Returns the members of a given key inside the provided geospatial radius +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { name: 'other HQ' }, { name: 'HQ' } " + - "\\[ { name: 'other HQ', distance: 4.9271 }," + - " { name: 'HQ', distance: 4.596 } ]" + - "\\[ { name: 'HQ'," + - " distance: 4.596," + - " coordinates: \\[ 3.910904824733734, 43.607392252329916 ] }," + - " { name: 'other HQ'," + - " distance: 4.9271," + - " coordinates: \\[ 3.8971075415611267, 43.600221526170145 ] } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/georadiusbymember/index.md b/doc/6/controllers/ms/georadiusbymember/index.md new file mode 100644 index 000000000..797c931de --- /dev/null +++ b/doc/6/controllers/ms/georadiusbymember/index.md @@ -0,0 +1,55 @@ +--- +code: true +type: page +title: georadiusbymember +--- + +# georadiusbymember + +Returns the members (added with [geoadd](/sdk/js/6/controllers/ms/geoadd)) of a given key inside the provided geospatial radius, centered around one of a key's member. + +[[_Redis documentation_]](https://redis.io/commands/georadiusbymember) + +## Arguments + +```js +georadiusbymember(key, geopoint, dist, unit, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | ------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `geopoint` |
string
| Name of the geopoint to use as the center | +| `dist` |
number
| Distance from the center | +| `unit` |
string
| Unit of the distance parameter value.
Allowed values: `m`, `km`, `mi`, `ft` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | -------------------------- | -------------------------------------------------------------------------------------- | +| `count` |
integer
| Limit the number of returned geopoints to the provided value | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `sort` |
string
| Sort the result by distance, relative to the center.
Allowed values: `ASC`, `DESC` | +| `withcoord` |
boolean (false)
| Include the position of the matched geopoint in the result | +| `withdist` |
boolean (false)
| Include the calculated distance from the matched geopoint to center | + +## Resolve + +Resolves to an array of matched geopoints. + +Each returned geopoint is an object with the following properties: + +| Property | Type | Description | +| ------------- | ------------------- | ----------------------------------------------------------------------------------------------------------- | +| `name` |
string
| Geopoint identifier | +| `coordinates` |
number[]
| Geopoint coordinates in the following format: `[lon, lat]`. Only available if the option `withcoord` is set | +| `distance` |
number
| Distance from the center. Only available if the option `withdist` is set | + +## Usage + +<<< ./snippets/georadiusbymember.js diff --git a/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.js b/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.js new file mode 100644 index 000000000..6cb4a07b5 --- /dev/null +++ b/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.js @@ -0,0 +1,58 @@ +const kuzzleHQ = { + lon: 3.9109057, + lat: 43.6073913, + name: 'HQ' +}; +const otherHQ = { + lon: 3.897105, + lat: 43.6002203, + name: 'other HQ' +}; + +try { + await kuzzle.ms.geoadd('geofoo', [kuzzleHQ, otherHQ]); + + // Prints: [ { name: 'other HQ' }, { name: 'HQ' } ] + console.log(await kuzzle.ms.georadiusbymember( + 'geofoo', + 'HQ', + 1500, + 'm' + )); + + // Prints: + // [ + // { name: 'other HQ', distance: 1367.8521 }, + // { name: 'HQ', distance: 0 } + // ] + console.log(await kuzzle.ms.georadiusbymember( + 'geofoo', + 'HQ', + 1500, + 'm', + {withdist: true, sort: 'desc'} + )); + + // Prints: + // [ + // { + // name: 'HQ', + // distance: 0, + // coordinates: [ 3.910904824733734, 43.607392252329916 ] + // }, + // { + // name: 'other HQ', + // distance: 1367.8521, + // coordinates: [ 3.8971075415611267, 43.600221526170145 ] + // } + // ] + console.log(await kuzzle.ms.georadiusbymember( + 'geofoo', + 'HQ', + 1500, + 'm', + {withcoord: true, withdist: true, sort: 'asc'} + )); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml b/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml new file mode 100644 index 000000000..a86177ce7 --- /dev/null +++ b/doc/6/controllers/ms/georadiusbymember/snippets/georadiusbymember.test.yml @@ -0,0 +1,18 @@ +name: ms#georadiusbymember +description: Returns the members of a given key inside a radius centered around a key's member +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { name: '(other |)HQ' }, { name: '(other |)HQ' } ]" + - "\\[ { name: 'other HQ', distance: 1367.8521 }," + - " { name: 'HQ', distance: 0 } ]" + - "\\[ { name: 'HQ'," + - " distance: 0," + - " coordinates: \\[ 3.910904824733734, 43.607392252329916 ] }," + - " { name: 'other HQ'," + - " distance: 1367.8521," + - " coordinates: \\[ 3.8971075415611267, 43.600221526170145 ] } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/get/index.md b/doc/6/controllers/ms/get/index.md new file mode 100644 index 000000000..c128a9317 --- /dev/null +++ b/doc/6/controllers/ms/get/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: get +--- + +# get + +Gets the value of a key. + +[[_Redis documentation_]](https://redis.io/commands/get) + +## Arguments + +```js +get(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the key's value. + +## Usage + +<<< ./snippets/get.js diff --git a/doc/6/controllers/ms/get/snippets/get.js b/doc/6/controllers/ms/get/snippets/get.js new file mode 100644 index 000000000..a96b3fd23 --- /dev/null +++ b/doc/6/controllers/ms/get/snippets/get.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 'bar' + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/get/snippets/get.test.yml b/doc/6/controllers/ms/get/snippets/get.test.yml new file mode 100644 index 000000000..ede9c73c5 --- /dev/null +++ b/doc/6/controllers/ms/get/snippets/get.test.yml @@ -0,0 +1,9 @@ +name: ms#get +description: Gets the value of a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: bar +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/getbit/index.md b/doc/6/controllers/ms/getbit/index.md new file mode 100644 index 000000000..7a2da9a1d --- /dev/null +++ b/doc/6/controllers/ms/getbit/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: getbit +--- + +# getbit + +Returns the bit value at the provided offset, in the string value stored in a key. + +[[_Redis documentation_]](https://redis.io/commands/getbit) + +## Arguments + +```js +getbit(key, offset, options]) + +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `offset` |
integer
| Bit offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the bit at the provided offset (`0` or `1`). + +## Usage + +<<< ./snippets/getbit.js diff --git a/doc/6/controllers/ms/getbit/snippets/getbit.js b/doc/6/controllers/ms/getbit/snippets/getbit.js new file mode 100644 index 000000000..9c3755030 --- /dev/null +++ b/doc/6/controllers/ms/getbit/snippets/getbit.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('foo', '\x01'); + + // Prints: 0 + console.log(await kuzzle.ms.getbit('foo', 2)); + + // Prints: 1 + console.log(await kuzzle.ms.getbit('foo', 7)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/getbit/snippets/getbit.test.yml b/doc/6/controllers/ms/getbit/snippets/getbit.test.yml new file mode 100644 index 000000000..ea8ca01aa --- /dev/null +++ b/doc/6/controllers/ms/getbit/snippets/getbit.test.yml @@ -0,0 +1,11 @@ +name: ms#getbit +description: Returns the bit value at the provided offset +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^1$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/getrange/index.md b/doc/6/controllers/ms/getrange/index.md new file mode 100644 index 000000000..735bbe6e3 --- /dev/null +++ b/doc/6/controllers/ms/getrange/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: getrange +--- + +# getrange + +Returns a substring of a key's value. + +[[_Redis documentation_]](https://redis.io/commands/getrange) + +## Arguments + +```js +getrange(key, start, end, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `start` |
integer
| Range start | +| `end` |
integer
| Range end | +| `options` |
object
| Optional query arguments | + +The arguments `start` and `end` can be negative. In that case, the offset is calculated from the end of the string, going backward. For instance, -3 is the third character from the end of the string. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the extracted substring. + +## Usage + +<<< ./snippets/getrange.js diff --git a/doc/6/controllers/ms/getrange/snippets/getrange.js b/doc/6/controllers/ms/getrange/snippets/getrange.js new file mode 100644 index 000000000..653f100c4 --- /dev/null +++ b/doc/6/controllers/ms/getrange/snippets/getrange.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('foo', 'foobar'); + + // Prints: 'oba' + console.log(await kuzzle.ms.getrange('foo', 2, 4)); + + // Prints: 'bar' + console.log(await kuzzle.ms.getrange('foo', -3, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/getrange/snippets/getrange.test.yml b/doc/6/controllers/ms/getrange/snippets/getrange.test.yml new file mode 100644 index 000000000..052d7892c --- /dev/null +++ b/doc/6/controllers/ms/getrange/snippets/getrange.test.yml @@ -0,0 +1,11 @@ +name: ms#getrange +description: Returns a substring of a key's value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^oba$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/getset/index.md b/doc/6/controllers/ms/getset/index.md new file mode 100644 index 000000000..2db4e8667 --- /dev/null +++ b/doc/6/controllers/ms/getset/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: getset +--- + +# getset + +Sets a new value for a key, and returns its previously stored value. + +[[_Redis documentation_]](https://redis.io/commands/getset) + +## Arguments + +```js +getset(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
\*
| New key value. | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the previously set value, or `null` if the key didn't exist prior to this operation. + +## Usage + +<<< ./snippets/getset.js diff --git a/doc/6/controllers/ms/getset/snippets/getset.js b/doc/6/controllers/ms/getset/snippets/getset.js new file mode 100644 index 000000000..c94e699ff --- /dev/null +++ b/doc/6/controllers/ms/getset/snippets/getset.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 'bar' + console.log(await kuzzle.ms.getset('foo', 'qux')); + + // Prints: 'qux' + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/getset/snippets/getset.test.yml b/doc/6/controllers/ms/getset/snippets/getset.test.yml new file mode 100644 index 000000000..1ae03ae64 --- /dev/null +++ b/doc/6/controllers/ms/getset/snippets/getset.test.yml @@ -0,0 +1,11 @@ +name: ms#getset +description: Sets a new value for a key, and returns its previously stored value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^bar$ + - ^qux$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hdel/index.md b/doc/6/controllers/ms/hdel/index.md new file mode 100644 index 000000000..38c1f83ca --- /dev/null +++ b/doc/6/controllers/ms/hdel/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hdel +--- + +# hdel + +Removes fields from a hash. + +[[_Redis documentation_]](https://redis.io/commands/hdel) + +## Arguments + +```js +hdel(key, fields, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Hash key | +| `fields` |
string[]
| Field keys to delete | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of deleted fields. + +## Usage + +<<< ./snippets/hdel.js diff --git a/doc/6/controllers/ms/hdel/snippets/hdel.js b/doc/6/controllers/ms/hdel/snippets/hdel.js new file mode 100644 index 000000000..bf39b7875 --- /dev/null +++ b/doc/6/controllers/ms/hdel/snippets/hdel.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.hset('hashfoo', 'field1', 'val'); + await kuzzle.ms.hset('hashfoo', 'field2', 'val'); + + // Prints: 2 + console.log(await kuzzle.ms.hlen('hashfoo')); + + await kuzzle.ms.hdel('hashfoo', ['field2']); + + // Prints: 1 + console.log(await kuzzle.ms.hlen('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hdel/snippets/hdel.test.yml b/doc/6/controllers/ms/hdel/snippets/hdel.test.yml new file mode 100644 index 000000000..b460b4995 --- /dev/null +++ b/doc/6/controllers/ms/hdel/snippets/hdel.test.yml @@ -0,0 +1,11 @@ +name: ms#hdel +description: Removes fields from a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - ^1$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hexists/index.md b/doc/6/controllers/ms/hexists/index.md new file mode 100644 index 000000000..fd1473b39 --- /dev/null +++ b/doc/6/controllers/ms/hexists/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hexists +--- + +# hexists + +Checks if a field exists in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hexists) + +## Arguments + +```js +hexists(key, field, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the checked field exists or not. + +## Usage + +<<< ./snippets/hexists.js diff --git a/doc/6/controllers/ms/hexists/snippets/hexists.js b/doc/6/controllers/ms/hexists/snippets/hexists.js new file mode 100644 index 000000000..f4c7702cd --- /dev/null +++ b/doc/6/controllers/ms/hexists/snippets/hexists.js @@ -0,0 +1,11 @@ +try { + // Prints: false + console.log(await kuzzle.ms.hexists('hashfoo', 'foo')); + + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: true + console.log(await kuzzle.ms.hexists('hashfoo', 'foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hexists/snippets/hexists.test.yml b/doc/6/controllers/ms/hexists/snippets/hexists.test.yml new file mode 100644 index 000000000..7d599a8f7 --- /dev/null +++ b/doc/6/controllers/ms/hexists/snippets/hexists.test.yml @@ -0,0 +1,11 @@ +name: ms#hexists +description: Checks if a field exists in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^false$ + - ^true$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hget/index.md b/doc/6/controllers/ms/hget/index.md new file mode 100644 index 000000000..141228e71 --- /dev/null +++ b/doc/6/controllers/ms/hget/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hget +--- + +# hget + +Returns the field's value of a hash. + +[[_Redis documentation_]](https://redis.io/commands/hget) + +## Arguments + +```js +hget(key, field, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Returns the field's value. + +## Usage + +<<< ./snippets/hget.js diff --git a/doc/6/controllers/ms/hget/snippets/hget.js b/doc/6/controllers/ms/hget/snippets/hget.js new file mode 100644 index 000000000..1ba799358 --- /dev/null +++ b/doc/6/controllers/ms/hget/snippets/hget.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: 'bar' + console.log(await kuzzle.ms.hget('hashfoo', 'foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hget/snippets/hget.test.yml b/doc/6/controllers/ms/hget/snippets/hget.test.yml new file mode 100644 index 000000000..d020ee976 --- /dev/null +++ b/doc/6/controllers/ms/hget/snippets/hget.test.yml @@ -0,0 +1,9 @@ +name: ms#hget +description: Returns the field's value of a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hgetall/index.md b/doc/6/controllers/ms/hgetall/index.md new file mode 100644 index 000000000..99de3f6bd --- /dev/null +++ b/doc/6/controllers/ms/hgetall/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hgetall +--- + +# hgetall + +Returns all fields and values of a hash. + +[[_Redis documentation_]](https://redis.io/commands/hgetall) + +## Arguments + +```js +hgetall(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representation of the hash. + +## Usage + +<<< ./snippets/hgetall.js diff --git a/doc/6/controllers/ms/hgetall/snippets/hgetall.js b/doc/6/controllers/ms/hgetall/snippets/hgetall.js new file mode 100644 index 000000000..bf19115fc --- /dev/null +++ b/doc/6/controllers/ms/hgetall/snippets/hgetall.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.hset('hashfoo', 'field1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'field2', 'val2'); + + // Prints: { field1: 'val1', field2: 'val2' } + console.log(await kuzzle.ms.hgetall('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hgetall/snippets/hgetall.test.yml b/doc/6/controllers/ms/hgetall/snippets/hgetall.test.yml new file mode 100644 index 000000000..372468a4e --- /dev/null +++ b/doc/6/controllers/ms/hgetall/snippets/hgetall.test.yml @@ -0,0 +1,9 @@ +name: ms#hgetall +description: Returns all fields and values of a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "{ field1: 'val1', field2: 'val2' }" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hincrby/index.md b/doc/6/controllers/ms/hincrby/index.md new file mode 100644 index 000000000..d280835d7 --- /dev/null +++ b/doc/6/controllers/ms/hincrby/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: hincrby +--- + +# hincrby + +Increments the number stored in a hash field by the provided integer value. + +[[_Redis documentation_]](https://redis.io/commands/hincrby) + +## Arguments + +```js +hincrby(key, field, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `increment` |
integer
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated value of the hash's field. + +## Usage + +<<< ./snippets/hincrby.js diff --git a/doc/6/controllers/ms/hincrby/snippets/hincrby.js b/doc/6/controllers/ms/hincrby/snippets/hincrby.js new file mode 100644 index 000000000..ce4190e4b --- /dev/null +++ b/doc/6/controllers/ms/hincrby/snippets/hincrby.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'answer', 100); + + // Prints: 42 + console.log(await kuzzle.ms.hincrby('hashfoo', 'answer', -58)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hincrby/snippets/hincrby.test.yml b/doc/6/controllers/ms/hincrby/snippets/hincrby.test.yml new file mode 100644 index 000000000..3fce3c9b1 --- /dev/null +++ b/doc/6/controllers/ms/hincrby/snippets/hincrby.test.yml @@ -0,0 +1,9 @@ +name: ms#hincrby +description: Increments the number stored in a hash field by the provided integer value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^42$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hincrbyfloat/index.md b/doc/6/controllers/ms/hincrbyfloat/index.md new file mode 100644 index 000000000..f72b5f865 --- /dev/null +++ b/doc/6/controllers/ms/hincrbyfloat/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: hincrbyfloat +--- + +# hincrbyfloat + +Increments the number stored in a hash field by the provided float value. + +[[_Redis documentation_]](https://redis.io/commands/hincrbyfloat) + +## Arguments + +```js +hincrbyfloat(key, field, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `increment` |
number
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated value of the hash's field. + +## Usage + +<<< ./snippets/hincrbyfloat.js diff --git a/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js b/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js new file mode 100644 index 000000000..d64d30df2 --- /dev/null +++ b/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'almost_pi', 3); + + // Prints: 3.14159 + console.log(await kuzzle.ms.hincrbyfloat('hashfoo', 'almost_pi', 0.14159)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml b/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml new file mode 100644 index 000000000..9fc6064bc --- /dev/null +++ b/doc/6/controllers/ms/hincrbyfloat/snippets/hincrbyfloat.test.yml @@ -0,0 +1,9 @@ +name: ms#hincrbyfloat +description: Increments the number stored in a hash field by the provided float value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3.14159$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hkeys/index.md b/doc/6/controllers/ms/hkeys/index.md new file mode 100644 index 000000000..11d1e5063 --- /dev/null +++ b/doc/6/controllers/ms/hkeys/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hkeys +--- + +# hkeys + +Returns all field names contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hkeys) + +## Arguments + +```js +hkeys(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of hash field names. + +## Usage + +<<< ./snippets/hkeys.js diff --git a/doc/6/controllers/ms/hkeys/snippets/hkeys.js b/doc/6/controllers/ms/hkeys/snippets/hkeys.js new file mode 100644 index 000000000..799a493a4 --- /dev/null +++ b/doc/6/controllers/ms/hkeys/snippets/hkeys.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.hset('hashfoo', 'never', 'foo'); + await kuzzle.ms.hset('hashfoo', 'gonna', 'bar'); + await kuzzle.ms.hset('hashfoo', 'give you up', 'baz'); + + // Prints: ['never', 'gonna', 'give you up'] + console.log(await kuzzle.ms.hkeys('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hkeys/snippets/hkeys.test.yml b/doc/6/controllers/ms/hkeys/snippets/hkeys.test.yml new file mode 100644 index 000000000..91f00c124 --- /dev/null +++ b/doc/6/controllers/ms/hkeys/snippets/hkeys.test.yml @@ -0,0 +1,9 @@ +name: ms#hkeys +description: Returns all field names contained in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: \[ 'never', 'gonna', 'give you up' ] +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hlen/index.md b/doc/6/controllers/ms/hlen/index.md new file mode 100644 index 000000000..06421b8f7 --- /dev/null +++ b/doc/6/controllers/ms/hlen/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hlen +--- + +# hlen + +Returns the number of fields contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hlen) + +## Arguments + +```js +hlen(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of fields stored in a hash. + +## Usage + +<<< ./snippets/hlen.js diff --git a/doc/6/controllers/ms/hlen/snippets/hlen.js b/doc/6/controllers/ms/hlen/snippets/hlen.js new file mode 100644 index 000000000..4f0ff81ac --- /dev/null +++ b/doc/6/controllers/ms/hlen/snippets/hlen.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: 3 + console.log(await kuzzle.ms.hlen('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hlen/snippets/hlen.test.yml b/doc/6/controllers/ms/hlen/snippets/hlen.test.yml new file mode 100644 index 000000000..48c6a46b9 --- /dev/null +++ b/doc/6/controllers/ms/hlen/snippets/hlen.test.yml @@ -0,0 +1,9 @@ +name: ms#hlen +description: Returns the number of fields contained in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hmget/index.md b/doc/6/controllers/ms/hmget/index.md new file mode 100644 index 000000000..756ad89bd --- /dev/null +++ b/doc/6/controllers/ms/hmget/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hmget +--- + +# hmget + +Returns the values of the specified hash's fields. + +[[_Redis documentation_]](https://redis.io/commands/hmget) + +## Arguments + +```js +hmget(key, fields, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Hash key | +| `fields` |
string[]
| Field names | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of requested field values, in the same order than in the query. + +## Usage + +<<< ./snippets/hmget.js diff --git a/doc/6/controllers/ms/hmget/snippets/hmget.js b/doc/6/controllers/ms/hmget/snippets/hmget.js new file mode 100644 index 000000000..75883c886 --- /dev/null +++ b/doc/6/controllers/ms/hmget/snippets/hmget.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: [ 'val3', 'val1' ] + console.log(await kuzzle.ms.hmget('hashfoo', ['key3', 'key1'])); + +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hmget/snippets/hmget.test.yml b/doc/6/controllers/ms/hmget/snippets/hmget.test.yml new file mode 100644 index 000000000..3a9848b28 --- /dev/null +++ b/doc/6/controllers/ms/hmget/snippets/hmget.test.yml @@ -0,0 +1,9 @@ +name: ms#hmget +description: Returns the values of the specified hash's fields +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: \[ 'val3', 'val1' ] +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hmset/index.md b/doc/6/controllers/ms/hmset/index.md new file mode 100644 index 000000000..757f061b1 --- /dev/null +++ b/doc/6/controllers/ms/hmset/index.md @@ -0,0 +1,50 @@ +--- +code: true +type: page +title: hmset +--- + +# hmset + +Sets multiple fields at once in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hmset) + +## Arguments + +```js +hmset(key, entries, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | -------------------------------- | +| `key` |
string
| Hash key | +| `entries` |
object[]
| List of field-value pairs to set | +| `options` |
object
| Optional query arguments | + +### entries + +The `entries` array lists the fields to set in the hash. Each entry object has the following properties: + +| Properties | Type | Description | +| ---------- | ----------------- | ----------- | +| `field` |
string
| Field name | +| `value` |
string
| Field value | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the fields have been set. + +## Usage + +<<< ./snippets/hmset.js diff --git a/doc/6/controllers/ms/hmset/snippets/hmset.js b/doc/6/controllers/ms/hmset/snippets/hmset.js new file mode 100644 index 000000000..81ebbdc55 --- /dev/null +++ b/doc/6/controllers/ms/hmset/snippets/hmset.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.hmset( + 'hashfoo', + [ + {field: 'key1', value: 'val1'}, + {field: 'key2', value: 'val2'}, + {field: 'key3', value: 'val3'} + ] + ); + + // Prints: { key1: 'val1', key2: 'val2', key3: 'val3' } + console.log(await kuzzle.ms.hgetall('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hmset/snippets/hmset.test.yml b/doc/6/controllers/ms/hmset/snippets/hmset.test.yml new file mode 100644 index 000000000..fbda2f343 --- /dev/null +++ b/doc/6/controllers/ms/hmset/snippets/hmset.test.yml @@ -0,0 +1,9 @@ +name: ms#hmset +description: Sets multiple fields at once in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: { key1: 'val1', key2: 'val2', key3: 'val3' } +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hscan/index.md b/doc/6/controllers/ms/hscan/index.md new file mode 100644 index 000000000..5112e513e --- /dev/null +++ b/doc/6/controllers/ms/hscan/index.md @@ -0,0 +1,53 @@ +--- +code: true +type: page +title: hscan +--- + +# hscan + +Iterates incrementally over fields contained in a hash, using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/hscan) + +## Arguments + +```js +hscan(key, cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Hash key | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | ----------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of field-value pairs, alternating field names and values | + +## Usage + +<<< ./snippets/hscan.js diff --git a/doc/6/controllers/ms/hscan/snippets/hscan.js b/doc/6/controllers/ms/hscan/snippets/hscan.js new file mode 100644 index 000000000..7aca23b5e --- /dev/null +++ b/doc/6/controllers/ms/hscan/snippets/hscan.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: + // { + // cursor: '0', + // values: [ 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' ] + // } + console.log(await kuzzle.ms.hscan('hashfoo', 0)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hscan/snippets/hscan.test.yml b/doc/6/controllers/ms/hscan/snippets/hscan.test.yml new file mode 100644 index 000000000..ac0824180 --- /dev/null +++ b/doc/6/controllers/ms/hscan/snippets/hscan.test.yml @@ -0,0 +1,11 @@ +name: ms#hscan +description: Iterates incrementally over fields contained in a hash, using a cursor +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0'," + - "values: \\[ 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' ] }" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hset/index.md b/doc/6/controllers/ms/hset/index.md new file mode 100644 index 000000000..d45888150 --- /dev/null +++ b/doc/6/controllers/ms/hset/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: hset +--- + +# hset + +Sets a field and its value in a hash. + +If the key does not exist, a new key holding a hash is created. + +If the field already exists, its value is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/hset) + +## Arguments + +```js +hset(key, field, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Hash key | +| `field` |
string
| Field name | +| `value` |
string
| Field value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the field has been set. + +## Usage + +<<< ./snippets/hset.js diff --git a/doc/6/controllers/ms/hset/snippets/hset.js b/doc/6/controllers/ms/hset/snippets/hset.js new file mode 100644 index 000000000..f5416da3f --- /dev/null +++ b/doc/6/controllers/ms/hset/snippets/hset.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: { foo: 'bar' } + console.log(await kuzzle.ms.hgetall('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hset/snippets/hset.test.yml b/doc/6/controllers/ms/hset/snippets/hset.test.yml new file mode 100644 index 000000000..f8f074f45 --- /dev/null +++ b/doc/6/controllers/ms/hset/snippets/hset.test.yml @@ -0,0 +1,9 @@ +name: ms#hset +description: Sets a field and its value in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "{ foo: 'bar' }" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hsetnx/index.md b/doc/6/controllers/ms/hsetnx/index.md new file mode 100644 index 000000000..f49525e41 --- /dev/null +++ b/doc/6/controllers/ms/hsetnx/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: hsetnx +--- + +# hsetnx + +Sets a field and its value in a hash, only if the field does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/hsetnx) + +## Arguments + +```js +hsetnx(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +## Usage + +<<< ./snippets/hsetnx.js diff --git a/doc/6/controllers/ms/hsetnx/snippets/hsetnx.js b/doc/6/controllers/ms/hsetnx/snippets/hsetnx.js new file mode 100644 index 000000000..3d35c494a --- /dev/null +++ b/doc/6/controllers/ms/hsetnx/snippets/hsetnx.js @@ -0,0 +1,13 @@ +try { + // Prints: true + console.log(await kuzzle.ms.hsetnx('hashfoo', 'foo', 'bar')); + + // Prints: false + console.log(await kuzzle.ms.hsetnx('hashfoo', 'foo', 'qux')); + + // Prints: bar + console.log(await kuzzle.ms.hget('hashfoo', 'foo')); + +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hsetnx/snippets/hsetnx.test.yml b/doc/6/controllers/ms/hsetnx/snippets/hsetnx.test.yml new file mode 100644 index 000000000..7742ae0c6 --- /dev/null +++ b/doc/6/controllers/ms/hsetnx/snippets/hsetnx.test.yml @@ -0,0 +1,12 @@ +name: ms#hsetnx +description: Sets a field and its value in a hash, only if the field does not already exist +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^true$ + - ^false$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hstrlen/index.md b/doc/6/controllers/ms/hstrlen/index.md new file mode 100644 index 000000000..23f2ce826 --- /dev/null +++ b/doc/6/controllers/ms/hstrlen/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: hstrlen +--- + +# hstrlen + +Returns the string length of a field's value in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hstrlen) + +## Arguments + +```js +hstrlen(key, field, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `field` |
string
| Field name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the field value length. + +## Usage + +<<< ./snippets/hstrlen.js diff --git a/doc/6/controllers/ms/hstrlen/snippets/hstrlen.js b/doc/6/controllers/ms/hstrlen/snippets/hstrlen.js new file mode 100644 index 000000000..ff3e5e7bd --- /dev/null +++ b/doc/6/controllers/ms/hstrlen/snippets/hstrlen.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.hset('hashfoo', 'foo', 'bar'); + + // Prints: 3 + console.log(await kuzzle.ms.hstrlen('hashfoo', 'foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hstrlen/snippets/hstrlen.test.yml b/doc/6/controllers/ms/hstrlen/snippets/hstrlen.test.yml new file mode 100644 index 000000000..ef71bdf52 --- /dev/null +++ b/doc/6/controllers/ms/hstrlen/snippets/hstrlen.test.yml @@ -0,0 +1,9 @@ +name: ms#hstrlen +description: Returns the string length of a field's value in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/hvals/index.md b/doc/6/controllers/ms/hvals/index.md new file mode 100644 index 000000000..7efa03a56 --- /dev/null +++ b/doc/6/controllers/ms/hvals/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: hvals +--- + +# hvals + +Returns all values contained in a hash. + +[[_Redis documentation_]](https://redis.io/commands/hvals) + +## Arguments + +```js +hvals(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of hash's field values. + +## Usage + +<<< ./snippets/hvals.js diff --git a/doc/6/controllers/ms/hvals/snippets/hvals.js b/doc/6/controllers/ms/hvals/snippets/hvals.js new file mode 100644 index 000000000..4d3159555 --- /dev/null +++ b/doc/6/controllers/ms/hvals/snippets/hvals.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.hset('hashfoo', 'key1', 'val1'); + await kuzzle.ms.hset('hashfoo', 'key2', 'val2'); + await kuzzle.ms.hset('hashfoo', 'key3', 'val3'); + + // Prints: [ 'val1', 'val2', 'val3' ] + console.log(await kuzzle.ms.hvals('hashfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/hvals/snippets/hvals.test.yml b/doc/6/controllers/ms/hvals/snippets/hvals.test.yml new file mode 100644 index 000000000..efe75d69d --- /dev/null +++ b/doc/6/controllers/ms/hvals/snippets/hvals.test.yml @@ -0,0 +1,9 @@ +name: ms#hvals +description: Returns all values contained in a hash +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'val1', 'val2', 'val3' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/incr/index.md b/doc/6/controllers/ms/incr/index.md new file mode 100644 index 000000000..81ac08daa --- /dev/null +++ b/doc/6/controllers/ms/incr/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: incr +--- + +# incr + +Increments the number stored at `key` by 1. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incr) + +## Arguments + +```js +incr(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the incremented key value. + +## Usage + +<<< ./snippets/incr.js diff --git a/doc/6/controllers/ms/incr/snippets/incr.js b/doc/6/controllers/ms/incr/snippets/incr.js new file mode 100644 index 000000000..833c8b1b3 --- /dev/null +++ b/doc/6/controllers/ms/incr/snippets/incr.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 41); + + // Prints: 42 + console.log(await kuzzle.ms.incr('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/incr/snippets/incr.test.yml b/doc/6/controllers/ms/incr/snippets/incr.test.yml new file mode 100644 index 000000000..8eb956a22 --- /dev/null +++ b/doc/6/controllers/ms/incr/snippets/incr.test.yml @@ -0,0 +1,9 @@ +name: ms#incr +description: Increments the number stored at key by 1 +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^42$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/incrby/index.md b/doc/6/controllers/ms/incrby/index.md new file mode 100644 index 000000000..fc17f6264 --- /dev/null +++ b/doc/6/controllers/ms/incrby/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: incrby +--- + +# incrby + +Increments the number stored at `key` by the provided integer value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incrby) + +## Arguments + +```js +incrby(key, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ------------------------ | +| `key` |
string
| Key | +| `increment` |
integer
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the incremented key value. + +## Usage + +<<< ./snippets/incrby.js diff --git a/doc/6/controllers/ms/incrby/snippets/incrby.js b/doc/6/controllers/ms/incrby/snippets/incrby.js new file mode 100644 index 000000000..9fbf7e5a0 --- /dev/null +++ b/doc/6/controllers/ms/incrby/snippets/incrby.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 100); + + // Prints: 42 + console.log(await kuzzle.ms.incrby('foo', -58)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/incrby/snippets/incrby.test.yml b/doc/6/controllers/ms/incrby/snippets/incrby.test.yml new file mode 100644 index 000000000..66b93f139 --- /dev/null +++ b/doc/6/controllers/ms/incrby/snippets/incrby.test.yml @@ -0,0 +1,9 @@ +name: ms#incrby +description: Increments the number stored at `key` by the provided integer value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^42$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/incrbyfloat/index.md b/doc/6/controllers/ms/incrbyfloat/index.md new file mode 100644 index 000000000..fca7286f8 --- /dev/null +++ b/doc/6/controllers/ms/incrbyfloat/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: incrbyfloat +--- + +# incrbyfloat + +Increments the number stored at `key` by the provided float value. If the key does not exist, it is set to 0 before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/incrbyfloat) + +## Arguments + +```js +incrbyfloat(key, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `increment` |
number
| Increment value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the incremented value. + +## Usage + +<<< ./snippets/incrbyfloat.js diff --git a/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.js b/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.js new file mode 100644 index 000000000..c518c2614 --- /dev/null +++ b/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('almost pi', 3); + + // Prints: 3.14159 + console.log(await kuzzle.ms.incrbyfloat('almost pi', 0.14159)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml b/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml new file mode 100644 index 000000000..f9695c2f5 --- /dev/null +++ b/doc/6/controllers/ms/incrbyfloat/snippets/incrbyfloat.test.yml @@ -0,0 +1,9 @@ +name: ms#incrbyfloat +description: Increments the number stored at key by the provided float value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3.14159$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/index.md b/doc/6/controllers/ms/index.md new file mode 100644 index 000000000..02d0feef7 --- /dev/null +++ b/doc/6/controllers/ms/index.md @@ -0,0 +1,6 @@ +--- +code: true +type: branch +title: ms +description: memory storage controller documentation +--- diff --git a/doc/6/controllers/ms/keys/index.md b/doc/6/controllers/ms/keys/index.md new file mode 100644 index 000000000..53433d409 --- /dev/null +++ b/doc/6/controllers/ms/keys/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: keys +--- + +# keys + +Returns all keys matching the provided pattern. + +[[_Redis documentation_]](https://redis.io/commands/keys) + +## Arguments + +```js +keys(pattern, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ----------------- | +| `pattern` |
string
| Match pattern | +| | `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of key identifiers. + +## Usage + +<<< ./snippets/keys.js diff --git a/doc/6/controllers/ms/keys/snippets/keys.js b/doc/6/controllers/ms/keys/snippets/keys.js new file mode 100644 index 000000000..bcf66a5d7 --- /dev/null +++ b/doc/6/controllers/ms/keys/snippets/keys.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + await kuzzle.ms.set('Suddenly', 'Bananas'); + await kuzzle.ms.set('Hello', 'World'); + + // Prints: [ 'foo', 'Hello' ] + console.log(await kuzzle.ms.keys('*o')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/keys/snippets/keys.test.yml b/doc/6/controllers/ms/keys/snippets/keys.test.yml new file mode 100644 index 000000000..ec079ebad --- /dev/null +++ b/doc/6/controllers/ms/keys/snippets/keys.test.yml @@ -0,0 +1,9 @@ +name: ms#keys +description: Returns all keys matching the provided pattern +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ '(Hello|foo)', '(Hello|foo)' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lindex/index.md b/doc/6/controllers/ms/lindex/index.md new file mode 100644 index 000000000..2841425a3 --- /dev/null +++ b/doc/6/controllers/ms/lindex/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: lindex +--- + +# lindex + +Returns the element at the provided index in a list. + +[[_Redis documentation_]](https://redis.io/commands/lindex) + +## Arguments + +```js +lindex(key, index, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| List key | +| `index` |
integer
| List index | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the stored value at the provided list index. + +## Usage + +<<< ./snippets/lindex.js diff --git a/doc/6/controllers/ms/lindex/snippets/lindex.js b/doc/6/controllers/ms/lindex/snippets/lindex.js new file mode 100644 index 000000000..5effdd332 --- /dev/null +++ b/doc/6/controllers/ms/lindex/snippets/lindex.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: bar + console.log(await kuzzle.ms.lindex('listfoo', 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lindex/snippets/lindex.test.yml b/doc/6/controllers/ms/lindex/snippets/lindex.test.yml new file mode 100644 index 000000000..8abf7ad84 --- /dev/null +++ b/doc/6/controllers/ms/lindex/snippets/lindex.test.yml @@ -0,0 +1,9 @@ +name: ms#lindex +description: Returns the element at the provided index in a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/linsert/index.md b/doc/6/controllers/ms/linsert/index.md new file mode 100644 index 000000000..5bba89e36 --- /dev/null +++ b/doc/6/controllers/ms/linsert/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: linsert +--- + +# linsert + +Inserts a value in a list, either before or after a pivot value. + +[[_Redis documentation_]](https://redis.io/commands/linsert) + +## Arguments + +```js +linsert(key, position, pivot, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ----------------- | --------------------------------------------------------------------- | +| `key` |
string
| List key | +| `position` |
string
| Position relative to the pivot.
Allowed values: `before`, `after` | +| `pivot` |
string
| Existing list value to use as a pivot | +| `value` |
string
| Value to insert | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated length of the list. + +## Usage + +<<< ./snippets/linsert.js diff --git a/doc/6/controllers/ms/linsert/snippets/linsert.js b/doc/6/controllers/ms/linsert/snippets/linsert.js new file mode 100644 index 000000000..1c73644d8 --- /dev/null +++ b/doc/6/controllers/ms/linsert/snippets/linsert.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + await kuzzle.ms.linsert('listfoo', 'before', 'bar', 'qux'); + + // Prints: [ 'foo', 'qux', 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/linsert/snippets/linsert.test.yml b/doc/6/controllers/ms/linsert/snippets/linsert.test.yml new file mode 100644 index 000000000..ffa21f82c --- /dev/null +++ b/doc/6/controllers/ms/linsert/snippets/linsert.test.yml @@ -0,0 +1,9 @@ +name: ms#linsert +description: Inserts a value in a list, either before or after a pivot value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo', 'qux', 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/llen/index.md b/doc/6/controllers/ms/llen/index.md new file mode 100644 index 000000000..be28549f7 --- /dev/null +++ b/doc/6/controllers/ms/llen/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: llen +--- + +# llen + +Returns the length of a list. + +[[_Redis documentation_]](https://redis.io/commands/llen) + +## Arguments + +```js +llen(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the length of the list. + +## Usage + +<<< ./snippets/llen.js diff --git a/doc/6/controllers/ms/llen/snippets/llen.js b/doc/6/controllers/ms/llen/snippets/llen.js new file mode 100644 index 000000000..7ff06fa91 --- /dev/null +++ b/doc/6/controllers/ms/llen/snippets/llen.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: 3 + console.log(await kuzzle.ms.llen('listfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/llen/snippets/llen.test.yml b/doc/6/controllers/ms/llen/snippets/llen.test.yml new file mode 100644 index 000000000..65112883a --- /dev/null +++ b/doc/6/controllers/ms/llen/snippets/llen.test.yml @@ -0,0 +1,9 @@ +name: ms#llen +description: Returns the length of a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lpop/index.md b/doc/6/controllers/ms/lpop/index.md new file mode 100644 index 000000000..dc2533a33 --- /dev/null +++ b/doc/6/controllers/ms/lpop/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: lpop +--- + +# lpop + +Removes and returns the first element of a list. + +[[_Redis documentation_]](https://redis.io/commands/lpop) + +## Arguments + +```js +lpop(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the value extracted from the list. + +## Usage + +<<< ./snippets/lpop.js diff --git a/doc/6/controllers/ms/lpop/snippets/lpop.js b/doc/6/controllers/ms/lpop/snippets/lpop.js new file mode 100644 index 000000000..1e411615d --- /dev/null +++ b/doc/6/controllers/ms/lpop/snippets/lpop.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: foo + console.log(await kuzzle.ms.lpop('listfoo')); + + // Prints: [ 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lpop/snippets/lpop.test.yml b/doc/6/controllers/ms/lpop/snippets/lpop.test.yml new file mode 100644 index 000000000..c812c4378 --- /dev/null +++ b/doc/6/controllers/ms/lpop/snippets/lpop.test.yml @@ -0,0 +1,11 @@ +name: ms#lpop +description: Removes and returns the first element of a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^foo$ + - "\\[ 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lpush/index.md b/doc/6/controllers/ms/lpush/index.md new file mode 100644 index 000000000..abe0e6fc1 --- /dev/null +++ b/doc/6/controllers/ms/lpush/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: lpush +--- + +# lpush + +Prepends the specified values to a list. + +If the key does not exist, it is created holding an empty list before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/lpush) + +## Arguments + +```js +lpush(key, values, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| List key | +| `values` |
string[]
| Values to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated length of the list. + +## Usage + +<<< ./snippets/lpush.js diff --git a/doc/6/controllers/ms/lpush/snippets/lpush.js b/doc/6/controllers/ms/lpush/snippets/lpush.js new file mode 100644 index 000000000..e8a8534f2 --- /dev/null +++ b/doc/6/controllers/ms/lpush/snippets/lpush.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foobar']); + + // Prints: 3 + console.log(await kuzzle.ms.lpush('listfoo', ['World', 'Hello'])); + + // Prints: [ 'Hello', 'World', 'foobar' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lpush/snippets/lpush.test.yml b/doc/6/controllers/ms/lpush/snippets/lpush.test.yml new file mode 100644 index 000000000..0d671ed18 --- /dev/null +++ b/doc/6/controllers/ms/lpush/snippets/lpush.test.yml @@ -0,0 +1,11 @@ +name: ms#lpush +description: Prepends the specified values to a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^3$ + - "\\[ 'Hello', 'World', 'foobar' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lpushx/index.md b/doc/6/controllers/ms/lpushx/index.md new file mode 100644 index 000000000..37606192d --- /dev/null +++ b/doc/6/controllers/ms/lpushx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: lpushx +--- + +# lpushx + +Prepends the specified value to a list, only if the key already exists and if it holds a list. + +[[_Redis documentation_]](https://redis.io/commands/lpushx) + +## Arguments + +```js +lpushx(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Existing list key | +| `value` |
string
| Value to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated list length. + +## Usage + +<<< ./snippets/lpushx.js diff --git a/doc/6/controllers/ms/lpushx/snippets/lpushx.js b/doc/6/controllers/ms/lpushx/snippets/lpushx.js new file mode 100644 index 000000000..0adf26657 --- /dev/null +++ b/doc/6/controllers/ms/lpushx/snippets/lpushx.js @@ -0,0 +1,17 @@ +try { + // Prints: 0 + console.log(await kuzzle.ms.lpushx('listfoo', 'foo')); + + // Prints: [] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); + + await kuzzle.ms.lpush('listfoo', ['bar']); + + // Prints: 2 + console.log(await kuzzle.ms.lpushx('listfoo', 'foo')); + + // Prints: [ 'foo', 'bar' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lpushx/snippets/lpushx.test.yml b/doc/6/controllers/ms/lpushx/snippets/lpushx.test.yml new file mode 100644 index 000000000..029a61412 --- /dev/null +++ b/doc/6/controllers/ms/lpushx/snippets/lpushx.test.yml @@ -0,0 +1,13 @@ +name: ms#lpushx +description: Prepends the specified value to an existing list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - "\\[]" + - ^2$ + - "\\[ 'foo', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lrange/index.md b/doc/6/controllers/ms/lrange/index.md new file mode 100644 index 000000000..1997c0299 --- /dev/null +++ b/doc/6/controllers/ms/lrange/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: lrange +--- + +# lrange + +Returns the list elements between the `start` and `stop` positions. + +Offsets start at `0`, and the range is inclusive. + +[[_Redis documentation_]](https://redis.io/commands/lrange) + +## Arguments + +```js +lrange(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | -------------------------- | +| `key` |
string
| List key | +| `start` |
integer
| Starting index (inclusive) | +| `stop` |
integer
| Ending index (inclusive) | +| `options` |
object
| Optional query arguments | + +The `start` and `stop` arguments can be negative. In that case, the offset is calculated from the end of the list, going backward. For instance, -3 is the third element from the end of the list. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of list elements. + +## Usage + +<<< ./snippets/lrange.js diff --git a/doc/6/controllers/ms/lrange/snippets/lrange.js b/doc/6/controllers/ms/lrange/snippets/lrange.js new file mode 100644 index 000000000..f7b57bfe5 --- /dev/null +++ b/doc/6/controllers/ms/lrange/snippets/lrange.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + // Prints: [ 'b', 'c', 'd' ] + console.log(await kuzzle.ms.lrange('listfoo', 1, 3)); + + // Prints: [ d', 'e' ] + console.log(await kuzzle.ms.lrange('listfoo', 3, -2)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lrange/snippets/lrange.test.yml b/doc/6/controllers/ms/lrange/snippets/lrange.test.yml new file mode 100644 index 000000000..0c47e421a --- /dev/null +++ b/doc/6/controllers/ms/lrange/snippets/lrange.test.yml @@ -0,0 +1,11 @@ +name: ms#lrange +description: Returns the list elements between the start and stop positions +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ 'b', 'c', 'd' ]" + - "\\[ 'd', 'e' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lrem/index.md b/doc/6/controllers/ms/lrem/index.md new file mode 100644 index 000000000..87f7c3bc1 --- /dev/null +++ b/doc/6/controllers/ms/lrem/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: lrem +--- + +# lrem + +Removes the first occurences of an element from a list. + +[[_Redis documentation_]](https://redis.io/commands/lrem) + +## Arguments + +```js +lrem(key, count, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ---------------------------------------------- | +| `key` |
string
| List key | +| `count` |
integer
| Number of the first found occurences to remove | +| `value` |
string
| Value to remove | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed elements. + +## Usage + +<<< ./snippets/lrem.js diff --git a/doc/6/controllers/ms/lrem/snippets/lrem.js b/doc/6/controllers/ms/lrem/snippets/lrem.js new file mode 100644 index 000000000..0775173d5 --- /dev/null +++ b/doc/6/controllers/ms/lrem/snippets/lrem.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'foo', 'baz', 'foo']); + + // Prints: 2 + console.log(await kuzzle.ms.lrem('listfoo', 2, 'foo')); + + // Prints: [ 'bar', 'baz', 'foo' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lrem/snippets/lrem.test.yml b/doc/6/controllers/ms/lrem/snippets/lrem.test.yml new file mode 100644 index 000000000..dd43df76d --- /dev/null +++ b/doc/6/controllers/ms/lrem/snippets/lrem.test.yml @@ -0,0 +1,11 @@ +name: ms#lrem +description: Removes the first occurences of an element from a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - "\\[ 'bar', 'baz', 'foo' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/lset/index.md b/doc/6/controllers/ms/lset/index.md new file mode 100644 index 000000000..004a8281c --- /dev/null +++ b/doc/6/controllers/ms/lset/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: lset +--- + +# lset + +Sets the list element at `index` with the provided value. + +[[_Redis documentation_]](https://redis.io/commands/lset) + +## Arguments + +```js +lset(key, index, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ----------------------------------------------------------------------------------------------- | +| `key` |
string
| List key | +| `index` |
integer
| Index of the list (lists are 0-indexed). If negative, it goes backward from the end of the list | +| `value` |
string
| Value to set | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the new value is set. + +## Usage + +<<< ./snippets/lset.js diff --git a/doc/6/controllers/ms/lset/snippets/lset.js b/doc/6/controllers/ms/lset/snippets/lset.js new file mode 100644 index 000000000..1d8e24dad --- /dev/null +++ b/doc/6/controllers/ms/lset/snippets/lset.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.rpush('listfoo', ['qux', 'bar', 'baz']); + + await kuzzle.ms.lset('listfoo', 0, 'foo'); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/lset/snippets/lset.test.yml b/doc/6/controllers/ms/lset/snippets/lset.test.yml new file mode 100644 index 000000000..8102ca92f --- /dev/null +++ b/doc/6/controllers/ms/lset/snippets/lset.test.yml @@ -0,0 +1,9 @@ +name: ms#lset +description: Sets the list element at index with the provided value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo', 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/ltrim/index.md b/doc/6/controllers/ms/ltrim/index.md new file mode 100644 index 000000000..daee7ddb7 --- /dev/null +++ b/doc/6/controllers/ms/ltrim/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: ltrim +--- + +# ltrim + +Trims an existing list so that it will contain only the specified range of elements specified. + +[[_Redis documentation_]](https://redis.io/commands/ltrim) + +## Arguments + +```js +ltrim(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | -------------------------- | +| `key` |
string
| List key | +| `start` |
integer
| Starting index (inclusive) | +| `stop` |
integer
| Ending index (inclusive) | +| `options` |
object
| Optional query arguments | + +The `start` and `stop` arguments can be negative. In that case, the offset is calculated from the end of the list, going backward. For instance, -3 is the third element from the end of the list. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation is finished. + +## Usage + +<<< ./snippets/ltrim.js diff --git a/doc/6/controllers/ms/ltrim/snippets/ltrim.js b/doc/6/controllers/ms/ltrim/snippets/ltrim.js new file mode 100644 index 000000000..70ecb7d93 --- /dev/null +++ b/doc/6/controllers/ms/ltrim/snippets/ltrim.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.rpush('listfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + await kuzzle.ms.ltrim('listfoo', 3, -2); + + // Prints [ 'd', 'e' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/ltrim/snippets/ltrim.test.yml b/doc/6/controllers/ms/ltrim/snippets/ltrim.test.yml new file mode 100644 index 000000000..96629d68e --- /dev/null +++ b/doc/6/controllers/ms/ltrim/snippets/ltrim.test.yml @@ -0,0 +1,9 @@ +name: ms#ltrim +description: Trims an existing list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'd', 'e' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/mget/index.md b/doc/6/controllers/ms/mget/index.md new file mode 100644 index 000000000..99488fafa --- /dev/null +++ b/doc/6/controllers/ms/mget/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: mget +--- + +# mget + +Returns the values of the provided keys. + +[[_Redis documentation_]](https://redis.io/commands/mget) + +## Arguments + +```js +mget(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of keys to get | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of corresponding key values, in the same order than the one provided in the query. + +## Usage + +<<< ./snippets/mget.js diff --git a/doc/6/controllers/ms/mget/snippets/mget.js b/doc/6/controllers/ms/mget/snippets/mget.js new file mode 100644 index 000000000..46bfef49f --- /dev/null +++ b/doc/6/controllers/ms/mget/snippets/mget.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + await kuzzle.ms.set('hello', 'world'); + + // Prints: [ 'world', 'bar' ] + console.log(await kuzzle.ms.mget(['hello', 'foo'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/mget/snippets/mget.test.yml b/doc/6/controllers/ms/mget/snippets/mget.test.yml new file mode 100644 index 000000000..23195d61f --- /dev/null +++ b/doc/6/controllers/ms/mget/snippets/mget.test.yml @@ -0,0 +1,9 @@ +name: ms#mget +description: Returns the values of the provided keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'world', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/mset/index.md b/doc/6/controllers/ms/mset/index.md new file mode 100644 index 000000000..ddd5cf64f --- /dev/null +++ b/doc/6/controllers/ms/mset/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: mset +--- + +# mset + +Sets the provided keys to their respective values. If a key does not exist, it is created. Otherwise, the key's value is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/mset) + +## Arguments + +```js +mset(entries, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------ | +| `entries` |
object[]
| List of key-value pairs to set | +| `options` |
object
| Optional query arguments | + +### entries + +The `entries` argument is an array of objects. Each object is a key-value pair, defined with the following properties: + +| Property | Type | Description | +| -------- | ----------------- | ----------- | +| `key` |
string
| Key | +| `value` |
\*
| Value | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves successfully once the keys are set. + +## Usage + +<<< ./snippets/mset.js diff --git a/doc/6/controllers/ms/mset/snippets/mset.js b/doc/6/controllers/ms/mset/snippets/mset.js new file mode 100644 index 000000000..579c5a54f --- /dev/null +++ b/doc/6/controllers/ms/mset/snippets/mset.js @@ -0,0 +1,15 @@ +try { + // Prints: 0 + console.log(await kuzzle.ms.exists(['key1', 'key2', 'key3'])); + + await kuzzle.ms.mset([ + { key: 'key1', value: 'val1' }, + { key: 'key2', value: 'val2' }, + { key: 'key3', value: 'val3' } + ]); + + // Prints: 3 + console.log(await kuzzle.ms.exists(['key1', 'key2', 'key3'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/mset/snippets/mset.test.yml b/doc/6/controllers/ms/mset/snippets/mset.test.yml new file mode 100644 index 000000000..8effcbefc --- /dev/null +++ b/doc/6/controllers/ms/mset/snippets/mset.test.yml @@ -0,0 +1,11 @@ +name: ms#mset +description: Sets the provided keys to their respective values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^3$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/msetnx/index.md b/doc/6/controllers/ms/msetnx/index.md new file mode 100644 index 000000000..64cc99b2a --- /dev/null +++ b/doc/6/controllers/ms/msetnx/index.md @@ -0,0 +1,49 @@ +--- +code: true +type: page +title: msetnx +--- + +# msetnx + +Sets the provided keys to their respective values, only if they do not exist. If a key exists, then the whole operation is aborted and no key is set. + +[[_Redis documentation_]](https://redis.io/commands/msetnx) + +## Arguments + +```js +msetnx(entries, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------ | +| `entries` |
object[]
| List of key-value pairs to set | +| `options` |
object
| Optional query arguments | + +### entries + +The `entries` argument is an array of objects. Each object is a key-value pair, defined with the following properties: + +| Property | Type | Description | +| -------- | ----------------- | ----------- | +| `key` |
string
| Key | +| `value` |
\*
| Value | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the keys have been set or not. + +## Usage + +<<< ./snippets/msetnx.js diff --git a/doc/6/controllers/ms/msetnx/snippets/msetnx.js b/doc/6/controllers/ms/msetnx/snippets/msetnx.js new file mode 100644 index 000000000..70a76ee8c --- /dev/null +++ b/doc/6/controllers/ms/msetnx/snippets/msetnx.js @@ -0,0 +1,19 @@ +const entries = [ + { key: 'hello', value: 'world' }, + { key: 'foo', value: 'bar' } +]; + +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: false + // (the entire operation aborted) + console.log(await kuzzle.ms.msetnx(entries)); + + await kuzzle.ms.del('foo'); + + // Prints: true + console.log(await kuzzle.ms.msetnx(entries)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/msetnx/snippets/msetnx.test.yml b/doc/6/controllers/ms/msetnx/snippets/msetnx.test.yml new file mode 100644 index 000000000..f73ac5b14 --- /dev/null +++ b/doc/6/controllers/ms/msetnx/snippets/msetnx.test.yml @@ -0,0 +1,11 @@ +name: ms#msetnx +description: Sets the provided keys to their respective values, only if they do not exist +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^false$ + - ^true$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/object/index.md b/doc/6/controllers/ms/object/index.md new file mode 100644 index 000000000..9c87e3bcc --- /dev/null +++ b/doc/6/controllers/ms/object/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: object +--- + +# object + +Inspects the low-level properties of a key. + +[[_Redis documentation_]](https://redis.io/commands/object) + +## Arguments + +```js +object(key, subcommand, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | ---------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `subcommand` |
string
| Object property to inspect.
Allowed values: `encoding`, `idletime`, `refcount` | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the inspected property value. + +## Usage + +<<< ./snippets/object.js diff --git a/doc/6/controllers/ms/object/snippets/object.js b/doc/6/controllers/ms/object/snippets/object.js new file mode 100644 index 000000000..beef89a13 --- /dev/null +++ b/doc/6/controllers/ms/object/snippets/object.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.sadd('foo', ['bar', 'baz']); + + // Prints: hashtable + console.log(await kuzzle.ms.object('foo', 'encoding')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/object/snippets/object.test.yml b/doc/6/controllers/ms/object/snippets/object.test.yml new file mode 100644 index 000000000..ec96be4b7 --- /dev/null +++ b/doc/6/controllers/ms/object/snippets/object.test.yml @@ -0,0 +1,9 @@ +name: ms#object +description: Inspects the low-level properties of a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^hashtable$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/persist/index.md b/doc/6/controllers/ms/persist/index.md new file mode 100644 index 000000000..19963bcc9 --- /dev/null +++ b/doc/6/controllers/ms/persist/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: persist +--- + +# persist + +Removes the expiration delay or timestamp from a key, making it persistent. + +[[_Redis documentation_]](https://redis.io/commands/persist) + +## Arguments + +```js +persist(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the key is persisted. + +## Usage + +<<< ./snippets/persist.js diff --git a/doc/6/controllers/ms/persist/snippets/persist.js b/doc/6/controllers/ms/persist/snippets/persist.js new file mode 100644 index 000000000..aba174638 --- /dev/null +++ b/doc/6/controllers/ms/persist/snippets/persist.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.setex('foo', 'bar', 60); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); + + await kuzzle.ms.persist('foo'); + + // Prints: -1 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/persist/snippets/persist.test.yml b/doc/6/controllers/ms/persist/snippets/persist.test.yml new file mode 100644 index 000000000..5a3b014a3 --- /dev/null +++ b/doc/6/controllers/ms/persist/snippets/persist.test.yml @@ -0,0 +1,11 @@ +name: ms#persist +description: Removes the expiration delay or timestamp from a key, making it persistent +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^[0-9]+$ + - "-1" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/pexpire/index.md b/doc/6/controllers/ms/pexpire/index.md new file mode 100644 index 000000000..92a540532 --- /dev/null +++ b/doc/6/controllers/ms/pexpire/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: pexpire +--- + +# pexpire + +Sets a timeout (in milliseconds) on a key. After the timeout has expired, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/pexpire) + +## Arguments + +```js +pexpire(key, milliseconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| -------------- | ------------------ | ----------------------------------------------------- | +| `key` |
string
| Key | +| `milliseconds` |
integer
| Number of milliseconds after which the key is deleted | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean, telling whether the operation succeeded or not. + +## Usage + +<<< ./snippets/pexpire.js diff --git a/doc/6/controllers/ms/pexpire/snippets/pexpire.js b/doc/6/controllers/ms/pexpire/snippets/pexpire.js new file mode 100644 index 000000000..6cb30e4d7 --- /dev/null +++ b/doc/6/controllers/ms/pexpire/snippets/pexpire.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: -1 + console.log(await kuzzle.ms.ttl('foo')); + + await kuzzle.ms.pexpire('foo', 60000); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/pexpire/snippets/pexpire.test.yml b/doc/6/controllers/ms/pexpire/snippets/pexpire.test.yml new file mode 100644 index 000000000..caf2552ea --- /dev/null +++ b/doc/6/controllers/ms/pexpire/snippets/pexpire.test.yml @@ -0,0 +1,11 @@ +name: ms#pexpire +description: Sets a timeout (in milliseconds) on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^-1$ + - ^[0-9]{1,2}$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/pexpireat/index.md b/doc/6/controllers/ms/pexpireat/index.md new file mode 100644 index 000000000..ff31c6941 --- /dev/null +++ b/doc/6/controllers/ms/pexpireat/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: pexpireat +--- + +# pexpireat + +Sets an expiration timestamp (in Epoch-milis) on a key. After the timestamp has been reached, the key will automatically be deleted. + +[[_Redis documentation_]](https://redis.io/commands/pexpireat) + +## Arguments + +```js +pexpireat(key, timestamp, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ----------------------------------------------------------------------------------------------- | +| `key` |
string
| Key | +| `timestamp` |
integer
| Expiration timestamp ([Epoch](https://en.wikipedia.org/wiki/Unix_time) format, in milliseconds) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation was successful or not. + +## Usage + +<<< ./snippets/pexpireat.js diff --git a/doc/6/controllers/ms/pexpireat/snippets/pexpireat.js b/doc/6/controllers/ms/pexpireat/snippets/pexpireat.js new file mode 100644 index 000000000..3a40c7fec --- /dev/null +++ b/doc/6/controllers/ms/pexpireat/snippets/pexpireat.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: 1 + console.log(await kuzzle.ms.exists(['foo'])); + + // Oct. 12, 2011 + await kuzzle.ms.pexpireat('foo', 1318425955000); + + // Prints: 0 + console.log(await kuzzle.ms.exists(['foo'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/pexpireat/snippets/pexpireat.test.yml b/doc/6/controllers/ms/pexpireat/snippets/pexpireat.test.yml new file mode 100644 index 000000000..d2f23f5e8 --- /dev/null +++ b/doc/6/controllers/ms/pexpireat/snippets/pexpireat.test.yml @@ -0,0 +1,11 @@ +name: ms#pexpireat +description: Sets an expiration timestamp on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^1$ + - ^0$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/pfadd/index.md b/doc/6/controllers/ms/pfadd/index.md new file mode 100644 index 000000000..32bc0b613 --- /dev/null +++ b/doc/6/controllers/ms/pfadd/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: pfadd +--- + +# pfadd + +Adds elements to a [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure. + +[[_Redis documentation_]](https://redis.io/commands/pfadd) + +## Arguments + +```js +pfadd(key, elements, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| HyperLogLog key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Returns a boolean telling whether the addition altered the HyperLogLog structure or not. + +## Usage + +<<< ./snippets/pfadd.js diff --git a/doc/6/controllers/ms/pfadd/snippets/pfadd.js b/doc/6/controllers/ms/pfadd/snippets/pfadd.js new file mode 100644 index 000000000..26c01e1bb --- /dev/null +++ b/doc/6/controllers/ms/pfadd/snippets/pfadd.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.pfadd('hllfoo', ['foo', 'bar', 'baz', 'qux']); + + // Prints: 4 + console.log(await kuzzle.ms.pfcount('hllfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/pfadd/snippets/pfadd.test.yml b/doc/6/controllers/ms/pfadd/snippets/pfadd.test.yml new file mode 100644 index 000000000..a471b2507 --- /dev/null +++ b/doc/6/controllers/ms/pfadd/snippets/pfadd.test.yml @@ -0,0 +1,9 @@ +name: ms#pfadd +description: Adds elements to a HyperLogLog data structure +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^4$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/pfcount/index.md b/doc/6/controllers/ms/pfcount/index.md new file mode 100644 index 000000000..e6e8245eb --- /dev/null +++ b/doc/6/controllers/ms/pfcount/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: pfcount +--- + +# pfcount + +Returns the probabilistic cardinality of a [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structure, or of the merged HyperLogLog structures if more than 1 is provided (see [pfadd](/sdk/js/6/controllers/ms/pfadd)). + +[[_Redis documentation_]](https://redis.io/commands/pfcount) + +## Arguments + +```js +pfcount(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of HyperLogLog keys | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the merged HyperLogLog structures cardinality. + +## Usage + +<<< ./snippets/pfcount.js diff --git a/doc/6/controllers/ms/pfcount/snippets/pfcount.js b/doc/6/controllers/ms/pfcount/snippets/pfcount.js new file mode 100644 index 000000000..53871f22e --- /dev/null +++ b/doc/6/controllers/ms/pfcount/snippets/pfcount.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.pfadd('hllfoo', ['foo', 'bar', 'baz']); + await kuzzle.ms.pfadd('hllfoo2', ['hello', 'world', 'foo']); + + // Prints: 5 + console.log(await kuzzle.ms.pfcount(['hllfoo', 'hllfoo2'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/pfcount/snippets/pfcount.test.yml b/doc/6/controllers/ms/pfcount/snippets/pfcount.test.yml new file mode 100644 index 000000000..e172ba101 --- /dev/null +++ b/doc/6/controllers/ms/pfcount/snippets/pfcount.test.yml @@ -0,0 +1,9 @@ +name: ms#pfcount +description: Returns the probabilistic cardinality of a HyperLogLog data structure +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^5$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/pfmerge/index.md b/doc/6/controllers/ms/pfmerge/index.md new file mode 100644 index 000000000..ed883f3f0 --- /dev/null +++ b/doc/6/controllers/ms/pfmerge/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: pfmerge +--- + +# pfmerge + +Merges multiple [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) data structures into an unique HyperLogLog structure, approximating the cardinality of the union of the source structures. + +[[_Redis documentation_]](https://redis.io/commands/pfmerge) + +## Arguments + +```js +pfmerge(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | --------------------------------- | +| `dest` |
string
| Destination key | +| `sources` |
string[]
| List of HyperLogLog keys to merge | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/pfmerge.js diff --git a/doc/6/controllers/ms/pfmerge/snippets/pfmerge.js b/doc/6/controllers/ms/pfmerge/snippets/pfmerge.js new file mode 100644 index 000000000..3e186cba6 --- /dev/null +++ b/doc/6/controllers/ms/pfmerge/snippets/pfmerge.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.pfadd('hllfoo', ['foo', 'bar', 'baz']); + await kuzzle.ms.pfadd('hllfoo2', ['hello', 'world', 'foo']); + + await kuzzle.ms.pfmerge('hllmerged', ['hllfoo', 'hllfoo2']); + + // Prints: 5 + console.log(await kuzzle.ms.pfcount(['hllmerged'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/pfmerge/snippets/pfmerge.test.yml b/doc/6/controllers/ms/pfmerge/snippets/pfmerge.test.yml new file mode 100644 index 000000000..aa7772bda --- /dev/null +++ b/doc/6/controllers/ms/pfmerge/snippets/pfmerge.test.yml @@ -0,0 +1,9 @@ +name: ms#pfmerge +description: Merges multiple HyperLogLog data structures +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^5$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/ping/index.md b/doc/6/controllers/ms/ping/index.md new file mode 100644 index 000000000..fb757401c --- /dev/null +++ b/doc/6/controllers/ms/ping/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: ping +--- + +# ping + +Pings the memory storage database. + +[[_Redis documentation_]](https://redis.io/commands/ping) + +## Arguments + +```js +ping([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the string `PONG`. + +## Usage + +<<< ./snippets/ping.js diff --git a/doc/6/controllers/ms/ping/snippets/ping.js b/doc/6/controllers/ms/ping/snippets/ping.js new file mode 100644 index 000000000..0290c406a --- /dev/null +++ b/doc/6/controllers/ms/ping/snippets/ping.js @@ -0,0 +1,6 @@ +try { + // Prints: PONG + console.log(await kuzzle.ms.ping()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/ping/snippets/ping.test.yml b/doc/6/controllers/ms/ping/snippets/ping.test.yml new file mode 100644 index 000000000..2de8803ee --- /dev/null +++ b/doc/6/controllers/ms/ping/snippets/ping.test.yml @@ -0,0 +1,9 @@ +name: ms#ping +description: Pings the memory storage database +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^PONG$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/psetex/index.md b/doc/6/controllers/ms/psetex/index.md new file mode 100644 index 000000000..587999708 --- /dev/null +++ b/doc/6/controllers/ms/psetex/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: psetex +--- + +# psetex + +Sets a key with the provided value, and an expiration delay expressed in milliseconds. If the key does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/psetex) + +## Arguments + +```js +psetex(key, value, milliseconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| -------------- | ------------------ | ----------------------------------------------------- | +| `key` |
string
| Key | +| `value` |
string
| Value | +| `milliseconds` |
integer
| Number of milliseconds after which the key is deleted | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/psetex.js diff --git a/doc/6/controllers/ms/psetex/snippets/psetex.js b/doc/6/controllers/ms/psetex/snippets/psetex.js new file mode 100644 index 000000000..f23cc7ffc --- /dev/null +++ b/doc/6/controllers/ms/psetex/snippets/psetex.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.psetex('foo', 'bar', 60000); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/psetex/snippets/psetex.test.yml b/doc/6/controllers/ms/psetex/snippets/psetex.test.yml new file mode 100644 index 000000000..e18aafc99 --- /dev/null +++ b/doc/6/controllers/ms/psetex/snippets/psetex.test.yml @@ -0,0 +1,11 @@ +name: ms#psetex +description: Sets a key with the provided value, and an expiration delay expressed in milliseconds +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^[0-9]{1,2}$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/pttl/index.md b/doc/6/controllers/ms/pttl/index.md new file mode 100644 index 000000000..477790477 --- /dev/null +++ b/doc/6/controllers/ms/pttl/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: pttl +--- + +# pttl + +Returns the remaining time to live of a key, in milliseconds. + +[[_Redis documentation_]](https://redis.io/commands/pttl) + +## Arguments + +```js +pttl(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the remaining TTL, in milliseconds. + +## Usage + +<<< ./snippets/pttl.js diff --git a/doc/6/controllers/ms/pttl/snippets/pttl.js b/doc/6/controllers/ms/pttl/snippets/pttl.js new file mode 100644 index 000000000..acec88d99 --- /dev/null +++ b/doc/6/controllers/ms/pttl/snippets/pttl.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.psetex('foo', 'bar', 60000); + + // Prints: 60000 + console.log(await kuzzle.ms.pttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/pttl/snippets/pttl.test.yml b/doc/6/controllers/ms/pttl/snippets/pttl.test.yml new file mode 100644 index 000000000..f7881e2fd --- /dev/null +++ b/doc/6/controllers/ms/pttl/snippets/pttl.test.yml @@ -0,0 +1,9 @@ +name: ms#pttl +description: Returns the remaining time to live of a key, in milliseconds +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^[0-9]+$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/randomkey/index.md b/doc/6/controllers/ms/randomkey/index.md new file mode 100644 index 000000000..b3eea2ef2 --- /dev/null +++ b/doc/6/controllers/ms/randomkey/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: randomkey +--- + +# randomkey + +Returns a key identifier from the memory storage, at random. + +[[_Redis documentation_]](https://redis.io/commands/randomkey) + +## Arguments + +```js +randomkey([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a key identifier, at random. + +## Usage + +<<< ./snippets/randomkey.js diff --git a/doc/6/controllers/ms/randomkey/snippets/randomkey.js b/doc/6/controllers/ms/randomkey/snippets/randomkey.js new file mode 100644 index 000000000..4be04bc03 --- /dev/null +++ b/doc/6/controllers/ms/randomkey/snippets/randomkey.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('foo', 'val'); + await kuzzle.ms.set('bar', 'val'); + await kuzzle.ms.set('baz', 'val'); + + // Prints one of the following: foo, bar or baz + console.log(await kuzzle.ms.randomkey()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/randomkey/snippets/randomkey.test.yml b/doc/6/controllers/ms/randomkey/snippets/randomkey.test.yml new file mode 100644 index 000000000..93c2f889c --- /dev/null +++ b/doc/6/controllers/ms/randomkey/snippets/randomkey.test.yml @@ -0,0 +1,9 @@ +name: ms#randomkey +description: Returns a key identifier from the memory storage, at random +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^(foo|bar|baz)$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/rename/index.md b/doc/6/controllers/ms/rename/index.md new file mode 100644 index 000000000..abff9ad35 --- /dev/null +++ b/doc/6/controllers/ms/rename/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: rename +--- + +# rename + +Renames a key. + +If the new key name is already used, then it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/rename) + +## Arguments + +```js +rename(src, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Key to rename | +| `dest` |
string
| New key name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/rename.js diff --git a/doc/6/controllers/ms/rename/snippets/rename.js b/doc/6/controllers/ms/rename/snippets/rename.js new file mode 100644 index 000000000..d5da37409 --- /dev/null +++ b/doc/6/controllers/ms/rename/snippets/rename.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.set('foo', 'World'); + + await kuzzle.ms.rename('foo', 'Hello'); + + // Prints: World + console.log(await kuzzle.ms.get('Hello')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/rename/snippets/rename.test.yml b/doc/6/controllers/ms/rename/snippets/rename.test.yml new file mode 100644 index 000000000..e11268290 --- /dev/null +++ b/doc/6/controllers/ms/rename/snippets/rename.test.yml @@ -0,0 +1,9 @@ +name: ms#rename +description: Renames a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^World$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/renamenx/index.md b/doc/6/controllers/ms/renamenx/index.md new file mode 100644 index 000000000..48edab3a6 --- /dev/null +++ b/doc/6/controllers/ms/renamenx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: renamenx +--- + +# renamenx + +Renames a key, only if the new name is not already used. + +[[_Redis documentation_]](https://redis.io/commands/renamenx) + +## Arguments + +```js +renamenx(src, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Key to rename | +| `dest` |
string
| New key name | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation succeeded or not. + +## Usage + +<<< ./snippets/renamenx.js diff --git a/doc/6/controllers/ms/renamenx/snippets/renamenx.js b/doc/6/controllers/ms/renamenx/snippets/renamenx.js new file mode 100644 index 000000000..f0e9cf95e --- /dev/null +++ b/doc/6/controllers/ms/renamenx/snippets/renamenx.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.set('foo', 'val'); + await kuzzle.ms.set('bar', 'val'); + + // Prints: false + // (the key "bar" already exists) + console.log(await kuzzle.ms.renamenx('foo', 'bar')); + + // Prints: true + console.log(await kuzzle.ms.renamenx('foo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/renamenx/snippets/renamenx.test.yml b/doc/6/controllers/ms/renamenx/snippets/renamenx.test.yml new file mode 100644 index 000000000..737877950 --- /dev/null +++ b/doc/6/controllers/ms/renamenx/snippets/renamenx.test.yml @@ -0,0 +1,11 @@ +name: ms#renamenx +description: Renames a key, only if the new name is not already used +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^false$ + - ^true$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/rpop/index.md b/doc/6/controllers/ms/rpop/index.md new file mode 100644 index 000000000..fb8f554ad --- /dev/null +++ b/doc/6/controllers/ms/rpop/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: rpop +--- + +# rpop + +Removes the last element of a list and returns it. + +[[_Redis documentation_]](https://redis.io/commands/rpop) + +## Arguments + +```js +rpop(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the removed element. + +## Usage + +<<< ./snippets/rpop.js diff --git a/doc/6/controllers/ms/rpop/snippets/rpop.js b/doc/6/controllers/ms/rpop/snippets/rpop.js new file mode 100644 index 000000000..906b67e2c --- /dev/null +++ b/doc/6/controllers/ms/rpop/snippets/rpop.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: 'baz' + console.log(await kuzzle.ms.rpop('listfoo')); + + // Prints: [ 'foo', 'bar' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/rpop/snippets/rpop.test.yml b/doc/6/controllers/ms/rpop/snippets/rpop.test.yml new file mode 100644 index 000000000..77caeb66e --- /dev/null +++ b/doc/6/controllers/ms/rpop/snippets/rpop.test.yml @@ -0,0 +1,11 @@ +name: ms#rpop +description: Removes the last element of a list and returns it +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^baz$ + - "\\[ 'foo', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/rpoplpush/index.md b/doc/6/controllers/ms/rpoplpush/index.md new file mode 100644 index 000000000..a46882b6e --- /dev/null +++ b/doc/6/controllers/ms/rpoplpush/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: rpoplpush +--- + +# rpoplpush + +Removes the last element of a list, and pushes it back at the start of another list. + +[[_Redis documentation_]](https://redis.io/commands/rpoplpush) + +## Arguments + +```js +rpoplpush(src, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Source key | +| `dest` |
string
| Destination key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the value of the moved element. + +## Usage + +<<< ./snippets/rpoplpush.js diff --git a/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.js b/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.js new file mode 100644 index 000000000..b5ed73dca --- /dev/null +++ b/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.rpush('foo', ['rick', 'astley', 'never']); + await kuzzle.ms.rpush('bar', ['gonna', 'give', 'you', 'up']); + + // Prints: never + console.log(await kuzzle.ms.rpoplpush('foo', 'bar')); + + // Prints: [ 'never', 'gonna', 'give', 'you', 'up' ] + console.log(await kuzzle.ms.lrange('bar', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml b/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml new file mode 100644 index 000000000..b41b74666 --- /dev/null +++ b/doc/6/controllers/ms/rpoplpush/snippets/rpoplpush.test.yml @@ -0,0 +1,11 @@ +name: ms#rpoplpush +description: Removes the last element of a list, and pushes it back at the start of another list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^never$ + - "\\[ 'never', 'gonna', 'give', 'you', 'up' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/rpush/index.md b/doc/6/controllers/ms/rpush/index.md new file mode 100644 index 000000000..becc1860e --- /dev/null +++ b/doc/6/controllers/ms/rpush/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: rpush +--- + +# rpush + +Appends values at the end of a list. + +If the destination list does not exist, it is created holding an empty list before performing the operation. + +[[_Redis documentation_]](https://redis.io/commands/rpush) + +## Arguments + +```js +rpush(key, values, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| List key | +| `values` |
string[]
| List of values to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated list length. + +## Usage + +<<< ./snippets/rpush.js diff --git a/doc/6/controllers/ms/rpush/snippets/rpush.js b/doc/6/controllers/ms/rpush/snippets/rpush.js new file mode 100644 index 000000000..d6cd12b16 --- /dev/null +++ b/doc/6/controllers/ms/rpush/snippets/rpush.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.lrange('listfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/rpush/snippets/rpush.test.yml b/doc/6/controllers/ms/rpush/snippets/rpush.test.yml new file mode 100644 index 000000000..d68827600 --- /dev/null +++ b/doc/6/controllers/ms/rpush/snippets/rpush.test.yml @@ -0,0 +1,9 @@ +name: ms#rpush +description: Appends values at the end of a list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo', 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/rpushx/index.md b/doc/6/controllers/ms/rpushx/index.md new file mode 100644 index 000000000..f9604b8c1 --- /dev/null +++ b/doc/6/controllers/ms/rpushx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: rpushx +--- + +# rpushx + +Appends a value at the end of a list, only if the destination key already exists, and if it holds a list. + +[[_Redis documentation_]](https://redis.io/commands/rpushx) + +## Arguments + +```js +rpushx(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| List key | +| `value` |
string
| Value to append | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated list length. + +## Usage + +<<< ./snippets/rpushx.js diff --git a/doc/6/controllers/ms/rpushx/snippets/rpushx.js b/doc/6/controllers/ms/rpushx/snippets/rpushx.js new file mode 100644 index 000000000..00875bb69 --- /dev/null +++ b/doc/6/controllers/ms/rpushx/snippets/rpushx.js @@ -0,0 +1,12 @@ +try { + // Prints: 0 + // ("listfoo" does not exist: the operation fails) + console.log(await kuzzle.ms.rpushx('listfoo', 'qux')); + + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + + // Prints: 4 + console.log(await kuzzle.ms.rpushx('listfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/rpushx/snippets/rpushx.test.yml b/doc/6/controllers/ms/rpushx/snippets/rpushx.test.yml new file mode 100644 index 000000000..af30e7bb7 --- /dev/null +++ b/doc/6/controllers/ms/rpushx/snippets/rpushx.test.yml @@ -0,0 +1,11 @@ +name: ms#rpushx +description: Appends a value at the end of an existing list +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^4$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sadd/index.md b/doc/6/controllers/ms/sadd/index.md new file mode 100644 index 000000000..cf3f528d0 --- /dev/null +++ b/doc/6/controllers/ms/sadd/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: sadd +--- + +# sadd + +Adds members to a set of unique values stored at `key`. + +If the destination set does not exist, it is created beforehand. + +[[_Redis documentation_]](https://redis.io/commands/sadd) + +## Arguments + +```js +sadd(key, values, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Set key | +| `values` |
string[]
| Values to add | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of successfully added members. + +## Usage + +<<< ./snippets/sadd.js diff --git a/doc/6/controllers/ms/sadd/snippets/sadd.js b/doc/6/controllers/ms/sadd/snippets/sadd.js new file mode 100644 index 000000000..0af225de5 --- /dev/null +++ b/doc/6/controllers/ms/sadd/snippets/sadd.js @@ -0,0 +1,12 @@ +try { + // Prints: 2 + console.log(await kuzzle.ms.sadd('setfoo', ['foo', 'bar'])); + + // Prints: 1 + console.log(await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz'])); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.smembers('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sadd/snippets/sadd.test.yml b/doc/6/controllers/ms/sadd/snippets/sadd.test.yml new file mode 100644 index 000000000..a66e0e5d4 --- /dev/null +++ b/doc/6/controllers/ms/sadd/snippets/sadd.test.yml @@ -0,0 +1,12 @@ +name: ms#sadd +description: Adds members to a set of unique values stored at key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - ^1$ + - "\\[ '(foo|bar|baz)', '(foo|bar|baz)', '(foo|bar|baz)' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/scan/index.md b/doc/6/controllers/ms/scan/index.md new file mode 100644 index 000000000..9ba928872 --- /dev/null +++ b/doc/6/controllers/ms/scan/index.md @@ -0,0 +1,52 @@ +--- +code: true +type: page +title: scan +--- + +# scan + +Iterates incrementally over the set of keys in the database using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/scan) + +## Arguments + +```js +scan(cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | ----------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of keys | + +## Usage + +<<< ./snippets/scan.js diff --git a/doc/6/controllers/ms/scan/snippets/scan.js b/doc/6/controllers/ms/scan/snippets/scan.js new file mode 100644 index 000000000..1eb7f8c56 --- /dev/null +++ b/doc/6/controllers/ms/scan/snippets/scan.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.set('key1', 'val1'); + await kuzzle.ms.set('key2', 'val2'); + await kuzzle.ms.set('key3', 'val3'); + + // Prints: + // { + // cursor: '0', + // values: [ 'key1', 'key2', 'key3' ] + // } + console.log(await kuzzle.ms.scan(0)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/scan/snippets/scan.test.yml b/doc/6/controllers/ms/scan/snippets/scan.test.yml new file mode 100644 index 000000000..94f14acf7 --- /dev/null +++ b/doc/6/controllers/ms/scan/snippets/scan.test.yml @@ -0,0 +1,11 @@ +name: ms#scan +description: Iterates incrementally over the set of keys in the database using a cursor +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0', values: \\[ 'key[123]', 'key[123]', 'key[123]' ] }" + +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/scard/index.md b/doc/6/controllers/ms/scard/index.md new file mode 100644 index 000000000..f7b7aca95 --- /dev/null +++ b/doc/6/controllers/ms/scard/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: scard +--- + +# scard + +Returns the number of members stored in a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/scard) + +## Arguments + +```js +scard(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the set length. + +## Usage + +<<< ./snippets/scard.js diff --git a/doc/6/controllers/ms/scard/snippets/scard.js b/doc/6/controllers/ms/scard/snippets/scard.js new file mode 100644 index 000000000..66850ad3e --- /dev/null +++ b/doc/6/controllers/ms/scard/snippets/scard.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'foo', 'bar', 'baz']); + + // Prints: 3 + console.log(await kuzzle.ms.scard('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/scard/snippets/scard.test.yml b/doc/6/controllers/ms/scard/snippets/scard.test.yml new file mode 100644 index 000000000..233e97519 --- /dev/null +++ b/doc/6/controllers/ms/scard/snippets/scard.test.yml @@ -0,0 +1,9 @@ +name: ms#scard +description: Returns the number of members stored in a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sdiff/index.md b/doc/6/controllers/ms/sdiff/index.md new file mode 100644 index 000000000..06f361efe --- /dev/null +++ b/doc/6/controllers/ms/sdiff/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: sdiff +--- + +# sdiff + +Returns the difference between a reference set and a list of other sets. + +[[_Redis documentation_]](https://redis.io/commands/sdiff) + +## Arguments + +```js +sdiff(ref, sets, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ---------------------------------------- | +| `ref` |
string
| Set key of reference | +| `sets` |
string[]
| List of sets to compare to the reference | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of differences. + +## Usage + +<<< ./snippets/sdiff.js diff --git a/doc/6/controllers/ms/sdiff/snippets/sdiff.js b/doc/6/controllers/ms/sdiff/snippets/sdiff.js new file mode 100644 index 000000000..81554c2b2 --- /dev/null +++ b/doc/6/controllers/ms/sdiff/snippets/sdiff.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.sadd('ref', ['foo', 'bar', 'baz']); + + await kuzzle.ms.sadd('set1', ['foo', 'hello']); + await kuzzle.ms.sadd('set2', ['bar', 'world']); + + // Prints: [ 'baz' ] + console.log(await kuzzle.ms.sdiff('ref', ['set1', 'set2'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sdiff/snippets/sdiff.test.yml b/doc/6/controllers/ms/sdiff/snippets/sdiff.test.yml new file mode 100644 index 000000000..f828fae8b --- /dev/null +++ b/doc/6/controllers/ms/sdiff/snippets/sdiff.test.yml @@ -0,0 +1,9 @@ +name: ms#sdiff +description: Returns the difference between a reference set and a list of other sets +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sdiffstore/index.md b/doc/6/controllers/ms/sdiffstore/index.md new file mode 100644 index 000000000..5fb7807b3 --- /dev/null +++ b/doc/6/controllers/ms/sdiffstore/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: sdiffstore +--- + +# sdiffstore + +Computes the difference between a reference set of unique values, and other sets. The differences are then stored in the provided destination key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sdiffstore) + +## Arguments + +```js +sdiffstore(ref, sets, dest, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ---------------------------------------- | +| `ref` |
string
| Set key of reference | +| `sets` |
string[]
| List of sets to compare to the reference | +| `dest` |
string
| Destination key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of values stored at the new key. + +## Usage + +<<< ./snippets/sdiffstore.js diff --git a/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.js b/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.js new file mode 100644 index 000000000..cffbb2826 --- /dev/null +++ b/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.sadd('ref', ['foo', 'bar', 'baz']); + + await kuzzle.ms.sadd('set1', ['foo', 'hello']); + await kuzzle.ms.sadd('set2', ['bar', 'world']); + + await kuzzle.ms.sdiffstore('ref', ['set1', 'set2'], 'diffs'); + + // Prints: [ 'baz' ] + console.log(await kuzzle.ms.smembers('diffs')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml b/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml new file mode 100644 index 000000000..fdbc89b7f --- /dev/null +++ b/doc/6/controllers/ms/sdiffstore/snippets/sdiffstore.test.yml @@ -0,0 +1,9 @@ +name: ms#sdiffstore +description: Stores the difference between a reference set and a list of other sets in a new key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/set/index.md b/doc/6/controllers/ms/set/index.md new file mode 100644 index 000000000..35300d86b --- /dev/null +++ b/doc/6/controllers/ms/set/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: set +--- + +# set + +Creates a key holding the provided value, or overwrites it if it already exists. + +[[_Redis documentation_]](https://redis.io/commands/set) + +## Arguments + +```js +set(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
\*
| Value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | -------------------------- | ---------------------------------------------------------------------------- | +| `ex` |
integer
| Adds an expiration delay to the key, in seconds | +| `nx` |
boolean (false)
| If true, do not set the key if it already exists | +| `px` |
integer
| Adds an expiration delay to the key, in milliseconds | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `xx` |
boolean (false)
| If true, sets the key only if it already exists | + +Note: the `ex` and `px` options are mutually exclusive; setting both options ends up in a `BadRequestError` error. Same thing goes for `nx` and `xx`. + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/set.js diff --git a/doc/6/controllers/ms/set/snippets/set.js b/doc/6/controllers/ms/set/snippets/set.js new file mode 100644 index 000000000..3f26ee695 --- /dev/null +++ b/doc/6/controllers/ms/set/snippets/set.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/set/snippets/set.test.yml b/doc/6/controllers/ms/set/snippets/set.test.yml new file mode 100644 index 000000000..48ccb56e6 --- /dev/null +++ b/doc/6/controllers/ms/set/snippets/set.test.yml @@ -0,0 +1,9 @@ +name: ms#set +description: Creates a key holding the provided value, or overwrites it if it already exists +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/setex/index.md b/doc/6/controllers/ms/setex/index.md new file mode 100644 index 000000000..239c83543 --- /dev/null +++ b/doc/6/controllers/ms/setex/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: setex +--- + +# setex + +Sets a value and a time to live (in seconds) on a key. If the key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/setex) + +## Arguments + +```js +setex(key, value, seconds, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------------------------------ | +| `key` |
string
| Key | +| `value` |
string
| Value | +| `seconds` |
integer
| Number of seconds after which the key is deleted | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves once the operation succeeds. + +## Usage + +<<< ./snippets/setex.js diff --git a/doc/6/controllers/ms/setex/snippets/setex.js b/doc/6/controllers/ms/setex/snippets/setex.js new file mode 100644 index 000000000..a51b2eedc --- /dev/null +++ b/doc/6/controllers/ms/setex/snippets/setex.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.setex('foo', 'bar', 60); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/setex/snippets/setex.test.yml b/doc/6/controllers/ms/setex/snippets/setex.test.yml new file mode 100644 index 000000000..2e27369b8 --- /dev/null +++ b/doc/6/controllers/ms/setex/snippets/setex.test.yml @@ -0,0 +1,11 @@ +name: ms#setex +description: Sets a value and a time to live (in seconds) on a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^[0-9]{1,2}$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/setnx/index.md b/doc/6/controllers/ms/setnx/index.md new file mode 100644 index 000000000..d1babbb69 --- /dev/null +++ b/doc/6/controllers/ms/setnx/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: setnx +--- + +# setnx + +Sets a value on a key, only if it does not already exist. + +[[_Redis documentation_]](https://redis.io/commands/setnx) + +## Arguments + +```js +setnx(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `value` |
string
| Value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling if the operation succeeded or not. + +## Usage + +<<< ./snippets/setnx.js diff --git a/doc/6/controllers/ms/setnx/snippets/setnx.js b/doc/6/controllers/ms/setnx/snippets/setnx.js new file mode 100644 index 000000000..62128914b --- /dev/null +++ b/doc/6/controllers/ms/setnx/snippets/setnx.js @@ -0,0 +1,12 @@ +try { + // Prints: true + console.log(await kuzzle.ms.setnx('foo', 'bar')); + + // Prints: false + console.log(await kuzzle.ms.setnx('foo', 'qux')); + + // Prints: bar + console.log(await kuzzle.ms.get('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/setnx/snippets/setnx.test.yml b/doc/6/controllers/ms/setnx/snippets/setnx.test.yml new file mode 100644 index 000000000..7611aab3b --- /dev/null +++ b/doc/6/controllers/ms/setnx/snippets/setnx.test.yml @@ -0,0 +1,12 @@ +name: ms#setnx +description: Sets a value on a key, only if it does not already exist +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^true$ + - ^false$ + - ^bar$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sinter/index.md b/doc/6/controllers/ms/sinter/index.md new file mode 100644 index 000000000..5c439a2f1 --- /dev/null +++ b/doc/6/controllers/ms/sinter/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: sinter +--- + +# sinter + +Returns the intersection of the provided sets of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sinter) + +## Arguments + +```js +sinter(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ----------------------------- | +| `keys` |
string[]
| List of set keys to intersect | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of intersected values. + +## Usage + +<<< ./snippets/sinter.js diff --git a/doc/6/controllers/ms/sinter/snippets/sinter.js b/doc/6/controllers/ms/sinter/snippets/sinter.js new file mode 100644 index 000000000..a6e4edaa2 --- /dev/null +++ b/doc/6/controllers/ms/sinter/snippets/sinter.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.sadd('set1', ['foo', 'bar', 'hello']); + await kuzzle.ms.sadd('set2', ['world', 'baz', 'foo']); + + // Prints: [ 'foo' ] + console.log(await kuzzle.ms.sinter(['set1', 'set2'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sinter/snippets/sinter.test.yml b/doc/6/controllers/ms/sinter/snippets/sinter.test.yml new file mode 100644 index 000000000..f1cda41f4 --- /dev/null +++ b/doc/6/controllers/ms/sinter/snippets/sinter.test.yml @@ -0,0 +1,9 @@ +name: ms#sinter +description: Returns the intersection of the provided sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'foo' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sinterstore/index.md b/doc/6/controllers/ms/sinterstore/index.md new file mode 100644 index 000000000..1299b6d77 --- /dev/null +++ b/doc/6/controllers/ms/sinterstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: sinterstore +--- + +# sinterstore + +Computes the intersection of the provided sets of unique values, and stores the result in a destination key. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sinterstore) + +## Arguments + +```js +sinterstore(dest, keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ----------------------------- | +| `dest` |
string
| Destination key | +| `keys` |
string[]
| List of set keys to intersect | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of stored values. + +## Usage + +<<< ./snippets/sinterstore.js diff --git a/doc/6/controllers/ms/sinterstore/snippets/sinterstore.js b/doc/6/controllers/ms/sinterstore/snippets/sinterstore.js new file mode 100644 index 000000000..ddd7da447 --- /dev/null +++ b/doc/6/controllers/ms/sinterstore/snippets/sinterstore.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.sadd('set1', ['foo', 'bar', 'hello']); + await kuzzle.ms.sadd('set2', ['world', 'baz', 'foo']); + + // Prints: 1 + console.log(await kuzzle.ms.sinterstore('dest', ['set1', 'set2'])); + + // Prints: [ 'foo' ] + console.log(await kuzzle.ms.smembers('dest')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sinterstore/snippets/sinterstore.test.yml b/doc/6/controllers/ms/sinterstore/snippets/sinterstore.test.yml new file mode 100644 index 000000000..6563fb0ab --- /dev/null +++ b/doc/6/controllers/ms/sinterstore/snippets/sinterstore.test.yml @@ -0,0 +1,11 @@ +name: ms#sinterstore +description: Stores the intersection of the provided sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^1$ + - "\\[ 'foo' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sismember/index.md b/doc/6/controllers/ms/sismember/index.md new file mode 100644 index 000000000..dee827912 --- /dev/null +++ b/doc/6/controllers/ms/sismember/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: sismember +--- + +# sismember + +Checks if a value is a member of a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sismember) + +## Arguments + +```js +sismember(key, value, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `value` |
string
| Value to check | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling if the value is in the set or not. + +## Usage + +<<< ./snippets/sismember.js diff --git a/doc/6/controllers/ms/sismember/snippets/sismember.js b/doc/6/controllers/ms/sismember/snippets/sismember.js new file mode 100644 index 000000000..4ff009cc3 --- /dev/null +++ b/doc/6/controllers/ms/sismember/snippets/sismember.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: true + console.log(await kuzzle.ms.sismember('setfoo', 'bar')); + + // Prints: false + console.log(await kuzzle.ms.sismember('setfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sismember/snippets/sismember.test.yml b/doc/6/controllers/ms/sismember/snippets/sismember.test.yml new file mode 100644 index 000000000..944f3a6cc --- /dev/null +++ b/doc/6/controllers/ms/sismember/snippets/sismember.test.yml @@ -0,0 +1,11 @@ +name: ms#sismember +description: Checks if a value is a member of a set of unique values. +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^true$ + - ^false$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/smembers/index.md b/doc/6/controllers/ms/smembers/index.md new file mode 100644 index 000000000..d1273c0d0 --- /dev/null +++ b/doc/6/controllers/ms/smembers/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: smembers +--- + +# smembers + +Returns the members of a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/smembers) + +## Arguments + +```js +smembers(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of the set's members. + +## Usage + +<<< ./snippets/smembers.js diff --git a/doc/6/controllers/ms/smembers/snippets/smembers.js b/doc/6/controllers/ms/smembers/snippets/smembers.js new file mode 100644 index 000000000..1f94a3f2d --- /dev/null +++ b/doc/6/controllers/ms/smembers/snippets/smembers.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.sadd('listfoo', ['foo', 'bar', 'baz']); + + // Prints: [ 'foo', 'bar', 'baz' ] + console.log(await kuzzle.ms.smembers('listfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/smembers/snippets/smembers.test.yml b/doc/6/controllers/ms/smembers/snippets/smembers.test.yml new file mode 100644 index 000000000..5c4cae961 --- /dev/null +++ b/doc/6/controllers/ms/smembers/snippets/smembers.test.yml @@ -0,0 +1,9 @@ +name: ms#smembers +description: Returns the members of a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ '(foo|bar|baz)', '(foo|bar|baz)', '(foo|bar|baz)' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/smove/index.md b/doc/6/controllers/ms/smove/index.md new file mode 100644 index 000000000..942d77bd6 --- /dev/null +++ b/doc/6/controllers/ms/smove/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: smove +--- + +# smove + +Moves a member from a set of unique values to another. + +[[_Redis documentation_]](https://redis.io/commands/smove) + +## Arguments + +```js +smove(src, dest, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `src` |
string
| Source set key | +| `dest` |
string
| Destination set key | +| `member` |
string
| Member to move | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a boolean telling whether the operation succeeded or not. + +## Usage + +<<< ./snippets/smove.js diff --git a/doc/6/controllers/ms/smove/snippets/smove.js b/doc/6/controllers/ms/smove/snippets/smove.js new file mode 100644 index 000000000..06ddc9be0 --- /dev/null +++ b/doc/6/controllers/ms/smove/snippets/smove.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.sadd('set1', ['foo', 'bar', 'baz']); + await kuzzle.ms.sadd('set2', ['qux']); + + await kuzzle.ms.smove('set1', 'set2', 'foo'); + + // Prints: [ 'bar', 'baz' ] + console.log(await kuzzle.ms.smembers('set1')); + + // Prints: [ 'foo', 'qux' ] + console.log(await kuzzle.ms.smembers('set2')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/smove/snippets/smove.test.yml b/doc/6/controllers/ms/smove/snippets/smove.test.yml new file mode 100644 index 000000000..abbf09ca1 --- /dev/null +++ b/doc/6/controllers/ms/smove/snippets/smove.test.yml @@ -0,0 +1,11 @@ +name: ms#smove +description: Moves a member from a set of unique values to another +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ '(bar|baz)', '(bar|baz)' ]" + - "\\[ '(foo|qux)', '(foo|qux)' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sort/index.md b/doc/6/controllers/ms/sort/index.md new file mode 100644 index 000000000..e3641baa8 --- /dev/null +++ b/doc/6/controllers/ms/sort/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: sort +--- + +# sort + +Sorts and returns elements contained in a list, a set of unique values or a sorted set. +By default, sorting is numeric and elements are compared by their value, interpreted as double precision floating point number. + +[[_Redis documentation_]](https://redis.io/commands/sort) + +## Arguments + +```js +sort(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | --------------------------- | +| `key` |
string
| List, set or sorted set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `alpha` |
boolean (false)
| Performs an alphanumerical sort instead of a numeric one | +| `by` |
string
| Instead of sorting by values, sorts by values contained in external keys, using the provided pattern completed by values of the list/set/sorted set to sort | +| `direction` |
string ('ASC')
| Sorts in ascendant or descendant order.
Allowed values: `ASC`, `DESC` | +| `get` |
string[]
| Instead of returning the sorted values directly, returns the values contained in external keys, using patterns completed by the sorted values | +| `limit` |
integer[]
| Limits the result set to a range of matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[, ]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the sorted elements. + +## Usage + +<<< ./snippets/sort.js diff --git a/doc/6/controllers/ms/sort/snippets/sort.js b/doc/6/controllers/ms/sort/snippets/sort.js new file mode 100644 index 000000000..7228c23eb --- /dev/null +++ b/doc/6/controllers/ms/sort/snippets/sort.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.sadd('setfoo', [1, 2, 3, 4, 5, 6, 7]); + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz', 'qux']); + + // Prints: [ '7', '6', '5', '4', '3', '2', '1' ] + console.log(await kuzzle.ms.sort('setfoo', {direction: 'DESC'})); + + // Prints: [ 'bar', 'baz', 'foo', 'qux' ] + console.log(await kuzzle.ms.sort('listfoo', {alpha: true})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sort/snippets/sort.test.yml b/doc/6/controllers/ms/sort/snippets/sort.test.yml new file mode 100644 index 000000000..10a6a0b7e --- /dev/null +++ b/doc/6/controllers/ms/sort/snippets/sort.test.yml @@ -0,0 +1,11 @@ +name: ms#sort +description: Sorts and returns elements contained in a list, a set or a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ '7', '6', '5', '4', '3', '2', '1' ]" + - "\\[ 'bar', 'baz', 'foo', 'qux' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/spop/index.md b/doc/6/controllers/ms/spop/index.md new file mode 100644 index 000000000..d54920635 --- /dev/null +++ b/doc/6/controllers/ms/spop/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: spop +--- + +# spop + +Removes and returns one or more elements at random from a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/spop) + +## Arguments + +```js +spop(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (1)
| The number of elements to pop | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of removed elements. + +## Usage + +<<< ./snippets/spop.js diff --git a/doc/6/controllers/ms/spop/snippets/spop.js b/doc/6/controllers/ms/spop/snippets/spop.js new file mode 100644 index 000000000..0b9c8886a --- /dev/null +++ b/doc/6/controllers/ms/spop/snippets/spop.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.sadd('setfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + // Prints one of the elements of setfoo, at random + console.log(await kuzzle.ms.spop('setfoo')); + + // Prints three of the remaining elements of setfoo, at random + console.log(await kuzzle.ms.spop('setfoo', {count: 3})); + + // Prints: 2 + console.log(await kuzzle.ms.scard('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/spop/snippets/spop.test.yml b/doc/6/controllers/ms/spop/snippets/spop.test.yml new file mode 100644 index 000000000..6fdcdadec --- /dev/null +++ b/doc/6/controllers/ms/spop/snippets/spop.test.yml @@ -0,0 +1,12 @@ +name: ms#spop +description: Removes one or more elements at random from a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "^\\[ '[a-f]' ]" + - "^\\[ '[a-f]', '[a-f]', '[a-f]' ]" + - ^2$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/srandmember/index.md b/doc/6/controllers/ms/srandmember/index.md new file mode 100644 index 000000000..c668e4894 --- /dev/null +++ b/doc/6/controllers/ms/srandmember/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: srandmember +--- + +# srandmember + +Returns one or more members of a set of unique values, at random. + +[[_Redis documentation_]](https://redis.io/commands/srandmember) + +## Arguments + +```js +srandmember(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | -------- | ------------------------ | +| `key` | `string` | Set key | +| `options` | `object` | Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `count` | `integer (1)` | If positive, returns `count` elements at random from the set, without repetition.
If negative, returns `abs(count)` elements, and the same element can be chosen multiple times | +| `queuable` | `boolean (true)` | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +## Usage + +<<< ./snippets/srandmember.js diff --git a/doc/6/controllers/ms/srandmember/snippets/srandmember.js b/doc/6/controllers/ms/srandmember/snippets/srandmember.js new file mode 100644 index 000000000..f3a62c5bf --- /dev/null +++ b/doc/6/controllers/ms/srandmember/snippets/srandmember.js @@ -0,0 +1,12 @@ +try { + + await kuzzle.ms.sadd('setfoo', ['a', 'b', 'c', 'd', 'e', 'f']); + + // Prints one of the elements of setfoo, at random + console.log(await kuzzle.ms.srandmember('setfoo')); + + // Prints three elements of setfoo, at random + console.log(await kuzzle.ms.srandmember('setfoo', {count: 3})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/srandmember/snippets/srandmember.test.yml b/doc/6/controllers/ms/srandmember/snippets/srandmember.test.yml new file mode 100644 index 000000000..ff393adee --- /dev/null +++ b/doc/6/controllers/ms/srandmember/snippets/srandmember.test.yml @@ -0,0 +1,11 @@ +name: ms#srandmember +description: Returns one or more members of a set of unique values, at random +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "^\\[ '[a-f]' ]" + - "^\\[ '[a-f]', '[a-f]', '[a-f]' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/srem/index.md b/doc/6/controllers/ms/srem/index.md new file mode 100644 index 000000000..d88c22c69 --- /dev/null +++ b/doc/6/controllers/ms/srem/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: srem +--- + +# srem + +Removes members from a set of unique values. + +[[_Redis documentation_]](https://redis.io/commands/srem) + +## Arguments + +```js +srem(key, members, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------- | +| `key` |
string
| Set key | +| `members` |
string[]
| List of members to remove | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed members. + +## Usage + +<<< ./snippets/srem.js diff --git a/doc/6/controllers/ms/srem/snippets/srem.js b/doc/6/controllers/ms/srem/snippets/srem.js new file mode 100644 index 000000000..2d984c745 --- /dev/null +++ b/doc/6/controllers/ms/srem/snippets/srem.js @@ -0,0 +1,11 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: 2 + console.log(await kuzzle.ms.srem('setfoo', ['bar', 'baz'])); + + // Prints: ['foo'] + console.log(await kuzzle.ms.smembers('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/srem/snippets/srem.test.yml b/doc/6/controllers/ms/srem/snippets/srem.test.yml new file mode 100644 index 000000000..788fb56b0 --- /dev/null +++ b/doc/6/controllers/ms/srem/snippets/srem.test.yml @@ -0,0 +1,11 @@ +name: ms#srem +description: Removes members from a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - "\\[ 'foo' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sscan/index.md b/doc/6/controllers/ms/sscan/index.md new file mode 100644 index 000000000..a862588a9 --- /dev/null +++ b/doc/6/controllers/ms/sscan/index.md @@ -0,0 +1,53 @@ +--- +code: true +type: page +title: sscan +--- + +# sscan + +Iterates incrementally over members contained in a set of unique values, using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/sscan) + +## Arguments + +```js +sscan(key, cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Set key | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | ----------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of found members | + +## Usage + +<<< ./snippets/sscan.js diff --git a/doc/6/controllers/ms/sscan/snippets/sscan.js b/doc/6/controllers/ms/sscan/snippets/sscan.js new file mode 100644 index 000000000..05121a1f9 --- /dev/null +++ b/doc/6/controllers/ms/sscan/snippets/sscan.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: + // { + // cursor: '0', + // values: [ bar', 'baz' ] + // } + console.log(await kuzzle.ms.sscan('setfoo', 0, {match: 'ba*'})); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sscan/snippets/sscan.test.yml b/doc/6/controllers/ms/sscan/snippets/sscan.test.yml new file mode 100644 index 000000000..30984934a --- /dev/null +++ b/doc/6/controllers/ms/sscan/snippets/sscan.test.yml @@ -0,0 +1,11 @@ +name: ms#sscan +description: Iterates incrementally over members contained in a set of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0', values: \\[ 'ba[rz]', 'ba[rz]' ] }" + +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/strlen/index.md b/doc/6/controllers/ms/strlen/index.md new file mode 100644 index 000000000..f08e8a8aa --- /dev/null +++ b/doc/6/controllers/ms/strlen/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: strlen +--- + +# strlen + +Returns the length of a value. + +[[_Redis documentation_]](https://redis.io/commands/strlen) + +## Arguments + +```js +strlen(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the value's length. + +## Usage + +<<< ./snippets/strlen.js diff --git a/doc/6/controllers/ms/strlen/snippets/strlen.js b/doc/6/controllers/ms/strlen/snippets/strlen.js new file mode 100644 index 000000000..1fd6d1890 --- /dev/null +++ b/doc/6/controllers/ms/strlen/snippets/strlen.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'abcdef'); + + // Prints: 6 + console.log(await kuzzle.ms.strlen('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/strlen/snippets/strlen.test.yml b/doc/6/controllers/ms/strlen/snippets/strlen.test.yml new file mode 100644 index 000000000..de4defc7b --- /dev/null +++ b/doc/6/controllers/ms/strlen/snippets/strlen.test.yml @@ -0,0 +1,9 @@ +name: ms#strlen +description: Returns the length of a value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^6$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sunion/index.md b/doc/6/controllers/ms/sunion/index.md new file mode 100644 index 000000000..d7e68457f --- /dev/null +++ b/doc/6/controllers/ms/sunion/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: sunion +--- + +# sunion + +Returns the union of sets of unique values. + +[[_Redis documentation_]](https://redis.io/commands/sunion) + +## Arguments + +```js +sunion(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of set keys | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the result of the union between the provided sets. + +## Usage + +<<< ./snippets/sunion.js diff --git a/doc/6/controllers/ms/sunion/snippets/sunion.js b/doc/6/controllers/ms/sunion/snippets/sunion.js new file mode 100644 index 000000000..3e414c706 --- /dev/null +++ b/doc/6/controllers/ms/sunion/snippets/sunion.js @@ -0,0 +1,10 @@ +try { + await kuzzle.ms.sadd('set1', ['a', 'b', 'c']); + await kuzzle.ms.sadd('set2', ['d', 'e', 'f']); + await kuzzle.ms.sadd('set3', ['g', 'h', 'i']); + + // Prints: [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' ] + console.log(await kuzzle.ms.sunion(['set1', 'set2', 'set3'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sunion/snippets/sunion.test.yml b/doc/6/controllers/ms/sunion/snippets/sunion.test.yml new file mode 100644 index 000000000..14b73c511 --- /dev/null +++ b/doc/6/controllers/ms/sunion/snippets/sunion.test.yml @@ -0,0 +1,9 @@ +name: ms#sunion +description: Returns the union of sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ ('[a-i]', ){8}'[a-i]' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/sunionstore/index.md b/doc/6/controllers/ms/sunionstore/index.md new file mode 100644 index 000000000..7557d9759 --- /dev/null +++ b/doc/6/controllers/ms/sunionstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: sunionstore +--- + +# sunionstore + +Computes the union of multiple sets of unique values and stores it in a new set. + +If the destination key already exists, it is overwritten. + +[[_Redis documentation_]](https://redis.io/commands/sunionstore) + +## Arguments + +```js +sunionstore(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Union target key | +| `sources` |
string[]
| List of set keys | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of values added to the destination key. + +## Usage + +<<< ./snippets/sunionstore.js diff --git a/doc/6/controllers/ms/sunionstore/snippets/sunionstore.js b/doc/6/controllers/ms/sunionstore/snippets/sunionstore.js new file mode 100644 index 000000000..59f60e382 --- /dev/null +++ b/doc/6/controllers/ms/sunionstore/snippets/sunionstore.js @@ -0,0 +1,16 @@ +try { + await kuzzle.ms.sadd('set1', ['a', 'b', 'c']); + await kuzzle.ms.sadd('set2', ['d', 'e', 'f']); + await kuzzle.ms.sadd('set3', ['g', 'h', 'i']); + + // Prints: 9 + console.log(await kuzzle.ms.sunionstore( + 'setdest', + ['set1', 'set2', 'set3'] + )); + + // Prints: [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' ] + console.log(await kuzzle.ms.smembers('setdest')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/sunionstore/snippets/sunionstore.test.yml b/doc/6/controllers/ms/sunionstore/snippets/sunionstore.test.yml new file mode 100644 index 000000000..9f42d0202 --- /dev/null +++ b/doc/6/controllers/ms/sunionstore/snippets/sunionstore.test.yml @@ -0,0 +1,11 @@ +name: ms#sunionstore +description: Stores the union of multiple sets of unique values +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^9$ + - "\\[ ('[a-i]', ){8}'[a-i]' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/time/index.md b/doc/6/controllers/ms/time/index.md new file mode 100644 index 000000000..e3ec5552d --- /dev/null +++ b/doc/6/controllers/ms/time/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: time +--- + +# time + +Returns the current server time. + +[[_Redis documentation_]](https://redis.io/commands/time) + +## Arguments + +```js +time([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the time as a two items array: + +- a timestamp in [Epoch time](https://en.wikipedia.org/wiki/Unix_time) +- the number of microseconds already elapsed in the current second + +## Usage + +<<< ./snippets/time.js diff --git a/doc/6/controllers/ms/time/snippets/time.js b/doc/6/controllers/ms/time/snippets/time.js new file mode 100644 index 000000000..9c8fe916f --- /dev/null +++ b/doc/6/controllers/ms/time/snippets/time.js @@ -0,0 +1,8 @@ +try { + // Prints: [ 1542890183, 868983 ] + // ...but only if the current time on your server is: + // [GMT] Nov. 22, 2018 12:36:23 PM + console.log(await kuzzle.ms.time()); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/time/snippets/time.test.yml b/doc/6/controllers/ms/time/snippets/time.test.yml new file mode 100644 index 000000000..3f1a9b33b --- /dev/null +++ b/doc/6/controllers/ms/time/snippets/time.test.yml @@ -0,0 +1,10 @@ +name: ms#time +description: Returns the current server time +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ \\d{10}, \\d+ ]$" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/touch/index.md b/doc/6/controllers/ms/touch/index.md new file mode 100644 index 000000000..da004fb23 --- /dev/null +++ b/doc/6/controllers/ms/touch/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: touch +--- + +# touch + +Alters the last access time of the provided keys. A key is ignored if it does not exist. + +[[_Redis documentation_]](https://redis.io/commands/touch) + +## Arguments + +```js +touch(keys, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `keys` |
string[]
| List of keys to alter | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of altered keys. + +## Usage + +<<< ./snippets/touch.js diff --git a/doc/6/controllers/ms/touch/snippets/touch.js b/doc/6/controllers/ms/touch/snippets/touch.js new file mode 100644 index 000000000..a834a7c45 --- /dev/null +++ b/doc/6/controllers/ms/touch/snippets/touch.js @@ -0,0 +1,9 @@ +try { + await kuzzle.ms.set('foo', 'bar'); + await kuzzle.ms.set('baz', 'qux'); + + // Prints: 2 + console.log(await kuzzle.ms.touch(['foo', 'baz', 'thedroidsIamlookingfor'])); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/touch/snippets/touch.test.yml b/doc/6/controllers/ms/touch/snippets/touch.test.yml new file mode 100644 index 000000000..8da644f65 --- /dev/null +++ b/doc/6/controllers/ms/touch/snippets/touch.test.yml @@ -0,0 +1,9 @@ +name: ms#touch +description: Alters the last access time of the provided keys +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^2$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/ttl/index.md b/doc/6/controllers/ms/ttl/index.md new file mode 100644 index 000000000..d9340adeb --- /dev/null +++ b/doc/6/controllers/ms/ttl/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: ttl +--- + +# ttl + +Returns the remaining time to live of a key, in seconds. + +[[_Redis documentation_]](https://redis.io/commands/ttl) + +## Arguments + +```js +ttl(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the remaining key TTL, in seconds, or to a negative value if the key does not exist or if it is persistent. + +## Usage + +<<< ./snippets/ttl.js diff --git a/doc/6/controllers/ms/ttl/snippets/ttl.js b/doc/6/controllers/ms/ttl/snippets/ttl.js new file mode 100644 index 000000000..d5253719e --- /dev/null +++ b/doc/6/controllers/ms/ttl/snippets/ttl.js @@ -0,0 +1,8 @@ +try { + await kuzzle.ms.set('foo', 'bar', {ex: 60}); + + // Prints: 60 + console.log(await kuzzle.ms.ttl('foo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/ttl/snippets/ttl.test.yml b/doc/6/controllers/ms/ttl/snippets/ttl.test.yml new file mode 100644 index 000000000..0b6ac875b --- /dev/null +++ b/doc/6/controllers/ms/ttl/snippets/ttl.test.yml @@ -0,0 +1,9 @@ +name: ms#ttl +description: Returns the remaining time to live of a key, in seconds +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^\d{1,2}$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/type/index.md b/doc/6/controllers/ms/type/index.md new file mode 100644 index 000000000..c055f6eac --- /dev/null +++ b/doc/6/controllers/ms/type/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: type +--- + +# type + +Returns the type of the value held by a key. + +[[_Redis documentation_]](https://redis.io/commands/type) + +## Arguments + +```js +type(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to one of the following: `hash`, `list`, `string`, `set`, `zset` + +## Usage + +<<< ./snippets/type.js diff --git a/doc/6/controllers/ms/type/snippets/type.js b/doc/6/controllers/ms/type/snippets/type.js new file mode 100644 index 000000000..a19c9f25f --- /dev/null +++ b/doc/6/controllers/ms/type/snippets/type.js @@ -0,0 +1,16 @@ +try { + await kuzzle.ms.set('foo', 123); + await kuzzle.ms.rpush('listfoo', ['foo', 'bar', 'baz']); + await kuzzle.ms.sadd('setfoo', ['foo', 'bar', 'baz']); + + // Prints: string + console.log(await kuzzle.ms.type('foo')); + + // Prints: list + console.log(await kuzzle.ms.type('listfoo')); + + // Prints: set + console.log(await kuzzle.ms.type('setfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/type/snippets/type.test.yml b/doc/6/controllers/ms/type/snippets/type.test.yml new file mode 100644 index 000000000..cb36f7b49 --- /dev/null +++ b/doc/6/controllers/ms/type/snippets/type.test.yml @@ -0,0 +1,12 @@ +name: ms#type +description: Returns the type of the value held by a key +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^string$ + - ^list$ + - ^set$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zadd/index.md b/doc/6/controllers/ms/zadd/index.md new file mode 100644 index 000000000..58bad292e --- /dev/null +++ b/doc/6/controllers/ms/zadd/index.md @@ -0,0 +1,60 @@ +--- +code: true +type: page +title: zadd +--- + +# zadd + +Adds elements to a sorted set. + +If the key does not exist, it is created, holding an empty sorted set. + +If the key already exists but does not hold a sorted set, an error is returned. + +If a member to insert is already in the sorted set, its score is updated and the member is reinserted at the right position in the set. + +[[_Redis documentation_]](https://redis.io/commands/zadd) + +## Arguments + +```js +zadd(key, elements, [options]); +``` + +
+ +| Arguments | Type | Description | +| ---------- | ------------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `elements` |
object[]
| Elements to add | +| `options` |
object
| Optional query arguments | + +### elements + +The `elements` array lists the elements to add to the sorted set. Each element object has the following properties: + +| Properties | Type | Description | +| ---------- | ----------------- | ------------ | +| `member` |
string
| Member value | +| `score` |
string
| Member score | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `ch` |
boolean (false)
| If true, instead of returning the number of added elements, returns the number of changes performed | +| `incr` |
boolean (false)
| If true, instead of adding elements, increments the existing member with the provided `score`. Only one element can be specified if this option is set | +| `nx` |
boolean (false)
| If true, only adds new elements, without altering existing ones | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `xx` |
boolean (false)
| If true, ignores new elements, alters only existing ones | + +## Resolve + +Resolves to the number of added elements or, if the `ch` option is set, resolves to the number of changes performed. + +## Usage + +<<< ./snippets/zadd.js diff --git a/doc/6/controllers/ms/zadd/snippets/zadd.js b/doc/6/controllers/ms/zadd/snippets/zadd.js new file mode 100644 index 000000000..49d1b24ea --- /dev/null +++ b/doc/6/controllers/ms/zadd/snippets/zadd.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'bar', score: 4 }, + // { member: 'foo', score: 42 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zadd/snippets/zadd.test.yml b/doc/6/controllers/ms/zadd/snippets/zadd.test.yml new file mode 100644 index 000000000..688ccce02 --- /dev/null +++ b/doc/6/controllers/ms/zadd/snippets/zadd.test.yml @@ -0,0 +1,12 @@ +name: ms#zadd +description: Adds elements to a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - " { member: 'bar', score: 4 }," + - " { member: 'foo', score: 42 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zcard/index.md b/doc/6/controllers/ms/zcard/index.md new file mode 100644 index 000000000..ad9afa03d --- /dev/null +++ b/doc/6/controllers/ms/zcard/index.md @@ -0,0 +1,40 @@ +--- +code: true +type: page +title: zcard +--- + +# zcard + +Returns the number of elements held by a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zcard) + +## Arguments + +```js +zcard(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of elements in the sorted set. + +## Usage + +<<< ./snippets/zcard.js diff --git a/doc/6/controllers/ms/zcard/snippets/zcard.js b/doc/6/controllers/ms/zcard/snippets/zcard.js new file mode 100644 index 000000000..34b296ab9 --- /dev/null +++ b/doc/6/controllers/ms/zcard/snippets/zcard.js @@ -0,0 +1,12 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints 3 + console.log(await kuzzle.ms.zcard('ssetfoo')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zcard/snippets/zcard.test.yml b/doc/6/controllers/ms/zcard/snippets/zcard.test.yml new file mode 100644 index 000000000..3879d59ef --- /dev/null +++ b/doc/6/controllers/ms/zcard/snippets/zcard.test.yml @@ -0,0 +1,9 @@ +name: ms#zcard +description: Returns the number of elements held by a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^3$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zcount/index.md b/doc/6/controllers/ms/zcount/index.md new file mode 100644 index 000000000..388156a2d --- /dev/null +++ b/doc/6/controllers/ms/zcount/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zcount +--- + +# zcount + +Returns the number of elements held by a sorted set with a score within the provided range. + +[[_Redis documentation_]](https://redis.io/commands/zcount) + +## Arguments + +```js +zcount(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYSCORE](https://redis.io/commands/zrangebyscore#exclusive-intervals-and-infinity) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +## Usage + +<<< ./snippets/zcount.js diff --git a/doc/6/controllers/ms/zcount/snippets/zcount.js b/doc/6/controllers/ms/zcount/snippets/zcount.js new file mode 100644 index 000000000..72b60f2ec --- /dev/null +++ b/doc/6/controllers/ms/zcount/snippets/zcount.js @@ -0,0 +1,13 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 2 + // Counts elements with a score lower than 42 (excluded) + console.log(await kuzzle.ms.zcount('ssetfoo', '-inf', '(42')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zcount/snippets/zcount.test.yml b/doc/6/controllers/ms/zcount/snippets/zcount.test.yml new file mode 100644 index 000000000..f0e2cc704 --- /dev/null +++ b/doc/6/controllers/ms/zcount/snippets/zcount.test.yml @@ -0,0 +1,9 @@ +name: ms#zcount +description: Counts elements in a sorted set within a score range +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^2$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zincrby/index.md b/doc/6/controllers/ms/zincrby/index.md new file mode 100644 index 000000000..53e502d86 --- /dev/null +++ b/doc/6/controllers/ms/zincrby/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zincrby +--- + +# zincrby + +Increments the score of a sorted set member by the provided value. + +[[_Redis documentation_]](https://redis.io/commands/zincrby) + +## Arguments + +```js +zincrby(key, member, increment, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------ | ---------------------------------------- | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `increment` |
integer
| Increment to apply to the member's score | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the updated member's score. + +## Usage + +<<< ./snippets/zincrby.js diff --git a/doc/6/controllers/ms/zincrby/snippets/zincrby.js b/doc/6/controllers/ms/zincrby/snippets/zincrby.js new file mode 100644 index 000000000..2b6008aee --- /dev/null +++ b/doc/6/controllers/ms/zincrby/snippets/zincrby.js @@ -0,0 +1,17 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zincrby('ssetfoo', 'bar', 1333); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'foo', score: 42 }, + // { member: 'bar', score: 1337 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zincrby/snippets/zincrby.test.yml b/doc/6/controllers/ms/zincrby/snippets/zincrby.test.yml new file mode 100644 index 000000000..0d968a143 --- /dev/null +++ b/doc/6/controllers/ms/zincrby/snippets/zincrby.test.yml @@ -0,0 +1,12 @@ +name: ms#zincrby +description: Increments the score of a sorted set member by the provided value +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - "\\{ member: 'foo', score: 42 }," + - "\\{ member: 'bar', score: 1337 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zinterstore/index.md b/doc/6/controllers/ms/zinterstore/index.md new file mode 100644 index 000000000..800e26f73 --- /dev/null +++ b/doc/6/controllers/ms/zinterstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: zinterstore +--- + +# zinterstore + +Computes the intersection of the provided sorted sets, and stores the result in a new sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zinterstore) + +## Arguments + +```js +zinterstore(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------------ | +| `dest` |
string
| Target sorted set key | +| `sources` |
string[]
| List of sorted set keys to intersect | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `aggregate` |
string ("sum")
| Specifies how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `weights` |
integer[]
| List of multiplication factors to apply to sources sets, before aggregation. | + +## Resolve + +Resolves to the number of members added to the destination sorted set. + +## Usage + +<<< ./snippets/zinterstore.js diff --git a/doc/6/controllers/ms/zinterstore/snippets/zinterstore.js b/doc/6/controllers/ms/zinterstore/snippets/zinterstore.js new file mode 100644 index 000000000..791344201 --- /dev/null +++ b/doc/6/controllers/ms/zinterstore/snippets/zinterstore.js @@ -0,0 +1,34 @@ +try { + await kuzzle.ms.zadd('sset1', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zadd('sset2', [ + {member: 'foo', score: '-29'}, + {member: 'baz', score: '300'} + ]); + + // Sums scores of intersected values + await kuzzle.ms.zinterstore('destsum', ['sset1', 'sset2']); + + // Stores the minimum possible scores of intersected values + await kuzzle.ms.zinterstore( + 'destmin', + ['sset1', 'sset2'], + {aggregate: 'min'} + ); + + // Prints: + // [ { member: 'foo', score: 13 }, + // { member: 'baz', score: 27.85 } ] + console.log(await kuzzle.ms.zrange('destsum', 0, -1)); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'foo', score: -29 } ] + console.log(await kuzzle.ms.zrange('destmin', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zinterstore/snippets/zinterstore.test.yml b/doc/6/controllers/ms/zinterstore/snippets/zinterstore.test.yml new file mode 100644 index 000000000..6ac996ae8 --- /dev/null +++ b/doc/6/controllers/ms/zinterstore/snippets/zinterstore.test.yml @@ -0,0 +1,13 @@ +name: ms#zinterstore +description: Stores the intersection of the provided sorted sets +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'foo', score: 13 }," + - " { member: 'baz', score: 27.85\\d* } ]" + - "\\[ { member: 'baz', score: -272.15 }" + - " { member: 'foo', score: -29 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zlexcount/index.md b/doc/6/controllers/ms/zlexcount/index.md new file mode 100644 index 000000000..a3e3a8cf2 --- /dev/null +++ b/doc/6/controllers/ms/zlexcount/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zlexcount +--- + +# zlexcount + +Counts elements in a sorted set where all members have equal score, using lexicographical ordering. + +[[_Redis documentation_]](https://redis.io/commands/zlexcount) + +## Arguments + +```js +zlexcount(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of elements in the provided range. + +## Usage + +<<< ./snippets/zlexcount.js diff --git a/doc/6/controllers/ms/zlexcount/snippets/zlexcount.js b/doc/6/controllers/ms/zlexcount/snippets/zlexcount.js new file mode 100644 index 000000000..0be03e8eb --- /dev/null +++ b/doc/6/controllers/ms/zlexcount/snippets/zlexcount.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + // Prints: 2 + // Lexicographically counts elements with a maximum value of 'f' (excluded), + // without a minimum value + console.log(await kuzzle.ms.zlexcount('ssetfoo', '-', '(f')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zlexcount/snippets/zlexcount.test.yml b/doc/6/controllers/ms/zlexcount/snippets/zlexcount.test.yml new file mode 100644 index 000000000..d6e40d7c6 --- /dev/null +++ b/doc/6/controllers/ms/zlexcount/snippets/zlexcount.test.yml @@ -0,0 +1,9 @@ +name: ms#zlexcount +description: Counts elements in a sorted set using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: ^2$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrange/index.md b/doc/6/controllers/ms/zrange/index.md new file mode 100644 index 000000000..b0f3d3d75 --- /dev/null +++ b/doc/6/controllers/ms/zrange/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zrange +--- + +# zrange + +Returns elements depending on their position in the sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zrange) + +## Arguments + +```js +zrange(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `key` |
string
| Sorted set key | +| `start` |
integer
| Starting index offset (inclusive) | +| `stop` |
integer
| Ending index offset (inclusive) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a list of element objects. + +## Usage + +<<< ./snippets/zrange.js diff --git a/doc/6/controllers/ms/zrange/snippets/zrange.js b/doc/6/controllers/ms/zrange/snippets/zrange.js new file mode 100644 index 000000000..e76070db7 --- /dev/null +++ b/doc/6/controllers/ms/zrange/snippets/zrange.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'bar', score: 4 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrange/snippets/zrange.test.yml b/doc/6/controllers/ms/zrange/snippets/zrange.test.yml new file mode 100644 index 000000000..ad7b75181 --- /dev/null +++ b/doc/6/controllers/ms/zrange/snippets/zrange.test.yml @@ -0,0 +1,11 @@ +name: ms#zrange +description: Returns elements depending on their position in the sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - "{ member: 'bar', score: 4 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrangebylex/index.md b/doc/6/controllers/ms/zrangebylex/index.md new file mode 100644 index 000000000..d33aa47c7 --- /dev/null +++ b/doc/6/controllers/ms/zrangebylex/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: zrangebylex +--- + +# zrangebylex + +Returns elements within a provided interval, in a sorted set where all members have equal score, using lexicographical ordering. + +[[_Redis documentation_]](https://redis.io/commands/zrangebylex) + +## Arguments + +```js +zrangebylex(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of matched elements. + +## Usage + +<<< ./snippets/zrangebylex.js diff --git a/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.js b/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.js new file mode 100644 index 000000000..e52f9081b --- /dev/null +++ b/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + // Prints: [ 'bar', 'baz' ] + // Lexicographically gets elements with a maximum value of 'f' (excluded), + // without a minimum value + console.log(await kuzzle.ms.zrangebylex('ssetfoo', '-', '(f')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml b/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml new file mode 100644 index 000000000..0877b44f6 --- /dev/null +++ b/doc/6/controllers/ms/zrangebylex/snippets/zrangebylex.test.yml @@ -0,0 +1,9 @@ +name: ms#zrangebylex +description: Returns elements within a provided interval, using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'bar', 'baz' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrangebyscore/index.md b/doc/6/controllers/ms/zrangebyscore/index.md new file mode 100644 index 000000000..4a796e21b --- /dev/null +++ b/doc/6/controllers/ms/zrangebyscore/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: zrangebyscore +--- + +# zrangebyscore + +Returns all sorted set elements with a score within a provided range. + +The elements are considered to be ordered from low to high scores. + +[[_Redis documentation_]](https://redis.io/commands/zrangebyscore) + +## Arguments + +```js +zrangebyscore(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum score value | +| `max` |
string
| Maximum score value | +| `options` |
object
| Optional query arguments | + +By default, `min` and `max` are inclusive. Check the full Redis documentation for other options. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of elements in the provided score range. + +## Usage + +<<< ./snippets/zrangebyscore.js diff --git a/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.js b/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.js new file mode 100644 index 000000000..883a68ef5 --- /dev/null +++ b/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'baz', score: -272.15 }, + // { member: 'bar', score: 4 } ] + console.log(await kuzzle.ms.zrangebyscore('ssetfoo', '-inf', '(42')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml b/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml new file mode 100644 index 000000000..25e845808 --- /dev/null +++ b/doc/6/controllers/ms/zrangebyscore/snippets/zrangebyscore.test.yml @@ -0,0 +1,11 @@ +name: ms#zrangebyscore +description: Returns all sorted set elements with a score within a provided range +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'baz', score: -272.15 }," + - "{ member: 'bar', score: 4 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrank/index.md b/doc/6/controllers/ms/zrank/index.md new file mode 100644 index 000000000..ae68b82de --- /dev/null +++ b/doc/6/controllers/ms/zrank/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zrank +--- + +# zrank + +Returns the position of an element in a sorted set, with scores sorted in ascending order. The index returned is 0-based (the lowest score member has an index of 0). + +[[_Redis documentation_]](https://redis.io/commands/zrank) + +## Arguments + +```js +zrank(key, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the index of the found member in the sorted set, or to `null` if the member is not found. + +## Usage + +<<< ./snippets/zrank.js diff --git a/doc/6/controllers/ms/zrank/snippets/zrank.js b/doc/6/controllers/ms/zrank/snippets/zrank.js new file mode 100644 index 000000000..f92571cf8 --- /dev/null +++ b/doc/6/controllers/ms/zrank/snippets/zrank.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 2 + console.log(await kuzzle.ms.zrank('ssetfoo', 'foo')); + + // Prints: null + console.log(await kuzzle.ms.zrank('ssetfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrank/snippets/zrank.test.yml b/doc/6/controllers/ms/zrank/snippets/zrank.test.yml new file mode 100644 index 000000000..7c003c8ec --- /dev/null +++ b/doc/6/controllers/ms/zrank/snippets/zrank.test.yml @@ -0,0 +1,11 @@ +name: ms#zrank +description: Returns the position of an element in a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^2$ + - ^null$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrem/index.md b/doc/6/controllers/ms/zrem/index.md new file mode 100644 index 000000000..1778ca68d --- /dev/null +++ b/doc/6/controllers/ms/zrem/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zrem +--- + +# zrem + +Removes members from a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zrem) + +## Arguments + +```js +zrem(key, members, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `members` |
string[]
| Member values to remove | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed members. + +## Usage + +<<< ./snippets/zrem.js diff --git a/doc/6/controllers/ms/zrem/snippets/zrem.js b/doc/6/controllers/ms/zrem/snippets/zrem.js new file mode 100644 index 000000000..75893c159 --- /dev/null +++ b/doc/6/controllers/ms/zrem/snippets/zrem.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zrem('ssetfoo', ['foo', 'bar']); + + // Prints: [ { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrem/snippets/zrem.test.yml b/doc/6/controllers/ms/zrem/snippets/zrem.test.yml new file mode 100644 index 000000000..b3dc91706 --- /dev/null +++ b/doc/6/controllers/ms/zrem/snippets/zrem.test.yml @@ -0,0 +1,9 @@ +name: ms#zrem +description: Removes members from a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ { member: 'baz', score: -272.15 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zremrangebylex/index.md b/doc/6/controllers/ms/zremrangebylex/index.md new file mode 100644 index 000000000..e73a28459 --- /dev/null +++ b/doc/6/controllers/ms/zremrangebylex/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zremrangebylex +--- + +# zremrangebylex + +Removes members within a provided range, from a sorted set where all elements have the same score, using lexicographical ordering. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebylex) + +## Arguments + +```js +zremrangebylex(key, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed members. + +## Usage + +<<< ./snippets/zremrangebylex.js diff --git a/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.js b/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.js new file mode 100644 index 000000000..97fb5a232 --- /dev/null +++ b/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + await kuzzle.ms.zremrangebylex('ssetfoo', '[baz', '+'); + + // Prints: [ 'bar' ] + console.log(await kuzzle.ms.zrangebylex('ssetfoo', '-', '+')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml b/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml new file mode 100644 index 000000000..a33d40996 --- /dev/null +++ b/doc/6/controllers/ms/zremrangebylex/snippets/zremrangebylex.test.yml @@ -0,0 +1,9 @@ +name: ms#zremrangebylex +description: Removes members within a provided range, using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'bar' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zremrangebyrank/index.md b/doc/6/controllers/ms/zremrangebyrank/index.md new file mode 100644 index 000000000..c2b8b7dad --- /dev/null +++ b/doc/6/controllers/ms/zremrangebyrank/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zremrangebyrank +--- + +# zremrangebyrank + +Removes members from a sorted set, with their position in the set within a provided index range. + +Positions are 0-based, meaning the first member of the set has a position of 0. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebyrank) + +## Arguments + +```js +zremrangebyrank(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `key` |
string
| Sorted set key | +| `start` |
integer
| Starting index offset (inclusive) | +| `stop` |
integer
| Ending index offset (inclusive) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed elements. + +## Usage + +<<< ./snippets/zremrangebyrank.js diff --git a/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js b/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js new file mode 100644 index 000000000..61c724559 --- /dev/null +++ b/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zremrangebyrank('ssetfoo', 1, 2); + + // Prints: [ { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml b/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml new file mode 100644 index 000000000..3dc0390ab --- /dev/null +++ b/doc/6/controllers/ms/zremrangebyrank/snippets/zremrangebyrank.test.yml @@ -0,0 +1,9 @@ +name: ms#zremrangebyrank +description: Removes members from a sorted setn by position +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ { member: 'baz', score: -272.15 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zremrangebyscore/index.md b/doc/6/controllers/ms/zremrangebyscore/index.md new file mode 100644 index 000000000..51f0ef8fd --- /dev/null +++ b/doc/6/controllers/ms/zremrangebyscore/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: zremrangebyscore +--- + +# zremrangebyscore + +Removes members from a sorted set, with a score between the provided interval. + +[[_Redis documentation_]](https://redis.io/commands/zremrangebylex) + +## Arguments + +```js +zremrangebyscore(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum score value | +| `max` |
string
| Maximum score value | +| `options` |
object
| Optional query arguments | + +By default, `min` and `max` are inclusive. Check the full Redis documentation for other options. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the number of removed elements. + +## Usage + +<<< ./snippets/zremrangebyscore.js diff --git a/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js b/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js new file mode 100644 index 000000000..3b81af9ba --- /dev/null +++ b/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + await kuzzle.ms.zremrangebyscore('ssetfoo', '0', '+inf'); + + // Prints: [ { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrange('ssetfoo', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml b/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml new file mode 100644 index 000000000..bd0924e7e --- /dev/null +++ b/doc/6/controllers/ms/zremrangebyscore/snippets/zremrangebyscore.test.yml @@ -0,0 +1,9 @@ +name: ms#zremrangebyscore +description: Removes members from a sorted set, by score +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ { member: 'baz', score: -272.15 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrevrange/index.md b/doc/6/controllers/ms/zrevrange/index.md new file mode 100644 index 000000000..3c22ff3b2 --- /dev/null +++ b/doc/6/controllers/ms/zrevrange/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: zrevrange +--- + +# zrevrange + +Identical to [zrange](/sdk/js/6/controllers/ms/zrange), except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrange) + +## Arguments + +```js +zrevrange(key, start, stop, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `key` |
string
| Sorted set key | +| `start` |
integer
| Starting index offset (inclusive) | +| `stop` |
integer
| Ending index offset (inclusive) | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a list of element objects. + +## Usage + +<<< ./snippets/zrevrange.js diff --git a/doc/6/controllers/ms/zrevrange/snippets/zrevrange.js b/doc/6/controllers/ms/zrevrange/snippets/zrevrange.js new file mode 100644 index 000000000..19025699b --- /dev/null +++ b/doc/6/controllers/ms/zrevrange/snippets/zrevrange.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'foo', score: 42 }, + // { member: 'bar', score: 4 } ] + console.log(await kuzzle.ms.zrevrange('ssetfoo', 0, 1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrevrange/snippets/zrevrange.test.yml b/doc/6/controllers/ms/zrevrange/snippets/zrevrange.test.yml new file mode 100644 index 000000000..a155183b1 --- /dev/null +++ b/doc/6/controllers/ms/zrevrange/snippets/zrevrange.test.yml @@ -0,0 +1,10 @@ +name: ms#zrevrange +description: Returns elements depending on their position in the sorted set, in descending order +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'foo', score: 42 }, { member: 'bar', score: 4 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrevrangebylex/index.md b/doc/6/controllers/ms/zrevrangebylex/index.md new file mode 100644 index 000000000..413ac7f97 --- /dev/null +++ b/doc/6/controllers/ms/zrevrangebylex/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: zrevrangebylex +--- + +# zrevrangebylex + +Identical to [zrangebylex](/core/1/api/controllers/memory-storage/zrangebylex/) except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrangebylex) + +## Arguments + +```js +zrevrangebylex(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum range value | +| `max` |
string
| Maximum range value | +| `options` |
object
| Optional query arguments | + +By default, the provided min and max values are inclusive. This behavior can be changed using the syntax described in the Redis [ZRANGEBYLEX](https://redis.io/commands/zrangebylex#how-to-specify-intervals) documentation. + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an array of matched elements. + +## Usage + +<<< ./snippets/zrevrangebylex.js diff --git a/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js b/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js new file mode 100644 index 000000000..a056f7261 --- /dev/null +++ b/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '0'}, + {member: 'bar', score: '0'}, + {member: 'baz', score: '0'} + ]); + + // Prints: [ 'baz', 'bar' ] + // Lexicographically gets elements with a maximum value of 'f' (excluded), + // without a minimum value + console.log(await kuzzle.ms.zrevrangebylex('ssetfoo', '-', '(f')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml b/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml new file mode 100644 index 000000000..895a059e0 --- /dev/null +++ b/doc/6/controllers/ms/zrevrangebylex/snippets/zrevrangebylex.test.yml @@ -0,0 +1,9 @@ +name: ms#zrevrangebylex +description: Returns elements within a provided interval, using lexicographical ordering +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: "\\[ 'baz', 'bar' ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrevrangebyscore/index.md b/doc/6/controllers/ms/zrevrangebyscore/index.md new file mode 100644 index 000000000..cf6d3313a --- /dev/null +++ b/doc/6/controllers/ms/zrevrangebyscore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: zrevrangebyscore +--- + +# zrevrangebyscore + +Identical to [zrangebyscore](/core/1/api/controllers/memory-storage/zrangebyscore/), except that the sorted set is traversed in descending order. + +[[_Redis documentation_]](https://redis.io/commands/zrevrangebyscore) + +## Arguments + +```js +zrevrangebyscore(key, min, max, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `min` |
string
| Minimum score value | +| `max` |
string
| Maximum score value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` |
integer[2]
| An array of 2 integers, used to limit the number of returned matching elements (similar to _SELECT LIMIT offset, count_ in SQL).
Format: `[,]` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the list of elements in the provided score range, in descending order. + +## Usage + +<<< ./snippets/zrevrangebyscore.js diff --git a/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js b/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js new file mode 100644 index 000000000..37b591750 --- /dev/null +++ b/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.js @@ -0,0 +1,14 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // [ { member: 'bar', score: 4 }, + // { member: 'baz', score: -272.15 } ] + console.log(await kuzzle.ms.zrevrangebyscore('ssetfoo', '-inf', '(42')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml b/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml new file mode 100644 index 000000000..f44188795 --- /dev/null +++ b/doc/6/controllers/ms/zrevrangebyscore/snippets/zrevrangebyscore.test.yml @@ -0,0 +1,12 @@ +name: ms#zrevrangebyscore +description: Returns all sorted set elements with a score within a provided range in descending order +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'bar', score: 4 }," + - "{ member: 'baz', score: -272.15 } ]" + +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zrevrank/index.md b/doc/6/controllers/ms/zrevrank/index.md new file mode 100644 index 000000000..312aa3a41 --- /dev/null +++ b/doc/6/controllers/ms/zrevrank/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zrevrank +--- + +# zrevrank + +Returns the position of an element in a sorted set, with scores in descending order. The index returned is 0-based (the lowest score member has an index of 0). + +[[_Redis documentation_]](https://redis.io/commands/zrevrank) + +## Arguments + +```js +zrevrank(key, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the index of the found member in the sorted set, or to `null` if the member is not found. + +## Usage + +<<< ./snippets/zrevrank.js diff --git a/doc/6/controllers/ms/zrevrank/snippets/zrevrank.js b/doc/6/controllers/ms/zrevrank/snippets/zrevrank.js new file mode 100644 index 000000000..9e7442449 --- /dev/null +++ b/doc/6/controllers/ms/zrevrank/snippets/zrevrank.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 0 + console.log(await kuzzle.ms.zrevrank('ssetfoo', 'foo')); + + // Prints: null + console.log(await kuzzle.ms.zrank('ssetfoo', 'qux')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zrevrank/snippets/zrevrank.test.yml b/doc/6/controllers/ms/zrevrank/snippets/zrevrank.test.yml new file mode 100644 index 000000000..7265aa01a --- /dev/null +++ b/doc/6/controllers/ms/zrevrank/snippets/zrevrank.test.yml @@ -0,0 +1,12 @@ +name: ms#zrevrank +description: Returns the position of an element in a sorted set, in reverse order +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^0$ + - ^null$ + +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zscan/index.md b/doc/6/controllers/ms/zscan/index.md new file mode 100644 index 000000000..78be305d6 --- /dev/null +++ b/doc/6/controllers/ms/zscan/index.md @@ -0,0 +1,53 @@ +--- +code: true +type: page +title: zscan +--- + +# zscan + +Iterates incrementally over members contained in a sorted set, using a cursor. + +An iteration starts when the cursor is set to 0. +To get the next page of results, simply re-send the request with the updated cursor position provided in the result set. + +The scan ends when the cursor returned by the server is 0. + +[[_Redis documentation_]](https://redis.io/commands/sscan) + +## Arguments + +```js +zscan(key, cursor, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------ | ------------------------ | +| `key` |
string
| Sorted set key | +| `cursor` |
integer
| Cursor offset | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `count` |
integer (10)
| Return an _approximate_ number of items per result set | +| `match` |
string (\*)
| Return only keys matching the provided pattern | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an object representing a result page, with the following properties: + +| Property | Type | Description | +| -------- | ------------------- | --------------------------------------------------------------------------------------------------------- | +| `cursor` |
integer
| Cursor offset for the next page, or `0` if at the end of the scan | +| `values` |
string[]
| List of member-score pairs. The array entries alternate between member values and their associated scores | + +## Usage + +<<< ./snippets/zscan.js diff --git a/doc/6/controllers/ms/zscan/snippets/zscan.js b/doc/6/controllers/ms/zscan/snippets/zscan.js new file mode 100644 index 000000000..6e8e7304b --- /dev/null +++ b/doc/6/controllers/ms/zscan/snippets/zscan.js @@ -0,0 +1,16 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: + // { + // cursor: '0', + // values: [ 'baz', '-272.15', 'bar', '4', 'foo', '42' ] + // } + console.log(await kuzzle.ms.zscan('ssetfoo', 0)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zscan/snippets/zscan.test.yml b/doc/6/controllers/ms/zscan/snippets/zscan.test.yml new file mode 100644 index 000000000..9a58a6608 --- /dev/null +++ b/doc/6/controllers/ms/zscan/snippets/zscan.test.yml @@ -0,0 +1,11 @@ +name: ms#zscan +description: Iterates incrementally over fields contained in a sorted set, using a cursor +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "{ cursor: '0'," + - "values: \\[ 'baz', '-272.1\\d{1,}', 'bar', '4', 'foo', '42' ] }" +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zscore/index.md b/doc/6/controllers/ms/zscore/index.md new file mode 100644 index 000000000..707d9535f --- /dev/null +++ b/doc/6/controllers/ms/zscore/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: zscore +--- + +# zscore + +Returns the score of an element in a sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zscore) + +## Arguments + +```js +zscore(key, member, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------------------ | +| `key` |
string
| Sorted set key | +| `member` |
string
| Member value | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ---------- | ------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to the member's score. + +## Usage + +<<< ./snippets/zscore.js diff --git a/doc/6/controllers/ms/zscore/snippets/zscore.js b/doc/6/controllers/ms/zscore/snippets/zscore.js new file mode 100644 index 000000000..6826cd3e1 --- /dev/null +++ b/doc/6/controllers/ms/zscore/snippets/zscore.js @@ -0,0 +1,15 @@ +try { + await kuzzle.ms.zadd('ssetfoo', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'}, + {member: 'baz', score: '-272.15'} + ]); + + // Prints: 42 + console.log(await kuzzle.ms.zscore('ssetfoo', 'foo')); + + // Prints: 4 + console.log(await kuzzle.ms.zscore('ssetfoo', 'bar')); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zscore/snippets/zscore.test.yml b/doc/6/controllers/ms/zscore/snippets/zscore.test.yml new file mode 100644 index 000000000..6cb2d2a1d --- /dev/null +++ b/doc/6/controllers/ms/zscore/snippets/zscore.test.yml @@ -0,0 +1,11 @@ +name: ms#zscore +description: Returns the score of an element in a sorted set +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - ^42$ + - ^4$ +sdk: js +version: 6 diff --git a/doc/6/controllers/ms/zunionstore/index.md b/doc/6/controllers/ms/zunionstore/index.md new file mode 100644 index 000000000..fb5e5693c --- /dev/null +++ b/doc/6/controllers/ms/zunionstore/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: zunionstore +--- + +# zunionstore + +Computes the union of the provided sorted sets, and stores the result in a new sorted set. + +[[_Redis documentation_]](https://redis.io/commands/zunionstore) + +## Arguments + +```js +zunionstore(dest, sources, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ------------------- | ------------------------------- | +| `dest` |
string
| Target sorted set key | +| `sources` |
string[]
| List of sorted set keys to join | +| `options` |
object
| Optional query arguments | + +### options + +The `options` arguments can contain the following option properties: + +| Property | Type (default) | Description | +| ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `aggregate` |
string ("sum")
| Specifies how members' scores are aggregated during the intersection.
Allowed values: `min`, `max`, `sum` | +| `queuable` |
boolean (true)
| If true, queues the request during downtime, until connected to Kuzzle again | +| `weights` |
integer[]
| List of multiplication factors to apply to sources sets, before aggregation. | + +## Resolve + +Resolves to the number of members added to the destination sorted set. + +## Usage + +<<< ./snippets/zunionstore.js diff --git a/doc/6/controllers/ms/zunionstore/snippets/zunionstore.js b/doc/6/controllers/ms/zunionstore/snippets/zunionstore.js new file mode 100644 index 000000000..327e9bd2f --- /dev/null +++ b/doc/6/controllers/ms/zunionstore/snippets/zunionstore.js @@ -0,0 +1,35 @@ +try { + await kuzzle.ms.zadd('sset1', [ + {member: 'foo', score: '42'}, + {member: 'bar', score: '4'} + ]); + + await kuzzle.ms.zadd('sset2', [ + {member: 'foo', score: '-29'}, + {member: 'baz', score: '300'} + ]); + + // Sums scores of joined values + await kuzzle.ms.zunionstore('destsum', ['sset1', 'sset2']); + + // Stores the minimum possible scores of joined values + await kuzzle.ms.zunionstore( + 'destmin', + ['sset1', 'sset2'], + {aggregate: 'min'} + ); + + // Prints: + // [ { member: 'bar', score: 4 }, + // { member: 'foo', score: 13 }, + // { member: 'baz', score: 300 } ] + console.log(await kuzzle.ms.zrange('destsum', 0, -1)); + + // Prints: + // [ { member: 'foo', score: -29 }, + // { member: 'bar', score: 4 }, + // { member: 'baz', score: 300 } ] + console.log(await kuzzle.ms.zrange('destmin', 0, -1)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/ms/zunionstore/snippets/zunionstore.test.yml b/doc/6/controllers/ms/zunionstore/snippets/zunionstore.test.yml new file mode 100644 index 000000000..e171869cb --- /dev/null +++ b/doc/6/controllers/ms/zunionstore/snippets/zunionstore.test.yml @@ -0,0 +1,15 @@ +name: ms#zunionstore +description: Stores the union of the provided sorted sets +hooks: + before: curl -X POST kuzzle:7512/ms/_flushdb + after: +template: default +expected: + - "\\[ { member: 'bar', score: 4 }," + - " { member: 'foo', score: 13 }," + - " { member: 'baz', score: 300 } ]" + - "\\[ { member: 'foo', score: -29 }," + - " { member: 'bar', score: 4 }," + - " { member: 'baz', score: 300 } ]" +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/count/index.md b/doc/6/controllers/realtime/count/index.md new file mode 100644 index 000000000..d8beddf88 --- /dev/null +++ b/doc/6/controllers/realtime/count/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: count +description: Count subscribers for a subscription room +--- + +# count + +Returns the number of other connections sharing the same subscription. + +## Arguments + +```js +count(roomId, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | -------------------- | +| `roomId` |
string
| Subscription room ID | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Option | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +Resolves to a number represensting active connections using the same provided subscription room. + +## Usage + +<<< ./snippets/count.js diff --git a/doc/6/controllers/realtime/count/snippets/count.js b/doc/6/controllers/realtime/count/snippets/count.js new file mode 100644 index 000000000..f6f305e57 --- /dev/null +++ b/doc/6/controllers/realtime/count/snippets/count.js @@ -0,0 +1,14 @@ +try { + const roomId = await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + {}, + () => {} + ); + + const count = await kuzzle.realtime.count(roomId); + + console.log(`Currently ${count} active subscription`); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/realtime/count/snippets/count.test.yml b/doc/6/controllers/realtime/count/snippets/count.test.yml new file mode 100644 index 000000000..b0ba611a2 --- /dev/null +++ b/doc/6/controllers/realtime/count/snippets/count.test.yml @@ -0,0 +1,10 @@ +name: realtime#count +description: Count subscribers for a subscription room +hooks: + before: + after: +template: default +expected: Currently 1 active subscription + +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/index.md b/doc/6/controllers/realtime/index.md new file mode 100644 index 000000000..e1753df1d --- /dev/null +++ b/doc/6/controllers/realtime/index.md @@ -0,0 +1,8 @@ +--- +code: true +type: branch +title: realtime +description: Realtime Controller +--- + +# Realtime Controller diff --git a/doc/6/controllers/realtime/publish/index.md b/doc/6/controllers/realtime/publish/index.md new file mode 100644 index 000000000..947c21771 --- /dev/null +++ b/doc/6/controllers/realtime/publish/index.md @@ -0,0 +1,45 @@ +--- +code: true +type: page +title: publish +description: Publish a real-time message +--- + +# publish + +Sends a real-time message to Kuzzle. The message will be dispatched to all clients with subscriptions matching the index, the collection and the message content. + +The index and collection are indicative and serve only to distinguish the rooms. They are not required to exist in the database + +**Note:** real-time messages are not persisted in the database. + +
+ +```js +publish(index, collection, message, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ----------------- | --------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `message` |
object
| Message to send | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Option | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +A boolean indicating if the message was successfully published. + +## Usage + +<<< ./snippets/publish.js diff --git a/doc/6/controllers/realtime/publish/snippets/publish.js b/doc/6/controllers/realtime/publish/snippets/publish.js new file mode 100644 index 000000000..854c5ccb0 --- /dev/null +++ b/doc/6/controllers/realtime/publish/snippets/publish.js @@ -0,0 +1,13 @@ +const message = { realtime: 'rule the web' }; + +try { + await kuzzle.realtime.publish( + 'i-dont-exist', + 'in-database', + message + ); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/realtime/publish/snippets/publish.test.yml b/doc/6/controllers/realtime/publish/snippets/publish.test.yml new file mode 100644 index 000000000..b95fffd27 --- /dev/null +++ b/doc/6/controllers/realtime/publish/snippets/publish.test.yml @@ -0,0 +1,10 @@ +name: realtime#publish +description: Publish a realtime message +hooks: + before: + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/subscribe/index.md b/doc/6/controllers/realtime/subscribe/index.md new file mode 100644 index 000000000..7eb6b6b42 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/index.md @@ -0,0 +1,64 @@ +--- +code: true +type: page +title: subscribe +description: Subscribe to real-time notifications +--- + +# subscribe + +Subscribes by providing a set of filters: messages, document changes and, optionally, user events matching the provided filters will generate [real-time notifications](/core/1/api/essentials/notifications), sent to you in real-time by Kuzzle. + +
+ +```js +subscribe(index, collection, filters, callback, [options]); +``` + +
+ +| Arguments | Type | Description | +| ------------ | ------------------- | ------------------------------------------------------------- | +| `index` |
string
| Index name | +| `collection` |
string
| Collection name | +| `filters` |
object
| Set of filters following [Koncorde syntax](/core/1/guides/cookbooks/realtime-api/) | +| `callback` |
function
| Callback function to handle notifications | +| `options` |
object
| Query options | + +### callback + +Callback function that will be called each time a new notifications is received. +The callback will receive the [notifications object](/sdk/js/6/essentials/realtime-notifications/) as only argument. + +### options + +Additional subscription options. + +| Property | Type
(default) | Description | +| ----------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `scope` |
string

(`all`) | Subscribe to document entering or leaving the scope
Possible values: `all`, `in`, `out`, `none` | +| `users` |
string

(`none`) | Subscribe to users entering or leaving the room
Possible values: `all`, `in`, `out`, `none` | +| `subscribeToSelf` |
boolean

(`true`) | Subscribe to notifications fired by our own queries | +| `volatile` |
object

(`null`) | subscription information, used in [user join/leave notifications](/core/1/api/essentials/volatile-data/) | + +## Resolves + +Resolves to a string containing the room ID + +## Usage + +_Simple subscription to document notifications_ + +<<< ./snippets/document-notifications.js + +_Subscription to document notifications with scope option_ + +<<< ./snippets/document-notifications-leave-scope.js + +_Subscription to message notifications_ + +<<< ./snippets/message-notifications.js + +_Subscription to user notifications_ + +<<< ./snippets/user-notifications.js diff --git a/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js b/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js new file mode 100644 index 000000000..f0eecc0f1 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.js @@ -0,0 +1,48 @@ +function callback (notification) { + console.log(notification); + /* + { status: 200, + requestId: 'e114c5d0-8ad1-4751-9236-772f9fea1b19', + timestamp: 1539783948258, + volatile: { sdkVersion: '6.0.0-beta-2' }, + index: 'nyc-open-data', + collection: 'yellow-taxi', + controller: 'document', + action: 'update', + protocol: 'websocket', + scope: 'out', + state: 'done', + result: { _id: 'AWaCRnfbiSV6vMG7iV_K' }, + type: 'document', + room: '638dd7b94b86720e6ac3f0617f26f116-ae85604010d1f5c7' } + */ + console.log(`Document moved ${notification.scope} from the scope`); +} + +try { + // Subscribe to notifications when document leaves the scope + const filters = { range: { age: { lte: 20 } } }; + const options = { scope: 'out' }; + + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filters, + callback, + options + ); + + const document = { name: 'nina vkote', age: 19 }; + + // The document is in the scope + const { _id } = await kuzzle.document.create( + 'nyc-open-data', + 'yellow-taxi', + document + ); + + // The document isn't in the scope anymore + await kuzzle.document.update('nyc-open-data', 'yellow-taxi', _id, { age: 42 }); +} catch (error) { + console.log(error.message); +} diff --git a/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml b/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml new file mode 100644 index 000000000..f4321c129 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/document-notifications-leave-scope.test.yml @@ -0,0 +1,10 @@ +name: realtime#subscribe-documents-leave-scope +description: Subscribe to documents leaving the scope +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create ; curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi/ + after: +template: realtime +expected: Document moved out from the scope + +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/subscribe/snippets/document-notifications.js b/doc/6/controllers/realtime/subscribe/snippets/document-notifications.js new file mode 100644 index 000000000..10e4c4231 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/document-notifications.js @@ -0,0 +1,46 @@ +function callback (notification) { + console.log(notification); + /* + { status: 200, + requestId: '1850b835-d82d-4bce-abec-bf593a578763', + timestamp: 1539680191720, + volatile: { sdkVersion: '6.0.0-beta-2' }, + index: 'nyc-open-data', + collection: 'yellow-taxi', + controller: 'document', + action: 'create', + protocol: 'websocket', + scope: 'in', + result: + { _source: + { name: 'nina vkote', + age: 19, + _kuzzle_info: + { author: '-1', + createdAt: 1539680191720, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } }, + _id: 'AWZ8F0TpJD41ulNI_b-v' }, + type: 'document', + room: '14b675feccf5ac320456ef0dbdf6c1fa-7a90af8c8bdaac1b' } + */ + if (notification.scope === 'in') { + console.log(`Document ${notification.result._source.name} enter the scope`); + } else { + console.log(`Document ${notification.result._source.name} leave the scope`); + } +} + +try { + // Subscribe to notifications for documents containing a 'name' property + const filters = { exists: 'name' }; + + await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filters, callback); + + const document = { name: 'nina vkote', age: 19 }; + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', document); +} catch (error) { + console.log(error.message); +} diff --git a/doc/6/controllers/realtime/subscribe/snippets/document-notifications.test.yml b/doc/6/controllers/realtime/subscribe/snippets/document-notifications.test.yml new file mode 100644 index 000000000..8dde8db25 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/document-notifications.test.yml @@ -0,0 +1,10 @@ +name: realtime#subscribe-documents +description: Simple subscribe to document notifications +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create ; curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi/ + after: +template: realtime +expected: Document nina vkote enter the scope + +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/subscribe/snippets/message-notifications.js b/doc/6/controllers/realtime/subscribe/snippets/message-notifications.js new file mode 100644 index 000000000..677a89c34 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/message-notifications.js @@ -0,0 +1,43 @@ +function callback (notification) { + console.log(notification); + /* + { status: 200, + requestId: '212cc14d-3a4e-4f26-9fe8-6ba6c6279f9d', + timestamp: 1539702246068, + volatile: { sdkVersion: '6.0.0-beta-2' }, + index: 'i-dont-exist', + collection: 'in-database', + controller: 'realtime', + action: 'publish', + protocol: 'websocket', + scope: 'in', + state: 'done', + result: + { _source: + { metAt: 'Insane', + hello: 'world', + _kuzzle_info: + { author: '-1', + createdAt: 1539680191720, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } }, + _id: null }, + type: 'document', + room: '24bbb5c44c343167eaf6a023dca8629e-7a90af8c8bdaac1b' } + */ + console.log('Message notification received'); +} + +try { + // Subscribe to a room + await kuzzle.realtime.subscribe('i-dont-exist', 'in-database', {}, callback); + + // Publish a message to this room + const message = { metAt: 'Insane', hello: 'world' }; + + await kuzzle.realtime.publish('i-dont-exist', 'in-database', message); +} catch (error) { + console.log(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/realtime/subscribe/snippets/message-notifications.test.yml b/doc/6/controllers/realtime/subscribe/snippets/message-notifications.test.yml new file mode 100644 index 000000000..b97305f9c --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/message-notifications.test.yml @@ -0,0 +1,10 @@ +name: realtime#subscribe-messages +description: Subscribe to message notifications +hooks: + before: + after: +template: realtime +expected: Message notification received + +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/subscribe/snippets/user-notifications.js b/doc/6/controllers/realtime/subscribe/snippets/user-notifications.js new file mode 100644 index 000000000..2b9cb8900 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/user-notifications.js @@ -0,0 +1,42 @@ +function callback (notification) { + if (notification.type === 'user') { + console.log(notification.volatile); + /* + { sdkVersion: '', username: 'nina vkote' }, + */ + console.log(`Currently ${notification.result.count} users in the room`); + } +} + +try { + const filters = { exists: 'name' }; + // Subscribe users notifications + const options = { users: 'all' }; + + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filters, + callback, + options + ); + + // Instantiates a second kuzzle client: multiple subscriptions + // made by the same user will not trigger "new user" notifications + const kuzzle2 = new Kuzzle( + new WebSocket('kuzzle') + ); + await kuzzle2.connect(); + + // Subscribe to the same room with the second client + const options2 = { users: 'all', volatile: { username: 'nina vkote' } }; + await kuzzle2.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filters, + () => {}, + options2 + ); +} catch (error) { + console.log(error.message); +} diff --git a/doc/6/controllers/realtime/subscribe/snippets/user-notifications.test.yml b/doc/6/controllers/realtime/subscribe/snippets/user-notifications.test.yml new file mode 100644 index 000000000..c0290cea0 --- /dev/null +++ b/doc/6/controllers/realtime/subscribe/snippets/user-notifications.test.yml @@ -0,0 +1,9 @@ +name: realtime#subscribe-users +description: Subscribe to users joining or leaving the room +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create ; curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi/ + after: +template: realtime +expected: "username: 'nina vkote'" +sdk: js +version: 6 diff --git a/doc/6/controllers/realtime/unsubscribe/index.md b/doc/6/controllers/realtime/unsubscribe/index.md new file mode 100644 index 000000000..795959c8a --- /dev/null +++ b/doc/6/controllers/realtime/unsubscribe/index.md @@ -0,0 +1,39 @@ +--- +code: true +type: page +title: unsubscribe +description: Removes a subscription +--- + +# unsubscribe + +Removes a subscription. + +
+ +```js +unsubscribe(roomId, [options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | -------------------- | +| `roomId` |
string
| Subscription room ID | +| `options` |
object
| Query options | + +### options + +Additional query options + +| Option | Type
(default) | Description | +| ---------- | ---------------------------- | --------------------------------- | +| `queuable` |
bool

(`true`) | Make this request queuable or not | + +## Resolves + +Resolves if successfuly unsubscribed. + +## Usage + +<<< ./snippets/unsubscribe.js diff --git a/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.js b/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.js new file mode 100644 index 000000000..d22947501 --- /dev/null +++ b/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.js @@ -0,0 +1,14 @@ +try { + const roomId = await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + {}, + () => {} + ); + + await kuzzle.realtime.unsubscribe(roomId); + + console.log('Success'); +} catch (error) { + console.error(error.message); +} \ No newline at end of file diff --git a/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml b/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml new file mode 100644 index 000000000..72124fdf9 --- /dev/null +++ b/doc/6/controllers/realtime/unsubscribe/snippets/unsubscribe.test.yml @@ -0,0 +1,10 @@ +name: realtime#unsubscribe +description: Removes a subscription +hooks: + before: + after: +template: default +expected: Success + +sdk: js +version: 6 diff --git a/doc/6/controllers/server/admin-exists/index.md b/doc/6/controllers/server/admin-exists/index.md new file mode 100644 index 000000000..9c1e84988 --- /dev/null +++ b/doc/6/controllers/server/admin-exists/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: adminExists +description: Checks that an administrator account exists. +--- + +# adminExists + +Checks that an administrator account exists. + +
+ +```js +adminExists([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a `boolean` set to `true` if an admin exists and `false` if it does not. + +## Usage + +<<< ./snippets/admin-exists.js diff --git a/doc/6/controllers/server/admin-exists/snippets/admin-exists.js b/doc/6/controllers/server/admin-exists/snippets/admin-exists.js new file mode 100644 index 000000000..c9c63df7b --- /dev/null +++ b/doc/6/controllers/server/admin-exists/snippets/admin-exists.js @@ -0,0 +1,7 @@ +try { + const exists = await kuzzle.server.adminExists(); + + console.log('Admin exists?', exists); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/admin-exists/snippets/admin-exists.test.yml b/doc/6/controllers/server/admin-exists/snippets/admin-exists.test.yml new file mode 100644 index 000000000..823029ea2 --- /dev/null +++ b/doc/6/controllers/server/admin-exists/snippets/admin-exists.test.yml @@ -0,0 +1,10 @@ +name: server#adminExists +description: Checks that an administrator account exists. +hooks: + before: + after: +template: default +expected: ^(Admin exists\?) (true|false)$ + +sdk: js +version: 6 diff --git a/doc/6/controllers/server/get-all-stats/index.md b/doc/6/controllers/server/get-all-stats/index.md new file mode 100644 index 000000000..a808d44d5 --- /dev/null +++ b/doc/6/controllers/server/get-all-stats/index.md @@ -0,0 +1,46 @@ +--- +code: true +type: page +title: getAllStats +description: Gets all stored internal statistic snapshots. +--- + +# getAllStats + +Gets all stored internal statistic snapshots. +By default, snapshots are made every 10 seconds and they are stored for 1 hour. + +These statistics include: + +- the number of connected users per protocol (not available for all protocols) +- the number of ongoing requests +- the number of completed requests since the last frame +- the number of failed requests since the last frame + +
+ +```js +getAllStats([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing all stored internal statistic snapshots. + +## Usage + +<<< ./snippets/get-all-stats.js diff --git a/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.js b/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.js new file mode 100644 index 000000000..c8448b610 --- /dev/null +++ b/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.js @@ -0,0 +1,7 @@ +try { + const allStats = await kuzzle.server.getAllStats(); + + console.log('All Kuzzle Stats:', JSON.stringify(allStats)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.test.yml b/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.test.yml new file mode 100644 index 000000000..9f3e4c6bf --- /dev/null +++ b/doc/6/controllers/server/get-all-stats/snippets/get-all-stats.test.yml @@ -0,0 +1,10 @@ +name: server#getAllStats +description: Gets all stored internal statistic snapshots. +hooks: + before: + after: +template: default +expected: ^(All Kuzzle Stats:) {"hits":\[({"connections":{.*},"ongoingRequests":{.*},"completedRequests":{}.*},"failedRequests":{.*},"timestamp":[0-9]{13}}(,)*)+\],"total":[0-9]+}$ + +sdk: js +version: 6 diff --git a/doc/6/controllers/server/get-config/index.md b/doc/6/controllers/server/get-config/index.md new file mode 100644 index 000000000..f1820d340 --- /dev/null +++ b/doc/6/controllers/server/get-config/index.md @@ -0,0 +1,42 @@ +--- +code: true +type: page +title: getConfig +description: Returns the current Kuzzle configuration. +--- + +# getConfig + +Returns the current Kuzzle configuration. + +:::warning +This route should only be accessible to administrators, as it might return sensitive information about the backend. +::: + +
+ +```js +getConfig([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing server configuration. + +## Usage + +<<< ./snippets/get-config.js diff --git a/doc/6/controllers/server/get-config/snippets/get-config.js b/doc/6/controllers/server/get-config/snippets/get-config.js new file mode 100644 index 000000000..7a2080fe7 --- /dev/null +++ b/doc/6/controllers/server/get-config/snippets/get-config.js @@ -0,0 +1,7 @@ +try { + const config = await kuzzle.server.getConfig(); + + console.log('Kuzzle Server configuration:', JSON.stringify(config)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/get-config/snippets/get-config.test.yml b/doc/6/controllers/server/get-config/snippets/get-config.test.yml new file mode 100644 index 000000000..9d79d6cfa --- /dev/null +++ b/doc/6/controllers/server/get-config/snippets/get-config.test.yml @@ -0,0 +1,10 @@ +name: server#getConfig +description: Returns the current Kuzzle configuration. +hooks: + before: + after: +template: default +expected: ^(Kuzzle Server configuration:) {("dump":{.*}),("limits":{.*}),("plugins":{.*}),("queues":{.*}),("repositories":{.*}),("server":{.*}),("services":{.*}),("stats":{.*}),("validation":{.*}),("_":.*),("internal":{.*}),("version":"[0-9]\.[0-9]\.[0-9]")}$ + +sdk: js +version: 6 diff --git a/doc/6/controllers/server/get-last-stats/index.md b/doc/6/controllers/server/get-last-stats/index.md new file mode 100644 index 000000000..4b2343fc9 --- /dev/null +++ b/doc/6/controllers/server/get-last-stats/index.md @@ -0,0 +1,47 @@ +--- +code: true +type: page +title: getLastStats +description: Returns the most recent statistics snapshot. +--- + +# getLastStats + +Returns the most recent statistics snapshot. + +By default, snapshots are made every 10 seconds and they are stored for 1 hour. + +These statistics include: + +- the number of connected users per protocol (not available for all protocols) +- the number of ongoing requests +- the number of completed requests since the last frame +- the number of failed requests since the last frame + +
+ +```js +getLastStats([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | no | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing the most recent statistics snapshot. + +## Usage + +<<< ./snippets/get-last-stats.js diff --git a/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.js b/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.js new file mode 100644 index 000000000..1fb9ee1ee --- /dev/null +++ b/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.js @@ -0,0 +1,7 @@ +try { + const lastStat = await kuzzle.server.getLastStats(); + + console.log('Last Kuzzle Stats:', JSON.stringify(lastStat)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.test.yml b/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.test.yml new file mode 100644 index 000000000..0e9b5b000 --- /dev/null +++ b/doc/6/controllers/server/get-last-stats/snippets/get-last-stats.test.yml @@ -0,0 +1,10 @@ +name: server#getLastStats +description: Gets all stored internal statistic snapshots. +hooks: + before: + after: +template: default +expected: ^(Last Kuzzle Stats:) {("connections":{.*}),("ongoingRequests":{.*}),("completedRequests":{.*}),("failedRequests":{.*}),("timestamp":[0-9]{13})}$ + +sdk: js +version: 6 diff --git a/doc/6/controllers/server/get-stats/index.md b/doc/6/controllers/server/get-stats/index.md new file mode 100644 index 000000000..d30996d00 --- /dev/null +++ b/doc/6/controllers/server/get-stats/index.md @@ -0,0 +1,48 @@ +--- +code: true +type: page +title: getStats +description: Returns statistics snapshots within a provided timestamp range. +--- + +# getStats + +Returns statistics snapshots within a provided timestamp range. +By default, snapshots are made every 10 seconds and they are stored for 1 hour. + +These statistics include: + +- the number of connected users per protocol (not available for all protocols) +- the number of ongoing requests +- the number of completed requests since the last frame +- the number of failed requests since the last frame + +
+ +```js +getStats(startTime, stopTime, [options]); +``` + +
+ +| Arguments | Type | Description | +| ----------- | ------------------------- | --------------------------------------------------------------- | +| `startTime` |
number, string
| Begining of statistics frame set (timestamp or datetime format) | +| `stopTime` |
number, string
| End of statistics frame set (timestamp or datetime format) | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing statistics snapshots within the provided range. + +## Usage + +<<< ./snippets/get-stats.js diff --git a/doc/6/controllers/server/get-stats/snippets/get-stats.js b/doc/6/controllers/server/get-stats/snippets/get-stats.js new file mode 100644 index 000000000..d3fb33fb8 --- /dev/null +++ b/doc/6/controllers/server/get-stats/snippets/get-stats.js @@ -0,0 +1,7 @@ +try { + const stats = await kuzzle.server.getStats('1234567890101', '1541426610304'); + + console.log('Kuzzle Stats:', JSON.stringify(stats)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/get-stats/snippets/get-stats.test.yml b/doc/6/controllers/server/get-stats/snippets/get-stats.test.yml new file mode 100644 index 000000000..80affa74d --- /dev/null +++ b/doc/6/controllers/server/get-stats/snippets/get-stats.test.yml @@ -0,0 +1,10 @@ +name: server#getStats +description: Returns statistics snapshots within a provided timestamp range. +hooks: + before: + after: +template: default +expected: ^(Kuzzle Stats:) {"hits":\[({"connections":{.*},"ongoingRequests":{.*},"completedRequests":{}.*},"failedRequests":{.*},"timestamp":[0-9]{13}}(,)*)*\],"total":[0-9]+}$ + +sdk: js +version: 6 diff --git a/doc/6/controllers/server/index.md b/doc/6/controllers/server/index.md new file mode 100644 index 000000000..8db5d1500 --- /dev/null +++ b/doc/6/controllers/server/index.md @@ -0,0 +1,8 @@ +--- +code: true +type: branch +title: server +description: Server Controller +--- + +# Server Controller diff --git a/doc/6/controllers/server/info/index.md b/doc/6/controllers/server/info/index.md new file mode 100644 index 000000000..182f32649 --- /dev/null +++ b/doc/6/controllers/server/info/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: info +description: Returns information about Kuzzle server. +--- + +# info + +Returns information about Kuzzle: available API (base + extended), plugins, external services (Redis, Elasticsearch, ...), servers, etc. + +
+ +```js +info([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to an `object` containing server information. + +## Usage + +<<< ./snippets/info.js diff --git a/doc/6/controllers/server/info/snippets/info.js b/doc/6/controllers/server/info/snippets/info.js new file mode 100644 index 000000000..b59bcbec6 --- /dev/null +++ b/doc/6/controllers/server/info/snippets/info.js @@ -0,0 +1,7 @@ +try { + const serverInfo = await kuzzle.server.info(); + + console.log('Kuzzle Server information:', JSON.stringify(serverInfo)); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/info/snippets/info.test.yml b/doc/6/controllers/server/info/snippets/info.test.yml new file mode 100644 index 000000000..f33e1acc7 --- /dev/null +++ b/doc/6/controllers/server/info/snippets/info.test.yml @@ -0,0 +1,9 @@ +name: server##info +description: Retrieves information about Kuzzle plugins and active services. +hooks: + before: + after: +template: default +expected: "^Kuzzle Server information: {\"serverInfo\":{\"kuzzle\":{\"version\":\"[0-9]\\.[0-9]\\.[0-9]\",\"api\":{.*" +sdk: js +version: 6 diff --git a/doc/6/controllers/server/now/index.md b/doc/6/controllers/server/now/index.md new file mode 100644 index 000000000..9a2ad4777 --- /dev/null +++ b/doc/6/controllers/server/now/index.md @@ -0,0 +1,38 @@ +--- +code: true +type: page +title: now +description: Returns the current server timestamp, in Epoch-millis format. +--- + +# now + +Returns the current server timestamp, in Epoch-millis format. + +
+ +```js +now([options]); +``` + +
+ +| Arguments | Type | Description | +| --------- | ----------------- | ------------- | +| `options` |
object
| Query options | + +### **Options** + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | ---------------------------------------------------------------------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolve + +Resolves to a number representing the current server timestamp in Epoch-millis format. + +## Usage + +<<< ./snippets/now.js diff --git a/doc/6/controllers/server/now/snippets/now.js b/doc/6/controllers/server/now/snippets/now.js new file mode 100644 index 000000000..c1c7665ae --- /dev/null +++ b/doc/6/controllers/server/now/snippets/now.js @@ -0,0 +1,7 @@ +try { + const timestamp = await kuzzle.server.now(); + + console.log('Epoch-millis timestamp:', timestamp); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/controllers/server/now/snippets/now.test.yml b/doc/6/controllers/server/now/snippets/now.test.yml new file mode 100644 index 000000000..342cdd0a3 --- /dev/null +++ b/doc/6/controllers/server/now/snippets/now.test.yml @@ -0,0 +1,10 @@ +name: server#now +description: Fetch the current server timestamp, in Epoch-millis format. +hooks: + before: + after: +template: default +expected: ^(Epoch-millis timestamp:) [0-9]{13}$ + +sdk: js +version: 6 diff --git a/doc/6/core-classes/base-controller/index.md b/doc/6/core-classes/base-controller/index.md new file mode 100644 index 000000000..15b75fbad --- /dev/null +++ b/doc/6/core-classes/base-controller/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: BaseController +description: BaseController object documentation +order: 500 +--- diff --git a/doc/6/core-classes/base-controller/introduction/index.md b/doc/6/core-classes/base-controller/introduction/index.md new file mode 100644 index 000000000..5692b1d71 --- /dev/null +++ b/doc/6/core-classes/base-controller/introduction/index.md @@ -0,0 +1,13 @@ +--- +code: true +type: page +title: Introduction +description: BaseController class +order: 0 +--- + +# BaseController + +Base class for a [custom SDK controller](/sdk/js/6/essentials/extend-sdk/#define-a-custom-sdk-controller). + +Custom SDK controllers have to extend the `BaseController` class to be added with the [Kuzzle.useController](/sdk/js/6/core-classes/kuzzle/use-controller) method. \ No newline at end of file diff --git a/doc/6/core-classes/base-controller/properties/index.md b/doc/6/core-classes/base-controller/properties/index.md new file mode 100644 index 000000000..d12d79117 --- /dev/null +++ b/doc/6/core-classes/base-controller/properties/index.md @@ -0,0 +1,16 @@ +--- +code: true +type: page +title: Properties +description: BaseController Properties +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | --------------------------------------- | +| `name` |
string
| Controller name | +| `kuzzle` | [`Kuzzle`](/sdk/js/6/core-classes/kuzzle/constructor) | Kuzzle SDK instance | + +**Note:** + - The `name` property will be injected in the request sent by the [BaseController.query](/sdk/js/6/core-classes/base-controller/query) method if the `controller` property is not set. \ No newline at end of file diff --git a/doc/6/core-classes/base-controller/query/index.md b/doc/6/core-classes/base-controller/query/index.md new file mode 100644 index 000000000..db26f4c75 --- /dev/null +++ b/doc/6/core-classes/base-controller/query/index.md @@ -0,0 +1,55 @@ +--- +code: true +type: page +title: query +description: Wrapper around the Kuzzle.query method +--- + +# query + +Base method used to send queries to a Kuzzle controller, following the [API Documentation](/core/1/api/essentials/connecting-to-kuzzle). + +This method injects the controller name into the the request and forwards it to the original [Kuzzle.query](/sdk/js/6/core-classes/kuzzle/query) method. + +## Arguments + +```js +query (request, [options]); +``` + +
+ +| Argument | Type | Description | +| -------------- | --------- | ------------- | +| `request` |
object
| API request | +| `options` |
object
| Optional query options | + +### request + +All properties necessary for the Kuzzle API can be added in the request object. +The following properties are the most common. + +| Property | Type | Description | +| -------------- | --------- | ------------- | +| `action` |
string
| Action name (required) | +| `controller` |
string
| Controller name | +| `body` |
object
| Query body for this action | +| `index` |
string
| Index name for this action | +| `collection` |
string
| Collection name for this action | +| `_id` |
string
| id for this action | +| `volatile` |
object
| Additional information to send to Kuzzle | + +**Note:** + - If the `controller` property is not set, the controller [name property](/sdk/js/6/core-classes/base-controller/properties) will be used + +### options + +Additional query options + +| Property | Type
(default) | Description | +| -------------- | --------- | ------------- | +| `queuable` |
boolean

(`true`) | If true, queues the request during downtime, until connected to Kuzzle again | + +## Resolves + +Resolve to the raw Kuzzle API response. See the [API Documentation](/core/1/api/essentials/connecting-to-kuzzle). \ No newline at end of file diff --git a/doc/6/core-classes/index.md b/doc/6/core-classes/index.md new file mode 100644 index 000000000..cb1e2bab9 --- /dev/null +++ b/doc/6/core-classes/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 200 +title: Core Classes +description: Javascript SDK v6.x core classes +--- diff --git a/doc/6/core-classes/kuzzle-error/index.md b/doc/6/core-classes/kuzzle-error/index.md new file mode 100644 index 000000000..5103a1d24 --- /dev/null +++ b/doc/6/core-classes/kuzzle-error/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: KuzzleError +description: KuzzleError object documentation +order: 510 +--- diff --git a/doc/6/core-classes/kuzzle-error/introduction/index.md b/doc/6/core-classes/kuzzle-error/introduction/index.md new file mode 100644 index 000000000..0f86b1a99 --- /dev/null +++ b/doc/6/core-classes/kuzzle-error/introduction/index.md @@ -0,0 +1,13 @@ +--- +code: false +type: page +title: Introduction +description: KuzzleError object +order: 0 +--- + +# KuzzleError + +Inherits from the standard `Error` class. + +The KuzzleError class represents an [error response from Kuzzle API](/core/1/api/essentials/errors/). \ No newline at end of file diff --git a/doc/6/core-classes/kuzzle-error/properties/index.md b/doc/6/core-classes/kuzzle-error/properties/index.md new file mode 100644 index 000000000..1b5655e92 --- /dev/null +++ b/doc/6/core-classes/kuzzle-error/properties/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: Properties +description: KuzzleError Properties +order: 10 +--- + + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | --------------------------------------- | +| `message` |
string
| Error message | +| `status` |
number
| Error status code | +| `stack` |
string
| Error stacktrace (only in development mode) | diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md new file mode 100644 index 000000000..8d673ae28 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-listener/index.md @@ -0,0 +1,32 @@ +--- +code: true +type: page +title: addListener +description: Adds a new listener for an event +--- + +# addListener + +Adds a listener function to the end of the listeners array for an event. +Whenever an event is triggered, listener functions are called in the order they were registered. + +## Arguments + +```js +addListener (eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ---------- | -------- | -------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call every time the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/add-listener.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js new file mode 100644 index 000000000..b98d6e0be --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.js @@ -0,0 +1,6 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent"!')); + +// Prints: Caught event "myEvent"! +eventEmitter.emit('myEvent'); diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml new file mode 100644 index 000000000..32d033093 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-listener/snippets/add-listener.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#add-listener +description: Adds new listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Caught event "myEvent"! +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/index.md new file mode 100644 index 000000000..290e83a51 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/index.md @@ -0,0 +1,33 @@ +--- +code: true +type: page +title: addOnceListener +description: Adds a new listener for an event +--- + +# addOnceListener + +Adds a **one-time** listener function to an event. +The next time the event is triggered, this listener is removed and then invoked. +Whenever an event is triggered, listener functions are called in the order they were registered. + +## Arguments + +```js +addOnceListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | -------------------------------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call when the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/add-once-listener.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js new file mode 100644 index 000000000..2f63326c1 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.js @@ -0,0 +1,11 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addOnceListener( + 'myEvent', + () => console.log('Caught event "myEvent"!')); + +// Prints: Caught event "myEvent"! +eventEmitter.emit('myEvent'); + +// Prints nothing: the event has since been removed +eventEmitter.emit('myEvent'); diff --git a/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml new file mode 100644 index 000000000..fe7b777ac --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/add-once-listener/snippets/add-once-listener.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#add-once-listener +description: Adds new once listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Caught event "myEvent"! +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/emit/index.md b/doc/6/core-classes/kuzzle-event-emitter/emit/index.md new file mode 100644 index 000000000..41b9b4775 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/emit/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: emit +description: Emits an event +--- + +# emit + +Emits an event with the specified payload. + +## Arguments + +```js +emit(eventName, ...payload); +``` + +
+ +| Argument | Type | Description | +| ----------- | ----------------- | --------------------------------- | +| `eventName` |
string
| The name of the event | +| `payload` |
any
| Payload(s) to send with the event | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/emit.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.js b/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.js new file mode 100644 index 000000000..b70bf929b --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.js @@ -0,0 +1,5 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('helloEvent', msg => console.log(`Hello ${msg}`)); + +eventEmitter.emit('helloEvent', 'World'); diff --git a/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml b/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml new file mode 100644 index 000000000..e2dec6f61 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/emit/snippets/emit.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#emit +description: Emits an event +hooks: + before: + after: +template: eventemitter +expected: Hello World +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/index.md b/doc/6/core-classes/kuzzle-event-emitter/index.md new file mode 100644 index 000000000..f7b127318 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: KuzzleEventEmitter +description: KuzzleEventEmitter class documentation +order: 510 +--- diff --git a/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md b/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md new file mode 100644 index 000000000..7e3981199 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/introduction/index.md @@ -0,0 +1,18 @@ +--- +code: false +type: page +title: Introduction +description: KuzzleEventEmitter class +order: 0 +--- + +# KuzzleEventEmitter + +A portable implementation of the Node.js `EventEmitter` interface. + +There are several classes extending `KuzzleEventEmitter` in the SDK: + +- [Kuzzle](/sdk/js/6/core-classes/kuzzle) +- [WebSocket](/sdk/js/6/protocols/websocket) +- [Http](/sdk/js/6/protocols/http) +- [SocketIO](/sdk/js/6/protocols/socketio) diff --git a/doc/6/core-classes/kuzzle-event-emitter/listeners/index.md b/doc/6/core-classes/kuzzle-event-emitter/listeners/index.md new file mode 100644 index 000000000..1455ff4f7 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/listeners/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: listeners +description: Returns listeners for an event +--- + +# listeners + +Returns the listener functions bound to a specific event. + +## Arguments + +```js +listeners(eventName); +``` + +## Return + +An array of listener functions. + +## Usage + +<<< ./snippets/listeners.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js b/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js new file mode 100644 index 000000000..4e5e83699 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.js @@ -0,0 +1,8 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('Hello')); +eventEmitter.addListener('myEvent', () => console.log('Hello World')); + +const listeners = eventEmitter.listeners('myEvent'); + +console.log(`There are ${listeners.length} listeners bound to the event "myEvent"`); diff --git a/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml b/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml new file mode 100644 index 000000000..fe978c60d --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/listeners/snippets/listeners.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#listeners +description: Returns listeners binded to an event +hooks: + before: + after: +template: eventemitter +expected: There are 2 listeners bound to the event "myEvent" +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/on/index.md b/doc/6/core-classes/kuzzle-event-emitter/on/index.md new file mode 100644 index 000000000..2d76aa56c --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/on/index.md @@ -0,0 +1,10 @@ +--- +code: true +type: page +title: on +description: Alias for addListener +--- + +# on + +Alias for [addListener](https://nodejs.org/api/events.html#events_emitter_addlistener_eventname_listener). diff --git a/doc/6/core-classes/kuzzle-event-emitter/once/index.md b/doc/6/core-classes/kuzzle-event-emitter/once/index.md new file mode 100644 index 000000000..ca3e6b4b3 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/once/index.md @@ -0,0 +1,10 @@ +--- +code: true +type: page +title: once +description: Alias for addOnceListener +--- + +# once + +Alias for [addOnceListener](/sdk/js/6/core-classes/kuzzle-event-emitter/add-once-listener/). diff --git a/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/index.md new file mode 100644 index 000000000..a36187191 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: prependListener +description: Prepends a new listener for an event +--- + +# prependListener + +Adds a listener function to the beginning of the listeners array for an event. + +## Arguments + +```js +prependListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | -------------------------------------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call every time the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/prepend-listener.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js new file mode 100644 index 000000000..997536d57 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.js @@ -0,0 +1,10 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('listener1')); + +eventEmitter.prependListener('myEvent', () => console.log('listener2')); + +// Prints: +// listener2 +// listener1 +eventEmitter.emit('myEvent'); diff --git a/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml new file mode 100644 index 000000000..6bb15910b --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/prepend-listener/snippets/prepend-listener.test.yml @@ -0,0 +1,11 @@ +name: kuzzleEventEmitter#prepend-listener +description: Prepends a new listener for the given event +hooks: + before: + after: +template: eventemitter +expected: + - ^listener2$ + - ^listener1$ +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md new file mode 100644 index 000000000..216d7af60 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/index.md @@ -0,0 +1,32 @@ +--- +code: true +type: page +title: prependOnceListener +description: Prepends a new once listener for an event +--- + +# prependOnceListener + +Adds a **one-time** listener function for an event to the beginning of the listeners array. +The next time that event is triggered, this listener is removed, and then invoked. + +## Arguments + +```js +prependOnceListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | -------------------------------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Function to call when the event is triggered | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/prepend-once-listener.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js new file mode 100644 index 000000000..479c42e3c --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.js @@ -0,0 +1,14 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('listener1')); + +eventEmitter.prependOnceListener('myEvent', () => console.log('listener2')); + +// Prints: +// listener2 +// listener1 +eventEmitter.emit('myEvent'); + +// Prints: listener1 +// (the listener function printing "listener2" as since been removed) +eventEmitter.emit('myEvent'); diff --git a/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml new file mode 100644 index 000000000..d329f51ff --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/prepend-once-listener/snippets/prepend-once-listener.test.yml @@ -0,0 +1,12 @@ +name: kuzzleEventEmitter#prepend-once-listener +description: Prepends an once new listener for the given event +hooks: + before: + after: +template: eventemitter +expected: + - ^listener2$ + - ^listener1$ + - ^listener1$ +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/index.md new file mode 100644 index 000000000..4f38ff477 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: removeAllListeners +description: Removes all listener functions, or all listener functions from an event +--- + +# removeAllListeners + +Removes all listener functions from an event. +If no eventName is specified, removes all listener functions from all events. + +## Arguments + +```js +removeAllListeners([eventName]); +``` + +
+ +| Argument | Type | Description | +| ----------- | ----------------- | -------------------------- | +| `eventName` |
string
| Optional name of the event | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/remove-all-listeners.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js new file mode 100644 index 000000000..00154de84 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.js @@ -0,0 +1,18 @@ +const eventEmitter = new KuzzleEventEmitter(); + +eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent" (1)')); +eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent" (2)')); + +// Prints: +// Caught event "myEvent" (1) +// Caught event "myEvent" (2) +eventEmitter.emit('myEvent'); + +eventEmitter.removeAllListeners('myEvent'); + +// Prints nothing: all events have been removed +eventEmitter.emit('myEvent'); + +if (eventEmitter.listeners('myEvent').length === 0) { + console.log('Successfully removed all listeners'); +} diff --git a/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml new file mode 100644 index 000000000..043d330e0 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/remove-all-listener/snippets/remove-all-listeners.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#remove-all-listeners +description: Removes a listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Successfully removed all listeners +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle-event-emitter/remove-listener/index.md b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/index.md new file mode 100644 index 000000000..7b58fc659 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/index.md @@ -0,0 +1,31 @@ +--- +code: true +type: page +title: removeListener +description: Removes a listener function from an event +--- + +# removeListener + +Removes a listener function from an event. + +## Arguments + +```js +removeListener(eventName, callback); +``` + +
+ +| Argument | Type | Description | +| ----------- | ------------------- | --------------------- | +| `eventName` |
string
| The name of the event | +| `callback` |
function
| Callback to remove | + +## Return + +The `KuzzleEventEmitter` instance. + +## Usage + +<<< ./snippets/remove-listener.js diff --git a/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js new file mode 100644 index 000000000..8c7276211 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.js @@ -0,0 +1,13 @@ +const eventEmitter = new KuzzleEventEmitter(); + +const listener = () => console.log('disconnected'); + +eventEmitter + .addListener('disconnected', () => console.log('disconnected')) + .addListener('disconnected', listener); + +eventEmitter.removeListener('disconnected', listener); + +if (eventEmitter.listeners('disconnected').length === 1) { + console.log('Successfully removed the listener'); +} diff --git a/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml new file mode 100644 index 000000000..d50965568 --- /dev/null +++ b/doc/6/core-classes/kuzzle-event-emitter/remove-listener/snippets/remove-listener.test.yml @@ -0,0 +1,9 @@ +name: kuzzleEventEmitter#remove-listener +description: Removes a listener for the given event +hooks: + before: + after: +template: eventemitter +expected: Successfully removed the listener +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/connect/index.md b/doc/6/core-classes/kuzzle/connect/index.md new file mode 100644 index 000000000..ec8404a64 --- /dev/null +++ b/doc/6/core-classes/kuzzle/connect/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: connect +description: Connects the SDK to Kuzzle +--- + +# connect + +Connects to Kuzzle using the `host` property provided in the [constructor options](/sdk/js/6/core-classes/kuzzle/constructor/#arguments). +Subsequent call have no effect if the SDK is already connected. + +## Arguments + +```js +connect(); +``` + +## Resolves + +Resolves if the connection is successful. + +## Usage + +<<< ./snippets/connect.js diff --git a/doc/6/core-classes/kuzzle/connect/snippets/connect.js b/doc/6/core-classes/kuzzle/connect/snippets/connect.js new file mode 100644 index 000000000..6a12ea0c1 --- /dev/null +++ b/doc/6/core-classes/kuzzle/connect/snippets/connect.js @@ -0,0 +1,7 @@ +try { + await kuzzle.connect(); + + console.log('Successfully connected'); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/core-classes/kuzzle/connect/snippets/connect.test.yml b/doc/6/core-classes/kuzzle/connect/snippets/connect.test.yml new file mode 100644 index 000000000..e904c4c4a --- /dev/null +++ b/doc/6/core-classes/kuzzle/connect/snippets/connect.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#connect +description: Connects the SDK to Kuzzle +hooks: + before: + after: +template: without-connect +expected: Successfully connected + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/constructor/index.md b/doc/6/core-classes/kuzzle/constructor/index.md new file mode 100644 index 000000000..618fe9828 --- /dev/null +++ b/doc/6/core-classes/kuzzle/constructor/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: constructor +description: Creates a new Kuzzle object connected to the backend +order: 50 +--- + +# Constructor + +Use this constructor to create a new instance of the SDK. +Each instance represent a different connection to a Kuzzle server with specific options. + +## Arguments + +```js +Kuzzle(protocol, [options]); +``` + +
+ +| Argument | Type | Description | +| ---------- | ------------------- | --------------------------------- | +| `protocol` |
Protocol
| Protocol used by the SDK instance | +| `options` |
object
| Kuzzle object configuration | + +### protocol + +The protocol used to connect to the Kuzzle instance. +It can be one of the following available protocols: + +- [WebSocket](/sdk/js/6/protocols/websocket) +- [Http](/sdk/js/6/protocols/http) +- [SocketIO](/sdk/js/6/protocols/socketio) + +### options + +Kuzzle SDK instance options. + +| Property | Type
(default) | Description | +| ----------------- | -------------------------------- | ------------------------------------------------------------------ | +| `autoQueue` |
boolean

(`false`) | Automatically queue all requests during offline mode | +| `autoReplay` |
boolean

(`false`) | Automatically replay queued requests on a `reconnected` event | +| `autoResubscribe` |
boolean

(`true`) | Automatically renew all subscriptions on a `reconnected` event | +| `eventTimeout` |
number

(`200`) | Time (in ms) during which a similar event is ignored | +| `offlineMode` |
string

(`manual`) | Offline mode configuration. Can be `manual` or `auto` | +| `queueTTL` |
number

(`120000`) | Time a queued request is kept during offline mode, in milliseconds | +| `queueMaxSize` |
number

(`500`) | Number of maximum requests kept during offline mode | +| `replayInterval` |
number

(`10`) | Delay between each replayed requests, in milliseconds | +| `volatile` |
object

(`{}`) | Common volatile data, will be sent to all future requests | + +## Return + +The `Kuzzle` SDK instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/6/core-classes/kuzzle/constructor/snippets/constructor.js b/doc/6/core-classes/kuzzle/constructor/snippets/constructor.js new file mode 100644 index 000000000..f362d01c3 --- /dev/null +++ b/doc/6/core-classes/kuzzle/constructor/snippets/constructor.js @@ -0,0 +1,25 @@ +// Loads the Kuzzle SDK module +const + { + Kuzzle, + WebSocket, + Http + } = require('kuzzle-sdk'); + +const options = { + offlineMode: 'auto', + volatile: { username: 'Gordon' } +}; + +// Instantiates the SDK with the websocket protocol +const + kuzzleWs = new Kuzzle( + new WebSocket('kuzzle'), + options + ); + +// Instantiates the SDK with the http protocol +const + kuzzleHttp = new Kuzzle( + new Http('kuzzle') + ); diff --git a/doc/6/core-classes/kuzzle/constructor/snippets/constructor.test.yml b/doc/6/core-classes/kuzzle/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..2a43f0463 --- /dev/null +++ b/doc/6/core-classes/kuzzle/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: kuzzle#constructor +description: Creates a new Kuzzle instance connected to kuzzle +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/disconnect/index.md b/doc/6/core-classes/kuzzle/disconnect/index.md new file mode 100644 index 000000000..896ab0e0b --- /dev/null +++ b/doc/6/core-classes/kuzzle/disconnect/index.md @@ -0,0 +1,22 @@ +--- +code: true +type: page +title: disconnect +description: Disconnect the SDK +--- + +# disconnect + +Closes the current connection to Kuzzle. +The SDK then enters the `offline` state. +A call to `disconnect()` will not trigger a `disconnected` event. This event is only triggered on unexpected disconnection. + +## Arguments + +```js +disconnect(); +``` + +## Usage + +<<< ./snippets/disconnect.js diff --git a/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.js b/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.js new file mode 100644 index 000000000..e3c9244e6 --- /dev/null +++ b/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.js @@ -0,0 +1,7 @@ +try { + kuzzle.disconnect(); + + console.log('Successfully disconnected'); +} catch (error) { + console.error(error); +} diff --git a/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml b/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml new file mode 100644 index 000000000..275657be6 --- /dev/null +++ b/doc/6/core-classes/kuzzle/disconnect/snippets/disconnect.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#disconnect +description: Disconnects the SDK +hooks: + before: + after: +template: without-connect +expected: Successfully disconnected + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/flush-queue/index.md b/doc/6/core-classes/kuzzle/flush-queue/index.md new file mode 100644 index 000000000..9245cf5f6 --- /dev/null +++ b/doc/6/core-classes/kuzzle/flush-queue/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: flushQueue +description: Empties the offline request queue +--- + +# flushQueue + +Empties the offline request queue without playing it. + +## Arguments + +```js +flushQueue(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/flush-queue.js diff --git a/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.js b/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.js new file mode 100644 index 000000000..1ce69b412 --- /dev/null +++ b/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.js @@ -0,0 +1,7 @@ +try { + kuzzle.flushQueue(); + + console.log('Offline queue flushed'); +} catch (error) { + console.error(error); +} diff --git a/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml b/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml new file mode 100644 index 000000000..704e7e084 --- /dev/null +++ b/doc/6/core-classes/kuzzle/flush-queue/snippets/flush-queue.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#flushQueue +description: Empties the offline request queue +hooks: + before: + after: +template: without-connect +expected: Offline queue flushed + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/index.md b/doc/6/core-classes/kuzzle/index.md new file mode 100644 index 000000000..81ec30a82 --- /dev/null +++ b/doc/6/core-classes/kuzzle/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Kuzzle +description: Kuzzle object documentation +order: 510 +--- diff --git a/doc/6/core-classes/kuzzle/introduction/index.md b/doc/6/core-classes/kuzzle/introduction/index.md new file mode 100644 index 000000000..eeb4b1549 --- /dev/null +++ b/doc/6/core-classes/kuzzle/introduction/index.md @@ -0,0 +1,37 @@ +--- +code: false +type: page +title: Introduction +description: Kuzzle object +order: 0 +--- + +# Kuzzle + +Inherits from: [KuzzleEventEmitter](/sdk/js/6/core-classes/kuzzle-event-emitter). + +The Kuzzle class is the main class of the SDK. +Once instantiated, it represents a connection to your Kuzzle server. + +It gives access to the different features of the SDKs: + +- access to the available controllers +- [SDK events](/sdk/cpp/1/essentials/events) handling +- resilience to connection loss +- network request queue management + +## Network protocol + +Each instance of the class communicates with the Kuzzle server through a class representing a network protocol implementation. + +The following protocols are available in the SDK JS 6: + +- [WebSocket](/sdk/js/6/protocols/websocket) +- [Http](/sdk/js/6/protocols/http) +- [SocketIO](/sdk/js/6/protocols/socketio) + +## Volatile data + +You can tell the Kuzzle SDK to attach a set of "volatile" data to each request. You can set it as an object contained in the `volatile` field of the Kuzzle constructor. The response to a request containing volatile data will contain the same data in its `volatile` field. This can be useful, for example, in real-time notifications for [user join/leave notifications](/core/1/api/essentials/volatile-data/) to provide additional informations about the client who sent the request. + +Note that you can also set volatile data on a per-request basis (on requests that accept a `volatile` field in their `options` argument). In this case, per-request volatile data will be merged with the global `volatile` object set in the constructor. Per-request fields will override global ones. \ No newline at end of file diff --git a/doc/6/core-classes/kuzzle/play-queue/index.md b/doc/6/core-classes/kuzzle/play-queue/index.md new file mode 100644 index 000000000..f614b16ca --- /dev/null +++ b/doc/6/core-classes/kuzzle/play-queue/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: playQueue +description: Play the offline request queue +--- + +# playQueue + +Plays the requests queued during `offline` state. +Works only if the SDK is not in a `offline` state, and if the `autoReplay` option is set to `false`. + +## Arguments + +```js +playQueue(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/play-queue.js diff --git a/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.js b/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.js new file mode 100644 index 000000000..463d99a18 --- /dev/null +++ b/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.js @@ -0,0 +1,7 @@ +try { + kuzzle.playQueue(); + + console.log('Start playing offline queue'); +} catch (error) { + console.error(error); +} diff --git a/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml b/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml new file mode 100644 index 000000000..a3507d292 --- /dev/null +++ b/doc/6/core-classes/kuzzle/play-queue/snippets/play-queue.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#playQueue +description: Play the requests queued +hooks: + before: + after: +template: without-connect +expected: Start playing offline queue + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/properties/index.md b/doc/6/core-classes/kuzzle/properties/index.md new file mode 100644 index 000000000..81006cdec --- /dev/null +++ b/doc/6/core-classes/kuzzle/properties/index.md @@ -0,0 +1,86 @@ +--- +code: false +type: page +title: Properties +description: Kuzzle class properties +order: 10 +--- + +# Read-only properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `authenticated` |
boolean
| Returns `true` if the SDK holds a valid token | +| `connected` |
boolean
| Returns `true` if the SDK is currently connected to a Kuzzle server. | +| `offlineQueue` |
object[]
| Contains the queued requests during offline mode | +| `protocol` |
Protocol
| Protocol used by the SDK | + +### connected + +The `connected` property wraps the underlying protocol `connected` property. +See the associated documentation: + - [Http.connected](/sdk/js/6/protocols/http/properties) + - [WebSocket.connected](/sdk/js/6/protocols/websocket/properties) + - [SocketIO.connected](/sdk/js/6/protocols/socketio/properties) + +# Writable properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoQueue` |
boolean
| If `true`, automatically queues all requests during offline mode | +| `autoReplay` |
boolean
| If `true`, automatically replays queued requests on a `reconnected` event | +| `autoResubscribe` |
boolean
| If `true`, automatically renews all subscriptions on a `reconnected` event | +| `jwt` |
string
| Authentication token | +| `offlineQueueLoader` |
function
| Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue | +| `queueFilter` |
function
| Custom function called during offline mode to filter queued requests on-the-fly | +| `queueMaxSize` |
number
| Number of maximum requests kept during offline mode| +| `queueTTL` |
number
| Time a queued request is kept during offline mode, in milliseconds | +| `replayInterval` |
number
| Delay between each replayed requests | +| `volatile` |
object
| Common volatile data, will be sent to all future requests | + +### offlineQueueLoader + +The `offlineQueueLoader` property must be set with a function of one of the following formats: + +```js +Object[] offlineQueueLoader() + +Promise offlineQueueLoader() +``` + +The returned (or resolved) array must contain objects, each with the following properties: + +| Property | Type | Description | +|---|---|---| +| `query` |
object
| Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format | +| `reject` |
function
| A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function | +| `resolve` |
function
| A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function | + +### queueFilter + +The `queueFilter` property must be set with a function of the following form: + +```js +boolean queueFilter(request) +``` + +The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format. + +### queueMaxSize + +This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue. + +This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests. + +If `queueMaxSize` is set to a number lower than, or equal to `0`, then an unlimited number of requests is kept in the offline buffer. +Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory. + +### queueTTL + +If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely. + +### volatile + +Multiple methods allow passing specific `volatile` data. + +These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones. diff --git a/doc/6/core-classes/kuzzle/query/index.md b/doc/6/core-classes/kuzzle/query/index.md new file mode 100644 index 000000000..be63f82a0 --- /dev/null +++ b/doc/6/core-classes/kuzzle/query/index.md @@ -0,0 +1,58 @@ +--- +code: true +type: page +title: query +description: Base method to send API query to Kuzzle +--- + +# query + +Base method used to send queries to Kuzzle, following the [API Documentation](/core/1/api). + +:::warning +This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods. +::: + +## Arguments + +```js +query(request, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------- | +| `request` |
object
| API request | +| `options` |
object
| Optional query options | + +### request + +All properties necessary for the Kuzzle API can be added in the request object. +The following properties are the most common. + +| Property | Type | Description | +| ------------ | ----------------- | ---------------------------------------- | +| `controller` |
string
| Controller name (mandatory) | +| `action` |
string
| Action name (mandatory) | +| `body` |
object
| Query body for this action | +| `index` |
string
| Index name for this action | +| `collection` |
string
| Collection name for this action | +| `_id` |
string
| id for this action | +| `volatile` |
object
| Additional information to send to Kuzzle | + +### options + +Additional query options + +| Property | Type
(default) | Description | +| ---------- | ------------------------------- | --------------------------------- | +| `queuable` |
boolean

(`true`) | Make this request queuable or not | + +## Resolves + +Resolve to the raw Kuzzle API response. See the [API Documentation](/core/1/api). + +## Usage + +<<< ./snippets/query.js diff --git a/doc/6/core-classes/kuzzle/query/snippets/query.js b/doc/6/core-classes/kuzzle/query/snippets/query.js new file mode 100644 index 000000000..e06d967f5 --- /dev/null +++ b/doc/6/core-classes/kuzzle/query/snippets/query.js @@ -0,0 +1,50 @@ +const request = { + controller: 'document', + action: 'create', + index: 'nyc-open-data', + collection: 'yellow-taxi', + _id: 'my-custom-document-id', + refresh: 'wait_for', // Additional property allowed for this API action + body: { + trip_distance: 4.23, + passenger_count: 2 + } +}; + +try { + const response = await kuzzle.query(request); + console.log(response); + /* + { requestId: '49ffb6db-bdff-45b9-b3f6-00442f472393', + status: 200, + error: null, + controller: 'document', + action: 'create', + collection: 'yellow-taxi', + index: 'nyc-open-data', + volatile: { sdkVersion: '6.0.0-beta-2' }, + room: '49ffb6db-bdff-45b9-b3f6-00442f472393', + result: + { _index: 'nyc-open-data', + _type: 'yellow-taxi', + _id: 'my-custom-document-id', + _version: 1, + result: 'created', + _shards: { total: 2, successful: 1, failed: 0 }, + created: true, + _source: + { trip_distance: 4.23, + passenger_count: 2, + _kuzzle_info: + { author: '-1', + createdAt: 1532529302225, + updatedAt: null, + updater: null, + active: true, + deletedAt: null } } } } + */ + + console.log('Document created'); +} catch (error) { + console.error(error); +} diff --git a/doc/6/core-classes/kuzzle/query/snippets/query.test.yml b/doc/6/core-classes/kuzzle/query/snippets/query.test.yml new file mode 100644 index 000000000..0b5358454 --- /dev/null +++ b/doc/6/core-classes/kuzzle/query/snippets/query.test.yml @@ -0,0 +1,14 @@ +--- +name: kuzzle#query +description: Sends a request to Kuzzle API +hooks: + before: | + curl -X POST kuzzle:7512/nyc-open-data/_create + curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi + curl -X DELETE kuzzle:7512/nyc-open-data/yellow-taxi/my-custom-document-id + after: +template: default +expected: Document created + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/start-queuing/index.md b/doc/6/core-classes/kuzzle/start-queuing/index.md new file mode 100644 index 000000000..bc6899895 --- /dev/null +++ b/doc/6/core-classes/kuzzle/start-queuing/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: startQueuing +description: Starts the requests queuing +--- + +# startQueuing + +Starts the requests queuing. +Works only in `offline` state, and if the `autoQueue` option is set to false. + +## Arguments + +```js +startQueuing(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/start-queuing.js diff --git a/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.js b/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.js new file mode 100644 index 000000000..787e2518b --- /dev/null +++ b/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.js @@ -0,0 +1,7 @@ +try { + kuzzle.startQueuing(); + + console.log('Start queuing requests'); +} catch (error) { + console.error(error); +} diff --git a/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml b/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml new file mode 100644 index 000000000..914f4ac01 --- /dev/null +++ b/doc/6/core-classes/kuzzle/start-queuing/snippets/start-queuing.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#startQueuing +description: Starts the requests queuing +hooks: + before: + after: +template: without-connect +expected: Start queuing requests + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/stop-queuing/index.md b/doc/6/core-classes/kuzzle/stop-queuing/index.md new file mode 100644 index 000000000..1cdb49faf --- /dev/null +++ b/doc/6/core-classes/kuzzle/stop-queuing/index.md @@ -0,0 +1,25 @@ +--- +code: true +type: page +title: stopQueuing +description: Stops the requests queuing +--- + +# stopQueuing + +Stops the requests queuing. +Works only in `offline` state, and if the `autoQueue` option is set to false. + +## Arguments + +```js +stopQueuing(); +``` + +## Return + +The `Kuzzle` instance. + +## Usage + +<<< ./snippets/stop-queuing.js diff --git a/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js b/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js new file mode 100644 index 000000000..782278ef6 --- /dev/null +++ b/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.js @@ -0,0 +1,7 @@ +try { + kuzzle.stopQueuing(); + + console.log('Stop queuing requests'); +} catch (error) { + console.error(error); +} diff --git a/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml b/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml new file mode 100644 index 000000000..d0709b139 --- /dev/null +++ b/doc/6/core-classes/kuzzle/stop-queuing/snippets/stop-queuing.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#stopQueuing +description: Stops the requests queuing +hooks: + before: + after: +template: without-connect +expected: Stop queuing requests + +sdk: js +version: 6 diff --git a/doc/6/core-classes/kuzzle/use-controller/index.md b/doc/6/core-classes/kuzzle/use-controller/index.md new file mode 100644 index 000000000..e5fcbd2a0 --- /dev/null +++ b/doc/6/core-classes/kuzzle/use-controller/index.md @@ -0,0 +1,34 @@ +--- +code: true +type: page +title: useController +description: Adds a new controller to the SDK +--- + +# useController + +Adds a new controller to the SDK. + +*See also:* + - *[Extend the SDK](/sdk/js/6/essentials/extend-sdk)* + +## Arguments + +```js +useController (ControllerClass, accessor); +``` + +
+ +| Argument | Type | Description | +| -------------- | --------- | ------------- | +| `ControllerClass` |
Class
| Controller class. Must inherit from [BaseController](/sdk/js/6/core-classes/base-controller) | +| `accessor` |
string
| Accessor name for the controller in the Kuzzle object | + +## Returns + +Returns the Kuzzle object. + +## Usage + +<<< ./snippets/use-controller.js \ No newline at end of file diff --git a/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js new file mode 100644 index 000000000..c63c4f286 --- /dev/null +++ b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.js @@ -0,0 +1,35 @@ +class TaxiController extends BaseController { + constructor (kuzzle) { + super(kuzzle, 'my-plugin/taxi'); + } + + enroll () { + return this.query({ + action: 'enroll' + }); + } +} + +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Add the custom SDK controller +kuzzle.useController(TaxiController, 'taxi'); + +const run = async () => { + try { + await kuzzle.connect(); + + // Call the custom SDK controller action + console.log(await kuzzle.taxi.enroll()); + + console.log('Success'); + } catch (error) { + console.error(error); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml new file mode 100644 index 000000000..f16fbf941 --- /dev/null +++ b/doc/6/core-classes/kuzzle/use-controller/snippets/use-controller.test.yml @@ -0,0 +1,11 @@ +--- +name: kuzzle#useController +description: Adds a new controller to the SDK +hooks: + before: + after: +template: controller +expected: Success + +sdk: js +version: 6 \ No newline at end of file diff --git a/doc/6/core-classes/profile/getRoles/index.md b/doc/6/core-classes/profile/getRoles/index.md new file mode 100644 index 000000000..b0457e1ba --- /dev/null +++ b/doc/6/core-classes/profile/getRoles/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: getRoles +description: Profile getRoles method +--- + +# getRoles + +Loads information about the profile roles. + +## Arguments + +```js +getRoles(); +``` + +## Resolve + +Resolves to an array of [Role](/sdk/js/6/core-classes/role/). + +## Usage + +<<< ./snippets/getRoles.js diff --git a/doc/6/core-classes/profile/getRoles/snippets/getRoles.js b/doc/6/core-classes/profile/getRoles/snippets/getRoles.js new file mode 100644 index 000000000..5ded07431 --- /dev/null +++ b/doc/6/core-classes/profile/getRoles/snippets/getRoles.js @@ -0,0 +1,28 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.getCurrentUser(); + + const profiles = await user.getProfiles(); + + const roles = await profiles[0].getRoles(); + console.log(roles); + /* + [ + Role { + _id: 'default', + controllers: { + '*': { + actions: { + '*': true + } + } + } + } + ] + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/core-classes/profile/getRoles/snippets/getRoles.test.yml b/doc/6/core-classes/profile/getRoles/snippets/getRoles.test.yml new file mode 100644 index 000000000..0ddd2c4b4 --- /dev/null +++ b/doc/6/core-classes/profile/getRoles/snippets/getRoles.test.yml @@ -0,0 +1,12 @@ +name: user#getRoles +description: Loads informations about user roles +hooks: + before: | + curl -X DELETE kuzzle:7512/users/foo + curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: +template: default +expected: + - Profile { _id: \'default\' +sdk: js +version: 6 diff --git a/doc/6/core-classes/profile/index.md b/doc/6/core-classes/profile/index.md new file mode 100644 index 000000000..ba2bda51a --- /dev/null +++ b/doc/6/core-classes/profile/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Profile +description: Profile class documentation +order: 510 +--- diff --git a/doc/6/core-classes/profile/introduction/index.md b/doc/6/core-classes/profile/introduction/index.md new file mode 100644 index 000000000..783f3a717 --- /dev/null +++ b/doc/6/core-classes/profile/introduction/index.md @@ -0,0 +1,13 @@ +--- +code: false +type: page +title: Introduction +description: Profile class +order: 0 +--- + +# Profile + +This class represents a Kuzzle Profile. + +Refer to the [Security guide](/core/1/guides/essentials/security/#defining-profiles) for more information about profiles. diff --git a/doc/6/core-classes/profile/properties/index.md b/doc/6/core-classes/profile/properties/index.md new file mode 100644 index 000000000..c6dddc9eb --- /dev/null +++ b/doc/6/core-classes/profile/properties/index.md @@ -0,0 +1,23 @@ +--- +code: false +type: page +title: Properties +description: Profile Properties +order: 10 +--- + +# Properties + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Profile ID | +| `policies` |
object[]
| Array of policies for this profile | + +### policies + +Each policy object can contain the following properties: + +| Property | Type | Description | +|--- |--- |--- | +| `roleId` |
string
| Roles IDs for this user | +| `restrictedTo` |
object[]
| Array of object containing indexes and collections which the profile is restricted to | diff --git a/doc/6/core-classes/role/index.md b/doc/6/core-classes/role/index.md new file mode 100644 index 000000000..25fb73bea --- /dev/null +++ b/doc/6/core-classes/role/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Role +description: Role class documentation +order: 510 +--- diff --git a/doc/6/core-classes/role/introduction/index.md b/doc/6/core-classes/role/introduction/index.md new file mode 100644 index 000000000..f1748eade --- /dev/null +++ b/doc/6/core-classes/role/introduction/index.md @@ -0,0 +1,13 @@ +--- +code: false +type: page +title: Introduction +description: Role class +order: 0 +--- + +# Role + +This class represents a Kuzzle Role. + +Refer to the [Security guide](/core/1/guides/essentials/security/#defining-roles) for more information about roles. \ No newline at end of file diff --git a/doc/6/core-classes/role/properties/index.md b/doc/6/core-classes/role/properties/index.md new file mode 100644 index 000000000..c3fe42c7c --- /dev/null +++ b/doc/6/core-classes/role/properties/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: Properties +description: Role class properties +order: 10 +--- + +# Properties + +Available properties: + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Role unique identifier | +| `controllers` |
object
| Object defining controller actions allowed by this role | diff --git a/doc/6/core-classes/search-result/index.md b/doc/6/core-classes/search-result/index.md new file mode 100644 index 000000000..5e822dcbe --- /dev/null +++ b/doc/6/core-classes/search-result/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: SearchResult +description: SearchResult class documentation +order: 510 +--- diff --git a/doc/6/core-classes/search-result/introduction/index.md b/doc/6/core-classes/search-result/introduction/index.md new file mode 100644 index 000000000..5690ee10d --- /dev/null +++ b/doc/6/core-classes/search-result/introduction/index.md @@ -0,0 +1,15 @@ +--- +code: false +type: page +title: Introduction +description: SearchResult class +order: 0 +--- + +# SearchResult + +The class is used to retrieve the subsequent paginated results of a search query. +The following methods returns a `SearchResult`: + +- [document:search](/sdk/js/6/controllers/document/search) +- [collection:searchSpecifications](/sdk/js/6/controllers/collection/search-specifications) diff --git a/doc/6/core-classes/search-result/next/index.md b/doc/6/core-classes/search-result/next/index.md new file mode 100644 index 000000000..ace94e5da --- /dev/null +++ b/doc/6/core-classes/search-result/next/index.md @@ -0,0 +1,63 @@ +--- +code: true +type: page +title: next +description: SearchResult next method +order: 200 +--- + +# SearchResult + +Returns a new `SearchResult` object which contain the subsequent results of the search. + +## Arguments + +```js +next(); +``` + +## Behaviour of the next method + +In order to be able to compute the next search page, some initial conditions must be met. + +Depending on the arguments given to the initial search, thhe `next` method will pick one of the following policies, by decreasing order of priority (i.e. a search including a `scroll`, `sort` and `size` will use the `scroll` policy). + +If no policy is applicable, the `next` method will throw an exception. + +:::info +When processing a large number of documents (i.e. more than 1000), it is advised to use a scroll cursor. + +It is also the only method guaranteeing that all matching documents will be retrieved and no duplicates will be included. +::: + +## Usage with scroll + +**This is the preferred way to get some paginated results**. + +If the original search is given a `scroll` parameter, the `next` method will use a cursor to paginate results. + +The results that are returned from a scroll request reflect the state of the index at the time the initial `search` request was performed, like a snapshot in time. + +As such, even if some documents are added or deleted from the database between two calls to `next`, the result is garanteed to include all items matching the query at the time the initial `search` was sent and to not get any duplicate between two search pages. + +<<< ./snippets/scroll.js + +## Usage with sort / size + +If the initial search is given some `sort` and `size` parameters, the `next` method will retrieve the next items matching the sort. + +To avoid too many duplicates, it is advised to provide a sort combination that will always identify one item only. The recommended way is to use the field `_uid` which is certain to contain one unique value for each document. + +Because this method does not freeze the research between two calls, if some updates are applied to the database between two calls, it is still possible to miss some documents and/or to get some duplicates between search pages. + +## Usage with from / size + +If the initial search is given some `from` and `size` parameters, the `next` method will increment the `from` parameter to retrieved the next results. + +Because this method does not freeze the research between two calls, if some updates are applied to the database between two calls, it is possible to miss some documents and/or to get some duplicates between search pages. + +:::info +It is not possible to retrieve more than 10000 items using this method. Above that limit, any call to `next` will throw an Exception. +::: + +<<< ./snippets/fromsize.js diff --git a/doc/6/core-classes/search-result/next/snippets/fromsize.js b/doc/6/core-classes/search-result/next/snippets/fromsize.js new file mode 100644 index 000000000..74fb61abe --- /dev/null +++ b/doc/6/core-classes/search-result/next/snippets/fromsize.js @@ -0,0 +1,69 @@ +const suv = { category: 'suv' }; + +try { + const requests = []; + + for (let i = 0; i < 10; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); + } + + await Promise.all(requests); + + // Waits documents to be indexed + await kuzzle.index.refresh('nyc-open-data'); + + const searchOptions = { + from: 1, + size: 5 + }; + + const results = await kuzzle.document.search( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + category: 'suv' + } + } + }, + searchOptions + ); + + const nextResults = await results.next(); + + console.log(`Successfully retrieved ${nextResults.fetched} documents`); + console.log(nextResults); + /* + { + "aggregations": undefined, + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "AWgi6A1POQUM6ucJ3q06", + "_score": 0.046520017, + "_source": { + "category": "suv", + "_kuzzle_info": { + "author": "-1", + "createdAt": 1546773859655, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + ... + ] + }, + "total": 10, + "fetched": 10, + "scroll_id": undefined, + "from": 1, + "size": 5 + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/core-classes/search-result/next/snippets/fromsize.test.yml b/doc/6/core-classes/search-result/next/snippets/fromsize.test.yml new file mode 100644 index 000000000..b23305a90 --- /dev/null +++ b/doc/6/core-classes/search-result/next/snippets/fromsize.test.yml @@ -0,0 +1,13 @@ +name: searchresult#fromsize +description: Next method with from/size +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully retrieved 10 documents +sdk: js +version: 6 diff --git a/doc/6/core-classes/search-result/next/snippets/scroll.js b/doc/6/core-classes/search-result/next/snippets/scroll.js new file mode 100644 index 000000000..c2e4f83ac --- /dev/null +++ b/doc/6/core-classes/search-result/next/snippets/scroll.js @@ -0,0 +1,74 @@ +const suv = { category: 'suv' }; + +try { + const requests = []; + + for (let i = 0; i < 10; i++) { + requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); + } + + await Promise.all(requests); + + // Waits documents to be indexed + await kuzzle.index.refresh('nyc-open-data'); + + const searchOptions = { + scroll: '1m', + size: 5 + }; + + let results = await kuzzle.document.search( + 'nyc-open-data', + 'yellow-taxi', + { + query: { + match: { + category: 'suv' + } + } + }, + searchOptions + ); + + // Fetch the next fetch results and push them into the 'documents' array + const documents = []; + + while (results) { + results.hits.forEach(hit => documents.push(hit._source)); + results = await results.next(); + } + + console.log(results); + /* + { + "aggregations": undefined, + "hits": [ + { + "_index": "nyc-open-data", + "_type": "yellow-taxi", + "_id": "AWgi6A1POQUM6ucJ3q06", + "_score": 0.046520017, + "_source": { + "category": "suv", + "_kuzzle_info": { + "author": "-1", + "createdAt": 1546773859655, + "updatedAt": null, + "updater": null, + "active": true, + "deletedAt": null + } + } + }, + ... + ] + }, + "total": 10, + "fetched": 10, + "scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAAqFnQ5NU9sZWFaUTRhd2VHNU5KZzVEQ" + */ + + console.log(`Successfully retrieved ${documents.length} documents`); +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/core-classes/search-result/next/snippets/scroll.test.yml b/doc/6/core-classes/search-result/next/snippets/scroll.test.yml new file mode 100644 index 000000000..6daa0f360 --- /dev/null +++ b/doc/6/core-classes/search-result/next/snippets/scroll.test.yml @@ -0,0 +1,13 @@ +name: searchresult#scroll +description: Next method with scroll +hooks: + before: | + curl -XDELETE kuzzle:7512/nyc-open-data + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: | + curl -XDELETE kuzzle:7512/nyc-open-data +template: default +expected: Successfully retrieved 10 documents +sdk: js +version: 6 diff --git a/doc/6/core-classes/search-result/properties/index.md b/doc/6/core-classes/search-result/properties/index.md new file mode 100644 index 000000000..d2cddde51 --- /dev/null +++ b/doc/6/core-classes/search-result/properties/index.md @@ -0,0 +1,27 @@ +--- +code: false +type: page +title: Properties +description: SearchResult class properties +order: 100 +--- + +# Properties + +| Property | Type | Description | +|--- |--- |--- | +| `aggregations` |
object
| Search aggregations if any | +| `hits` |
object[]
| Array containing the retrieved items for the current page | +| `total` |
number
| Total number of items matching the given query in Kuzzle database | +| `fetched` |
number
| Number of retrieved items so far | +| `scroll_id` |
string
| Scroll identifier if the search was given a `scroll` parameter | + +### hits + +Each object of the `hits` array contain the following properties: + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Document ID | +| `_score` |
number
| [Relevance score](https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html) | +| `_source` |
object
| Document content | diff --git a/doc/6/core-classes/user/getProfiles/index.md b/doc/6/core-classes/user/getProfiles/index.md new file mode 100644 index 000000000..87a9895ee --- /dev/null +++ b/doc/6/core-classes/user/getProfiles/index.md @@ -0,0 +1,24 @@ +--- +code: true +type: page +title: getProfiles +description: User getProfiles method +--- + +# getProfiles + +Loads information about the user profiles. + +## Arguments + +```js +getProfiles(); +``` + +## Resolve + +Resolves to an array of [Profile](/sdk/js/6/core-classes/profile). + +## Usage + +<<< ./snippets/getProfiles.js diff --git a/doc/6/core-classes/user/getProfiles/snippets/getProfiles.js b/doc/6/core-classes/user/getProfiles/snippets/getProfiles.js new file mode 100644 index 000000000..e21000022 --- /dev/null +++ b/doc/6/core-classes/user/getProfiles/snippets/getProfiles.js @@ -0,0 +1,24 @@ +const credentials = { username: 'foo', password: 'bar' }; + +try { + await kuzzle.auth.login('local', credentials); + + const user = await kuzzle.auth.getCurrentUser(); + + const profiles = await user.getProfiles(); + console.log(profiles); + /* + [ + Profile { + _id: 'default', + policies: [ + { + roleId: 'default' + } + ] + } + ] + */ +} catch (error) { + console.error(error.message); +} diff --git a/doc/6/core-classes/user/getProfiles/snippets/getProfiles.test.yml b/doc/6/core-classes/user/getProfiles/snippets/getProfiles.test.yml new file mode 100644 index 000000000..f23afa975 --- /dev/null +++ b/doc/6/core-classes/user/getProfiles/snippets/getProfiles.test.yml @@ -0,0 +1,12 @@ +name: user#getProfiles +description: Loads informations about user profiles +hooks: + before: | + curl -X DELETE kuzzle:7512/users/foo + curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}' + after: +template: default +expected: + - Role { _id: \'default\' +sdk: js +version: 6 diff --git a/doc/6/core-classes/user/index.md b/doc/6/core-classes/user/index.md new file mode 100644 index 000000000..f5b765f27 --- /dev/null +++ b/doc/6/core-classes/user/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: User +description: User class documentation +order: 510 +--- diff --git a/doc/6/core-classes/user/introduction/index.md b/doc/6/core-classes/user/introduction/index.md new file mode 100644 index 000000000..5bc9f6142 --- /dev/null +++ b/doc/6/core-classes/user/introduction/index.md @@ -0,0 +1,18 @@ +--- +code: false +type: page +title: Introduction +description: User class +order: 0 +--- + +# User + +This class represents a Kuzzle User. + +Refer to the [Security guide](/core/1/guides/essentials/security/) for more information about users. + +The following methods return a `User` object: + +- [auth:getCurrentUser](/sdk/js/6/controllers/auth/get-current-user) +- [auth:updateSelf](/sdk/js/6/controllers/auth/update-self) diff --git a/doc/6/core-classes/user/properties/index.md b/doc/6/core-classes/user/properties/index.md new file mode 100644 index 000000000..f1995aa86 --- /dev/null +++ b/doc/6/core-classes/user/properties/index.md @@ -0,0 +1,24 @@ +--- +code: false +type: page +title: Properties +description: User class properties +order: 10 +--- + +# Properties + + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| User ID (kuid) | +| `content` |
object
| User internal content | + +### content + +The `content` property is an object containing, alongside custom defined values, the following generic properties: + +| Property | Type | Description | +|--- |--- |--- | +| `profileIds` |
string[]
| Profiles IDs for this user | +| `_kuzzle_info` |
object
| [Kuzzle metadata](/core/1/guides/essentials/document-metadata/) | diff --git a/doc/6/essentials/error-handling/index.md b/doc/6/essentials/error-handling/index.md new file mode 100644 index 000000000..31249dc23 --- /dev/null +++ b/doc/6/essentials/error-handling/index.md @@ -0,0 +1,28 @@ +--- +code: false +type: page +title: Error Handling +description: How to handle errors with the SDK +order: 100 +--- + +# Error Handling + +All SDK methods return a promise, that can be rejected with a `KuzzleError` value in case of failure. + +[KuzzleError](/sdk/js/6/core-classes/kuzzle-error/introduction/) objects inherit the standard `Error` object, and add the following properties to it: + +| Property | Type | Description | +| -------- | ----------------- | ------------------------------------------------------------------------------------------ | +| `status` |
number
| Status following [HTTP Standards](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) | +| `stack` |
string
| Error stacktrace (Only in development mode) | + +You can find a detailed list of possible errors messages and statuses in the [documentation API](/core/1/api/essentials/errors). + +#### Example with a promise chain + +<<< ./snippets/error-handling.js + +#### Example with async/await + +<<< ./snippets/error-handling-async.js diff --git a/doc/6/essentials/error-handling/snippets/error-handling-async.js b/doc/6/essentials/error-handling/snippets/error-handling-async.js new file mode 100644 index 000000000..7ad0589e0 --- /dev/null +++ b/doc/6/essentials/error-handling/snippets/error-handling-async.js @@ -0,0 +1,8 @@ +try { + await kuzzle.index.create('nyc-open-data'); +} catch (error) { + if (error.status === 400) { + console.log(error.message); + console.log('Try with another name!'); + } +} diff --git a/doc/6/essentials/error-handling/snippets/error-handling-async.test.yml b/doc/6/essentials/error-handling/snippets/error-handling-async.test.yml new file mode 100644 index 000000000..8473fa704 --- /dev/null +++ b/doc/6/essentials/error-handling/snippets/error-handling-async.test.yml @@ -0,0 +1,10 @@ +name: essentials#errorHandlingAsync +description: How to handle errors with the SDK +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: default +expected: Try with another name! + +sdk: js +version: 6 diff --git a/doc/6/essentials/error-handling/snippets/error-handling.js b/doc/6/essentials/error-handling/snippets/error-handling.js new file mode 100644 index 000000000..3cde31af5 --- /dev/null +++ b/doc/6/essentials/error-handling/snippets/error-handling.js @@ -0,0 +1,8 @@ +kuzzle.index.create('nyc-open-data') + .then(() => 'do something') + .catch(error => { + if (error.status === 400) { + console.log(error.message); + console.log('Try with another name!'); + } + }); diff --git a/doc/6/essentials/error-handling/snippets/error-handling.test.yml b/doc/6/essentials/error-handling/snippets/error-handling.test.yml new file mode 100644 index 000000000..948f43353 --- /dev/null +++ b/doc/6/essentials/error-handling/snippets/error-handling.test.yml @@ -0,0 +1,10 @@ +name: essentials#errorHandling +description: How to handle errors with the SDK +hooks: + before: curl -X POST kuzzle:7512/nyc-open-data/_create + after: +template: thencatch +expected: Try with another name! + +sdk: js +version: 6 diff --git a/doc/6/essentials/events/index.md b/doc/6/essentials/events/index.md new file mode 100644 index 000000000..de31b9dda --- /dev/null +++ b/doc/6/essentials/events/index.md @@ -0,0 +1,101 @@ +--- +code: false +type: page +title: Events +description: SDK events system +order: 200 +--- + +# Events + +An event system allows to be notified when the SDK status changes. These events are issued by the [Kuzzle](/sdk/js/6/core-classes/kuzzle) SDK object. + +The API for interacting with events is described by our [KuzzleEventEmitter](/sdk/js/6/core-classes/kuzzle-event-emitter) class documentation. + +**Note:** listeners are called in the order of their insertion. + +# Emitted Events + +## connected + +Triggered when the SDK has successfully connected to Kuzzle. + +## discarded + +Triggered when Kuzzle discards a request, typically if no connection is established and the request is not queuable, either because the offline mode is not set or if set explicitely. + +**Callback arguments:** + +`@param {object} request`: the discarded [request](/core/1/api/essentials/query-syntax/) + +## disconnected + +Triggered when the current session has been unexpectedly disconnected. + +## loginAttempt + +Triggered when a login attempt completes, either with a success or a failure result. + +**Callback arguments:** + +`@param {object} data` + +| Property | Type | Description | +| --------- | ------------------ | --------------------------------- | +| `success` |
boolean
| Indicate if login attempt succeed | +| `error` |
string
| Error message when login fail | + +## networkError + +Triggered when the SDK has failed to connect to Kuzzle. + +**Callback arguments:** + +`@param {Error} error` + +| Property | Type | Description | +| --------- | ----------------- | ---------------------------------- | +| `message` |
string
| Error description | +| `status` |
number
| Error code | +| `stack` |
string
| Stacktrace (development mode only) | + +## offlineQueuePop + +Triggered whenever a request is removed from the offline queue. + +**Callback arguments:** + +`@param {object} request`: the [request](/core/1/api/essentials/query-syntax/) removed from the queue + +## offlineQueuePush + +Triggered whenever a request is added to the offline queue. + +**Callback arguments:** + +`@param {object} data` + +| Property | Type | Description | +| --------- | ----------------- | ------------------------------------------------------------------ | +| `request` |
object
| [Request](/core/1/api/essentials/query-syntax/) added to the queue | + +## queryError + +Triggered whenever Kuzzle responds with an error + +**Callback arguments:** + +`@param {object} data` + +| Property | Type | Description | +| --------- | ----------------- | ----------------------------- | +| `request` |
object
| Request that causing an error | +| `error` |
Error
| Error details | + +## reconnected + +Triggered when the current session has reconnected to Kuzzle after a disconnection, and only if `autoReconnect` is set to `true`. + +## tokenExpired + +Triggered when Kuzzle rejects a request because the authentication token has expired. diff --git a/doc/6/essentials/extend-sdk/index.md b/doc/6/essentials/extend-sdk/index.md new file mode 100644 index 000000000..df7387ec8 --- /dev/null +++ b/doc/6/essentials/extend-sdk/index.md @@ -0,0 +1,102 @@ +--- +code: false +type: page +title: Extends the SDK +description: Extend the SDK +order: 410 +--- + +# Extend the SDK with a custom SDK controller + + + +It is possible to extend the SDK's API by adding new controllers. + +These controllers correspond to [custom controllers created in a plugin](/core/1/plugins/guides/controllers). Thus, it is possible to use the actions of a core plugin in the SDK in the same way as the other actions of the Kuzzle API. + +## Define a custom SDK controller + +A custom SDK controller is a class inheriting from the [BaseController](/sdk/js/6/core-classes/base-controller) class and defining methods matching Kuzzle API actions. + +This base class is exposed alongside the other classes of the SDK module. + +After defining your new controller based on `BaseController`, you can add it to the SDK with the [Kuzzle.useController](/sdk/js/6/core-classes/kuzzle/use-controller) method. + +## Constructor + +The constructor of a custom SDK controller will be called by passing the SDK instance to it. It must call the parent constructor with this instance of the SDK and its name as defined in the API. + +For instance, if there is a plugin named `nyc-open-data-plugin`, extending Kuzzle's API with the following controller: + +```js +this.controllers = { + taxi: { + startDuty: request => this.startDuty(request) + } +} +``` + +Then the constructor of the custom SDK controller must specify its name as follows (see [how to query a custom API route](/core/1/plugins/guides/controllers/#querying-plugins-controllers) documentation): + +```js +const { BaseController } = require('kuzzle-sdk'); + +class TaxiController extends BaseController { + constructor (kuzzle) { + super(kuzzle, 'nyc-open-data-plugin/taxi'); + } +} +``` + +The controller name will then be injected into the requests sent with the [BaseController.query](/sdk/js/6/core-classes/base-controller/query) method. + +## Define custom SDK controller actions + +Each action of your custom SDK controller is a method of the class. + +These methods have to use the [BaseController.query](/sdk/js/6/core-classes/base-controller/query) method to invoke an API action. + +Extending the previous example, we now have: + +```js +const { BaseController } = require('kuzzle-sdk'); + +class TaxiController extends BaseController { + constructor (kuzzle) { + super(kuzzle, 'nyc-open-data-plugin/taxi'); + } + + startDuty (driver) { + const apiRequest = { + action: 'startDuty', + body: { + driver + } + }; + + return this.query(apiRequest) + .then(response => response.result); + } +} +``` + +## Add a custom SDK controller to the SDK + +Once you have defined your custom SDK controller, you can add it to the SDK with the [Kuzzle.useController](/sdk/js/6/core-classes/kuzzle/use-controller) method. + + +You can then use the actions of your plugins in the same way as the rest of the Kuzzle API by taking advantage of authentication, offline mode management, etc. + +```js +const + TaxiController = require('./taxiController'), + { Kuzzle, WebSocket } = require('kuzzle-sdk'); + +const kuzzle = new Kuzzle(new WebSocket('localhost')); + +kuzzle.useController(TaxiController, 'taxi'); + +await kuzzle.connect(); + +await kuzzle.taxi.startDuty('lia meh ry'); +``` diff --git a/doc/6/essentials/index.md b/doc/6/essentials/index.md new file mode 100644 index 000000000..41c639b95 --- /dev/null +++ b/doc/6/essentials/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 100 +title: Essentials +description: Javascript SDK v6.x essential notions +--- diff --git a/doc/6/essentials/offline-tools/index.md b/doc/6/essentials/offline-tools/index.md new file mode 100644 index 000000000..a77c60213 --- /dev/null +++ b/doc/6/essentials/offline-tools/index.md @@ -0,0 +1,98 @@ +--- +code: false +type: page +title: Offline Tools +description: Tools to handle the loss of connection to the Kuzzle server +order: 400 +--- + +# Offline tools + +The Kuzzle SDK provides a set of properties that helps your application to be resilient to the loss of network connection +during its lifespan. + +## Contructor options and properties + +These properties can be set in the `options` object when [instantiating a new SDK](/sdk/js/6/core-classes/kuzzle/constructor/#arguments). + +Some of them are also [writable properties](/sdk/js/6/core-classes/kuzzle/properties) available after SDK instantiation. + +### autoQueue + +A writable `boolean` telling the SDK whether to automatically queue requests during the `offline` state or not. + +Default value: `false` + +### autoReconnect + +A writable `boolean` telling the SDK whether to automatically reconnect or not to Kuzzle after a connection loss. + +Default value: *Depends on the Protocol* + +### autoReplay + +A writable `boolean` telling the SDK whether to automatically send or not the requests in the `offlineQueue` on a +`reconnected` event. + +Default value: `false` + +### autoResubscribe + +A writable `boolean` telling the SDK whether to automatically renew or not all subscriptions on a reconnected event. + +Default value: `true` + +### offlineQueue + +A read-only `Array` containing the requests queued while the SDK is in the `offline` state (it behaves like a FIFO queue). + +### offlineQueueLoader + +A writable `Function` called by the SDK before playing the requests in the `offlineQueue`. This function takes no arguments +and returns an array of `Request` that are added on top of the `offlineQueue`. Use it to inject new requests to be played +before the queue. + +### queueFilter + +A writable `Function` called by the SDK each time a `Request` need to be queued. The `Request` is passed as the only argument +to the function and is queued only if the function returns `true`. Use it to define which requests are allowed to be queued. + +### queueMaxSize + +A writable `number` defining the maximun size of the `offlineQueue`. + +Default value: `500` + +### queueTTL + +A writable `number` defining the time in milliseconds a queued request is kept in the `offlineQueue`. + +Default value: `120000` + +### reconnectionDelay + +A read-only `number` specifying the time in milliseconds between different reconnection attempts. + +Default value: *Depends on the Protocol* + +## Methods + +### [flushQueue()](/sdk/js/6/core-classes/kuzzle/flush-queue) + +Empties the `offlineQueue` without sending the requests to Kuzzle. + +### [playQueue()](/sdk/js/6/core-classes/kuzzle/play-queue) + +Sends to Kuzzle all the requests in the `offlineQueue`. Works only if the SDK is not in a `offline` state, and if the +`autoReplay` option is set to false. + +### [startQueuing()](/sdk/js/6/core-classes/kuzzle/start-queuing/) + +Starts queuing requests when in `offline` state. Requests will be put in the `offlineQueue` array instead of being discarded, until `stopQueuing` is called. +Works only in `offline` state when the `autoQueue` option is set to `false`. Call `playQueue` to send to Kuzzle the +requests in the queue, once the SDK state passes to `online`. Call `flushQueue` to empty the queue without sending the requests. + +### [stopQueuing()](/sdk/js/6/core-classes/kuzzle/stop-queuing) + +Stop queuing the requests. Requests will no more be put in the `offlineQueue`, they will be discarded. +Works only in the `offline` state, and if the `autoQueue` option is set to `false`. diff --git a/doc/6/essentials/realtime-notifications/index.md b/doc/6/essentials/realtime-notifications/index.md new file mode 100644 index 000000000..a06b06aa0 --- /dev/null +++ b/doc/6/essentials/realtime-notifications/index.md @@ -0,0 +1,69 @@ +--- +code: false +type: page +title: Realtime notifications +description: List of realtime notifications sent by Kuzzle +order: 300 +--- + +# Notifications + +The [realtime.subscribe](/sdk/js/6/controllers/realtime/) method takes a callback argument, called with a notification object, whose properties depends on the type of notification received. + +## Document & messages + +These notifications represent [documents changes & messages](/core/1/api/essentials/notifications#documents-changes-messages). + +| Property | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------- | +| `action` |
string
| API controller's action | +| `collection` |
string
| Data collection | +| `controller` |
string
| API controller | +| `index` |
string
| Data index | +| `protocol` |
string
| Network protocol used to modify the document | +| `result` |
object
| Notification content | +| `room` |
string
| Subscription channel identifier. Can be used to link a notification to its corresponding subscription | +| `scope` |
string
| `in`: document enters (or stays) in the scope
number | Timestamp of the event, in Epoch-millis format | +| `type` |
string
| `document`: Notification type | +| `volatile` |
object
| Request [volatile data](/core/1/api/essentials/volatile-data/) | + +The `result` object is the notification content, and it has the following structure: + +| Property | Type | Description | +| --------- | ----------------- | --------------------------------------------------------------------------------------- | +| `_id` |
string
| Document unique ID
object | Message or full document content. Not present if the event is about a document deletion | + +## User + +These notifications represent [user events](/core/1/api/essentials/notifications#user-notification). + +| Property | Type | Description | +| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------- | +| `action` |
string
| API controller's action | +| `collection` |
string
| Data collection | +| `controller` |
string
| API controller | +| `index` |
string
| Data index | +| `protocol` |
string
| Network protocol used by the entering/leaving user | +| `result` |
object
| Notification content | +| `room` |
string
| Subscription channel identifier. Can be used to link a notification to its corresponding subscription | +| `timestamp` |
number
| Timestamp of the event, in Epoch-millis format | +| `type` |
string
| `user`: Notification type | +| `user` |
string
| `in`: a new user has subscribed to the same filters
object | Request [volatile data](/core/1/api/essentials/volatile-data/) | + +The `result` object is the notification content, and it has the following structure: + +| Property | Type | Description | +| -------- | ----------------- | -------------------------------------------------- | +| `count` |
number
| Updated users count sharing that same subscription | + +## Server + +These notifications represent [server events](/core/1/api/essentials/notifications#server-notification). + +| Property | Type | Value | +| --------- | ----------------- | ------------------------------------------------------------------ | +| `message` |
string
| Server message explaining why this notification has been triggered | +| `type` |
string
| `TokenExpired`: notification type | diff --git a/doc/6/getting-started/index.md b/doc/6/getting-started/index.md new file mode 100644 index 000000000..7ea7b11d6 --- /dev/null +++ b/doc/6/getting-started/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +title: Getting Started +description: Get started with the Javascript SDK +order: 0 +--- diff --git a/doc/6/getting-started/node-js/index.md b/doc/6/getting-started/node-js/index.md new file mode 100644 index 000000000..1c15138d8 --- /dev/null +++ b/doc/6/getting-started/node-js/index.md @@ -0,0 +1,157 @@ +--- +code: false +type: page +title: Node.js +description: Getting started with Kuzzle and Node.js +order: 0 +--- + +# Getting Started with Kuzzle and Node.js + +This tutorial explains you how to use **Kuzzle** with **Node.js** and the **Javascript SDK**. +It will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** about document creations. + +You are going to write an application that **stores** documents in Kuzzle Server and subscribe to **real time notifications** for each created document. + +To follow this tutorial, you must have a Kuzzle Server up and running. Follow these instructions if this is not already the case: [Running Kuzzle](/core/1/guides/getting-started/running-kuzzle/). + + +:::info +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! +::: + +## Explore the SDK + +It's time to get started with the [Kuzzle Javascript SDK](/sdk/js/6). This section, explains you how to store a document and subscribe to notifications in Kuzzle using the Javascript SDK. + +Before proceeding, please make sure your system has **Node.js** version 8 or higher ([download page](https://nodejs.org/en/download/)) installed. + +## Prepare your environment + +Create your playground directory and install the Javascript SDK from the command line using npm: + +```sh +mkdir "kuzzle-playground" +cd "kuzzle-playground" +npm install kuzzle-sdk +``` + +:::info +If you are performing a clean install you might get some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +::: + +Then, create an `init.js` file and start by adding the code below. +This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. + +<<< ./snippets/load-sdk.js + +:::info +Replace 'kuzzle' which is the Kuzzle server hostname with 'localhost' or with the host name where your Kuzzle server is running. +::: + +Next, add a listener to be notified in case of a connection error: + +```js +kuzzle.on('networkError', error => { + console.error('Network Error: ', error); +}); +``` + +Then, connect the client to your Kuzzle server with the `connect()` method, afterwards you have to add the code that will access Kuzzle to create a new index 'nyc-open-data' and a new collection 'yellow-taxi' that you will use to store data later on. + +<<< ./snippets/prepare-db.js + +Your `init.js` file should now look like this: + +<<< ./snippets/init.js + +This code does the following: + +- loads the `Kuzzle SDK` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket +- creates the `nyc-open-data` index +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created or if an error occurs + +Run the code with Node.js: + +```bash +node init.js +``` + +The console should output the following message: + +```bash +nyc-open-data/yellow-taxi ready! +``` + +:::success +Congratulations! You are now ready to say Hello to the World! +::: + +## Create your first "Hello World" document + +Create a `create.js` file with the following code: + +<<< ./snippets/create.js + +This code does the following: + +- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions fails +- disconnects from Kuzzle after the document is created or if an error occurs + +Run the code with Node.js: + +```bash +node create.js +``` + +:::success +You have now successfully stored your first document into Kuzzle. You can now open an [Admin Console](http://console.kuzzle.io) to browse your collection and confirm that your document was saved. +::: + + +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the [realtime notifications](/sdk/js/6/essentials/realtime-notifications/) documentation). + +Let's get started. Create a `subscribe.js` file with the following code: + +<<< ./snippets/subscribe.js + +Run the code with Node.js: + +```bash +node subscribe.js +``` + +The `subscribe.js` program is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. + +Now in another terminal, launch the `create.js` file from the previous section. + +```bash +node create.js +``` + +This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages) sent to the `subscribe.js` program. +Check the `subscribe.js` terminal: a new message is printed everytime a document is created using the `create.js` code. + +```bash +New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. +``` + +:::success +Congratulations! You have just set up your first pub/sub communication! +::: + +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- discover what this SDK has to offer by browsing other sections of this documentation +- learn how to use [Koncorde](/core/1/guides/cookbooks/realtime-api) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to perform a [basic authentication](/sdk/js/6/controllers/auth/login) +- follow our guide to learn how to [manage users, and how to set up fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/node-js/snippets/create.js b/doc/6/getting-started/node-js/snippets/create.js new file mode 100644 index 000000000..abd761b20 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/create.js @@ -0,0 +1,39 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates a document + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); + console.log('New document successfully created!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/create.test.yml b/doc/6/getting-started/node-js/snippets/create.test.yml new file mode 100644 index 000000000..910484f25 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/create.test.yml @@ -0,0 +1,11 @@ +name: gettingstarted#nodejscreate +description: Creates a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: empty +expected: New document successfully created! +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/init.js b/doc/6/getting-started/node-js/snippets/init.js new file mode 100644 index 000000000..fd0a31384 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/init.js @@ -0,0 +1,37 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates an index + await kuzzle.index.create('nyc-open-data'); + + // Creates a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/init.test.yml b/doc/6/getting-started/node-js/snippets/init.test.yml new file mode 100644 index 000000000..0e76545bc --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/init.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejsinit +description: Creates an index and a collection +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: empty +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/load-sdk.js b/doc/6/getting-started/node-js/snippets/load-sdk.js new file mode 100644 index 000000000..ae17a9b0e --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/load-sdk.js @@ -0,0 +1,9 @@ +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); diff --git a/doc/6/getting-started/node-js/snippets/load-sdk.test.yml b/doc/6/getting-started/node-js/snippets/load-sdk.test.yml new file mode 100644 index 000000000..0d32da204 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/load-sdk.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejsload +description: Load SDK +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/prepare-db.js b/doc/6/getting-started/node-js/snippets/prepare-db.js new file mode 100644 index 000000000..2fb9b8410 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/prepare-db.js @@ -0,0 +1,20 @@ +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Creates an index + await kuzzle.index.create('nyc-open-data'); + + // Creates a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/prepare-db.test.yml b/doc/6/getting-started/node-js/snippets/prepare-db.test.yml new file mode 100644 index 000000000..e51b6f7ce --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/prepare-db.test.yml @@ -0,0 +1,9 @@ +name: gettingstarted#nodejspreparedb +description: Prepare database +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: blank +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 diff --git a/doc/6/getting-started/node-js/snippets/subscribe.js b/doc/6/getting-started/node-js/snippets/subscribe.js new file mode 100644 index 000000000..f85d66357 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/subscribe.js @@ -0,0 +1,51 @@ +// Loads the Kuzzle SDK modules +const { + Kuzzle, + WebSocket +} = require('kuzzle-sdk'); + +// Instantiates a Kuzzle client with the WebSocket protocol +// Replace 'kuzzle' with your Kuzzle server hostname (e.g. 'localhost') +const kuzzle = new Kuzzle( + new WebSocket('kuzzle') +); + +// Adds a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error('Network Error:', error); +}); + +const run = async () => { + try { + // Connects to the Kuzzle server + await kuzzle.connect(); + + // Defines a filter + const filter = { + equals: { license: 'B' } + }; + + // Defines a callback invoked each time a notification is received + const callback = (notification) => { + + if (notification.type === 'document' && notification.action === 'create') { + const { + _source: driver, + _id: driverId + } = notification.result; + + console.log(`New driver ${driver.name} with id ${driverId} has B license.`); + kuzzle.disconnect(); + } + }; + + // Subscribes to document notifications using the above filter + await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filter, callback); + + console.log('Successfully subscribed to document notifications!'); + } catch (error) { + console.error(error.message); + } +}; + +run(); diff --git a/doc/6/getting-started/node-js/snippets/subscribe.test.yml b/doc/6/getting-started/node-js/snippets/subscribe.test.yml new file mode 100644 index 000000000..5e6720558 --- /dev/null +++ b/doc/6/getting-started/node-js/snippets/subscribe.test.yml @@ -0,0 +1,11 @@ +name: gettingstarted#nodejssubscribe +description: Subscribes to document notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: empty-realtime +expected: Successfully subscribed to document notifications! +sdk: js +version: 6 diff --git a/doc/6/getting-started/raw-web/index.md b/doc/6/getting-started/raw-web/index.md new file mode 100644 index 000000000..bee031566 --- /dev/null +++ b/doc/6/getting-started/raw-web/index.md @@ -0,0 +1,168 @@ +--- +code: false +type: page +title: Browser (Vanilla) +description: Getting started with Kuzzle in the browser +order: 100 +--- + +# Getting Started with Kuzzle in the browser + +This tutorial explains how to use **Kuzzle** with the **Javascript SDK** in a **browser**. + +To follow this tutorial, you must have a Kuzzle Server up and running (you'll need to know the hostname of the machine running it). If this is not already the case, take a look at [how to run Kuzzle](/core/1/guides/getting-started/running-kuzzle/). + +Before proceeding, make sure your system has **Node.js** version 8 or higher ([download page](https://nodejs.org/en/download/)) installed. + +In this tutorial, you'll learn how to **store** a document and **subscribe** to notifications in Kuzzle using the Javascript SDK. + +:::info +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! +::: + +## Prepare your environment + +Create your playground directory: + +```sh +mkdir "kuzzle-playground" +cd "kuzzle-playground" +``` + +:::info +If you are performing a clean install you might get some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +::: + +Then, create an `index.html` file with the following structure: + +```html + + + + + + Kuzzle SDK Playground + + + + + + + + +``` + +:::info +If you are using Internet Explorer (not Edge), you are responsible of installing a Promise polyfill, which enables IE to support +Javascript [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +Our advice is to use [Bluebird](http://bluebirdjs.com/docs/getting-started.html), as shown in the code example above (refer to the commented lines in the `head` tag). +::: + +Then, add the code below in the `body` tag. +This loads the SDK and connects it to a Kuzzle instance using the WebSocket protocol. If an error occurs, it is displayed +in the console. Once the connection is established, a success message is displayed in the console. + +<<< ./snippets/load-sdk.html + +:::info +Replace `kuzzle` with localhost or with the host name where your Kuzzle server is running. +::: + +Now you have to add the code that will access Kuzzle to create a new index `nyc-open-data` and a new collection `yellow-taxi` +that you will use to store data later on. Make sure the code inside your `body` tag looks like the following: + +<<< ./snippets/prepare-db.html + +Now, let's take a look at what your script is doing: + +- creates an instance of the SDK, +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, +- creates the `nyc-open-data` index, +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created, +- displays an error whenever something goes wrong. + +Run this code by opening the `index.html` file in your favorite browser. +The console should output the following message: + +``` +Successfully connected to Kuzzle +nyc-open-data/yellow-taxi ready! +``` + +:::success +Congratulations! You are now ready to say Hello to the World! +::: + +:::info +If you reload the page, you should see an error in the console. This is OK, since Kuzzle is just refusing to create +the `nyc-open-data` index as it already exists. +::: + +## Create your first "Hello World" document + +Create a `create.html` file with the same structure as `index.html` (see above). +And, right like before, add some code to the `body` tag: + +<<< ./snippets/create.html + +This code does the following: + +- creates an instance of the SDK, +- connects it to Kuzzle running on `kuzzle` (change the hostname if needed) using WebSocket, +- creates a new document in the `yellow-taxi` collection, within the `nyc-open-data` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions fails +- disconnects from Kuzzle after the document is created or if an error occurs + +Run this code by opening the `create.html` file in your favorite browser. +The console should output the following message: + +``` +Successfully connected to Kuzzle +New document successfully created! +``` + +:::success +You have now successfully stored your first document into Kuzzle. Check our [Admin Console Guide](/core/1/guides/essentials/admin-console/) to see how to browse your collection and confirm that your document was saved. +::: + + +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the [realtime notifications](/sdk/js/6/essentials/realtime-notifications/) documentation). + +Let's get started. Create a `subscribe.html` file (same structure as above) with the following code in the `body` tag: + +<<< ./snippets/subscribe.html + +Run this code by opening the `subscribe.html` file in a new tab, leaving the previous one (showing `create.html`) open. +The console should output the following message: + +``` +Successfully connected to Kuzzle +Successfully subscribed to document notifications! +``` + +The code in the `subscribe.html` page is now running endlessly, waiting for notifications about documents matching its filters, specifically documents that have a `license` field equal to `'B'`. + +Now go back to the other tab and reload `create.html`. + +This creates a new document in Kuzzle which, in turn, triggers a [document notification](/core/1/api/essentials/notifications/#documents-changes-messages) sent to the `subscribe.html` tab. Check the `subscribe.html` tab: a new message is printed everytime a document is created using the `create.html` code. + +``` +New driver Sirkis with id AWccRe3-DfukVhSzMdUo has B license. +``` + +:::success +Congratulations! You have just set up your first pub/sub communication! +::: + +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- discover what this SDK has to offer by browsing other sections of this documentation +- learn how to use [Koncorde](/core/1/guides/cookbooks/realtime-api) to create incredibly fine-grained and blazing-fast subscriptions +- learn how to perform a [basic authentication](/sdk/js/6/controllers/auth/login) +- follow our guide to learn how to [manage users, and how to set up fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/raw-web/snippets/create.html b/doc/6/getting-started/raw-web/snippets/create.html new file mode 100644 index 000000000..70aee4f09 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/create.html @@ -0,0 +1,31 @@ + diff --git a/doc/6/getting-started/raw-web/snippets/create.test.yml b/doc/6/getting-started/raw-web/snippets/create.test.yml new file mode 100644 index 000000000..557868de8 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/create.test.yml @@ -0,0 +1,12 @@ +name: gettingstarted#browservanillacreate +description: Create a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: New document successfully created +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/raw-web/snippets/load-sdk.html b/doc/6/getting-started/raw-web/snippets/load-sdk.html new file mode 100644 index 000000000..10d2477d1 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/load-sdk.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/doc/6/getting-started/raw-web/snippets/load-sdk.test.yml b/doc/6/getting-started/raw-web/snippets/load-sdk.test.yml new file mode 100644 index 000000000..c17ef17d8 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/load-sdk.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#browservanillaconnect +description: Connect to Kuzzle +hooks: + before: + after: +template: default +expected: Successfully connected to Kuzzle +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/raw-web/snippets/prepare-db.html b/doc/6/getting-started/raw-web/snippets/prepare-db.html new file mode 100644 index 000000000..c392a86b4 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/prepare-db.html @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/doc/6/getting-started/raw-web/snippets/prepare-db.test.yml b/doc/6/getting-started/raw-web/snippets/prepare-db.test.yml new file mode 100644 index 000000000..3ac1c5a75 --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/prepare-db.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#browservanillaprepare +description: Prepare the database +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: default +expected: nyc-open-data/yellow-taxi ready +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/raw-web/snippets/subscribe.html b/doc/6/getting-started/raw-web/snippets/subscribe.html new file mode 100644 index 000000000..ec6c858ab --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/subscribe.html @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/doc/6/getting-started/raw-web/snippets/subscribe.test.yml b/doc/6/getting-started/raw-web/snippets/subscribe.test.yml new file mode 100644 index 000000000..2fad572cd --- /dev/null +++ b/doc/6/getting-started/raw-web/snippets/subscribe.test.yml @@ -0,0 +1,12 @@ +name: gettingstarted#browservanillasubscribe +description: Subscribe to notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: default +expected: Successfully subscribed to document notifications +sdk: js +version: 6 +runner: web diff --git a/doc/6/getting-started/webpack/index.md b/doc/6/getting-started/webpack/index.md new file mode 100644 index 000000000..aa88ebfc9 --- /dev/null +++ b/doc/6/getting-started/webpack/index.md @@ -0,0 +1,212 @@ +--- +type: page +code: false +title: Webpack +description: Getting started with Kuzzle and Webpack +order: 200 +--- + +# Getting Started with Kuzzle and Webpack + +In this tutorial you will learn how to install, run and use **Kuzzle** with the **Javascript SDK** in the browser using **Webpack**. +We will walk you through creating scripts that can **store** documents in Kuzzle and subscribe to **notifications** for each new document created. + +:::info +Having trouble? Get in touch with us on [Gitter](https://gitter.im/kuzzleio/kuzzle)! +::: + +## Running Kuzzle + +Before going through this tutorial, you should have a Kuzzle server running. Please refer to the [Running Kuzzle Tutorial](/core/1/guides/getting-started/running-kuzzle/) if you don't have one yet. + +## Fun with the SDK + +It's time to play with the [Kuzzle Javscript SDK](/sdk/js/6). In this section, we will store a document and subscribe to notifications in Kuzzle using the Javascript SDK in your browser. + +Before proceeding, please make sure your system has **Node.js** version 8 or higher ([instructions here](https://nodejs.org/en/download/)) installed. + +## Including the Kuzzle SDK in a Webpack project + +::: info +This section explains how to use the Kuzzle SDK within an existing Webpack project. +If you don't have your project up and running yet and want to learn how to leverage Webpack to build it, please refer to +the [official Webpack Getting Started page](https://webpack.js.org/guides/getting-started/). +::: + +In your terminal, go to the root of your front-end project using Webpack and type + +```bash +npm install kuzzle-sdk +``` + +:::info +If you are performing a clean install you might see some `UNMET PEER DEPENDENCY` warnings, these are safe to ignore as they refer to optional dependencies. +::: + +Then, create a `init-kuzzle.js` file and start by adding the code below. This will load the Kuzzle Javascript SDK: + +<<< ./snippets/init-kuzzle.js:1 + +Next, we instantiate a client that will connect to Kuzzle via WebSocket. If Kuzzle is not running on localhost, replace it with the corresponding server name or IP address. + +<<< ./snippets/init-kuzzle.js:2 + +Next we add a listener to be notified in case of a connection error: + +<<< ./snippets/init-kuzzle.js:3 + +Then we have to connect our web app to the Kuzzle server with the `connect()` method. + +```js +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + // Some more things will go here... + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; +``` + +Finally, we will create a new index `nyc-open-data` and a new collection +`yellow-taxi` that we will use to store data later on. + +<<< ./snippets/init-kuzzle.js:4 + +Your `kuzzle-init.js` file should now look like this: + +<<< ./snippets/init-kuzzle.js + +This code does the following: + +- loads the `kuzzle-sdk` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `localhost` with the `WebSocket` protocol +- creates the `nyc-open-data` index +- creates the `yellow-taxi` collection (within the `nyc-open-data` index), +- disconnects from Kuzzle after the collection is created or if an error occurs + +Now, to have your script up and running, require it somewhere in your application +(e.g. your main entry point) and launch it. + +```js +require('../path/to/init-kuzzle.js'); +``` + +Your console should output the following message: + +``` +nyc-open-data/yellow-taxi ready! +``` + +::: success +Congratulations! You are now ready to say Hello to the World! +::: + +::: info +Having trouble? Get in touch with us on [Gitter!](https://gitter.im/kuzzleio/kuzzle) We're happy to help. +::: + +## Create your first document + +Create a `create.js` file with following code: + +<<< ./snippets/create.js + +This code does the following: + +- creates a new document in `nyc-open-data` within the `yellow-taxi` index +- logs a success message to the console if everything went fine +- logs an error message if any of the previous actions failed +- disconnects from Kuzzle after the document is created or if an error occurs + +To activate this code, create a button somewhere in your page like the following + +```html + +``` + +Then, associate it to the `create` function by adding this code to your application + +```js +const create = require('../path/to/create.js'); + +// This is the most "vanilla" way to call a function in reaction to a click, +// if you're using a front-end framework like Vuejs, React or jQuery, feel free +// to follow any convenience method it provides for this purpose. +document.querySelector('#create-document-btn').addListener('click', event => { + create(); +}); +``` + +Now, click the button and check your console for a message like the following: + +```bash +New document successfully created! +``` + +::: success +You have now successfully stored your first document into Kuzzle. Click +[here](/core/1/guides/essentials/admin-console/) to see how you can use the +[**Kuzzle Admin Console**](http://console.kuzzle.io/) to browse your collection and +confirm that your document was saved. +::: + +::: info +Having trouble? Get in touch with us on [Gitter!](https://gitter.im/kuzzleio/kuzzle) We're happy to help. +::: + +## Subscribe to realtime document notifications (pub/sub) + +Kuzzle provides pub/sub features that can be used to trigger real-time notifications based on the state of your data (for a deep-dive on notifications check out the [realtime notifications](/sdk/js/6/essentials/realtime-notifications/) documentation). + +Let's get started. Create a `subscribe.js` file with following code: + +<<< ./snippets/subscribe.js + +This code does the following: + +- loads the `Kuzzle SDK` from its NPM package +- creates an instance of the SDK +- connects it to Kuzzle running on `localhost` with the `websocket` protocol +- defines a filter for the subscription to be done later (drivers with "B" license) +- defines a callback that will be called whenever a notification is received from Kuzzle (print driver name to console) +- subscribes for notifications on the `yellow-taxi` collection + +You can execute this code in the same page as before or in another page of your app. Whatever option you choose, to +execute the code, you just need to require it in your page + +```js +require('../path/to/subscribe.js'); +``` + +From now on, whenever you click the button we created before, Kuzzle will send a notification to the page containing +the subscription to the `yellow-taxi` collection. In the console corresponding to this page, you should see the following message: + +```bash +New driver Sirkis with id has B license. +``` + +In place of `` you'll see the ID that Kuzzle automatically generated for the document. + +::: success +Congratulations! You have just choreographed your first pub/sub pattern! +::: + +::: info +Having trouble? Get in touch with us on [Gitter!](https://gitter.im/kuzzleio/kuzzle) We're happy to help. +::: + +## Where do we go from here? + +Now that you're more familiar with Kuzzle, dive even deeper to learn how to leverage its full capabilities: + +- take a look at the [SDK Reference](/sdk/js/6) +- learn how to use [Koncorde](/core/1/guides/cookbooks/realtime-api) to create incredibly fine-grained and blazing-fast subscriptions +- follow our guide to learn how to implement [basic authentication](/core/1/guides/essentials/user-authentication/#local-strategy) +- follow our guide to learn how to implement [manage users and setup fine-grained access control](/core/1/guides/essentials/security/) diff --git a/doc/6/getting-started/webpack/snippets/create.js b/doc/6/getting-started/webpack/snippets/create.js new file mode 100644 index 000000000..fe66ca6b5 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/create.js @@ -0,0 +1,33 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const doIt = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create your document + const driver = { + name: 'Sirkis', + birthday: '1959-06-22', + license: 'B' + }; + + await kuzzle.document.create('nyc-open-data', 'yellow-taxi', driver); + console.log('New document successfully created!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; + +export default doIt; diff --git a/doc/6/getting-started/webpack/snippets/create.test.yml b/doc/6/getting-started/webpack/snippets/create.test.yml new file mode 100644 index 000000000..fb4561210 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/create.test.yml @@ -0,0 +1,13 @@ +name: gettingstarted#webpackcreate +description: Creates a document +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: doIt +expected: New document successfully created! + +runner: webpack +sdk: js +version: 6 diff --git a/doc/6/getting-started/webpack/snippets/init-kuzzle.js b/doc/6/getting-started/webpack/snippets/init-kuzzle.js new file mode 100644 index 000000000..dd8476b40 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/init-kuzzle.js @@ -0,0 +1,38 @@ +// load the Kuzzle SDK module +/* snippet:start:1 */ +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; +/* snippet:end */ + +// instantiate a Kuzzle client +/* snippet:start:2 */ +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); +/* snippet:end */ + +// add a listener to detect any connection problems +/* snippet:start:3 */ +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); +/* snippet:end */ + +/* snippet:start:4 */ +const run = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Create an index + await kuzzle.index.create('nyc-open-data'); + + // Create a collection + await kuzzle.collection.create('nyc-open-data', 'yellow-taxi'); + console.log('nyc-open-data/yellow-taxi ready!'); + } catch (error) { + console.error(error.message); + } finally { + kuzzle.disconnect(); + } +}; +/* snippet:end */ + +run(); diff --git a/doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml b/doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml new file mode 100644 index 000000000..cd2ff4589 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/init-kuzzle.test.yml @@ -0,0 +1,10 @@ +name: gettingstarted#webpackinitkuzzle +description: Creates an index and a collection +hooks: + before: curl -X DELETE kuzzle:7512/nyc-open-data + after: +template: empty +expected: nyc-open-data/yellow-taxi ready! +sdk: js +version: 6 +runner: webpack diff --git a/doc/6/getting-started/webpack/snippets/subscribe.js b/doc/6/getting-started/webpack/snippets/subscribe.js new file mode 100644 index 000000000..892c99bcb --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/subscribe.js @@ -0,0 +1,49 @@ +// load the Kuzzle SDK module +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +// instantiate a Kuzzle client +const kuzzle = new Kuzzle(new WebSocket('kuzzle')); + +// add a listener to detect any connection problems +kuzzle.on('networkError', error => { + console.error(`Network Error: ${error}`); +}); + +const doIt = async () => { + try { + // Connect to Kuzzle server + await kuzzle.connect(); + + // Define a filter + const filter = { + equals: { license: 'B' } + }; + + // Define a callback + const callback = notification => { + if ( + notification.type === 'document' && + notification.action === 'create' + ) { + const driver = notification.result._source; + const driverId = notification.result._id; + console.log( + `New driver ${driver.name} with id ${driverId} has B license.` + ); + } + }; + + // Subscribes to document notifications with our filter + await kuzzle.realtime.subscribe( + 'nyc-open-data', + 'yellow-taxi', + filter, + callback + ); + console.log('Successfully subscribed to document notifications!'); + } catch (error) { + console.error(error.message); + } +}; + +doIt(); diff --git a/doc/6/getting-started/webpack/snippets/subscribe.test.yml b/doc/6/getting-started/webpack/snippets/subscribe.test.yml new file mode 100644 index 000000000..f62f51a44 --- /dev/null +++ b/doc/6/getting-started/webpack/snippets/subscribe.test.yml @@ -0,0 +1,14 @@ +name: gettingstarted#webpacksubscribe +description: Subscribes to document notifications +hooks: + before: | + curl -XPOST kuzzle:7512/nyc-open-data/_create + curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi + after: +template: createDocumentAfterSnippet +expected: + - Successfully subscribed to document notifications! + - New driver Sirkis with id +sdk: js +version: 6 +runner: webpack diff --git a/doc/6/index.md b/doc/6/index.md new file mode 100644 index 000000000..1f7b5ba97 --- /dev/null +++ b/doc/6/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: root +order: 0 +title: Javascript SDK v6.x +description: Javascript SDK v6.x +--- diff --git a/doc/6/protocols/http/constructor/index.md b/doc/6/protocols/http/constructor/index.md new file mode 100644 index 000000000..24a46550c --- /dev/null +++ b/doc/6/protocols/http/constructor/index.md @@ -0,0 +1,41 @@ +--- +code: true +type: page +title: constructor +description: Creates a new Http protocol +order: 50 +--- + +# Constructor + +Use this constructor to create a new instance of the `Http` protocol with specific options. + +## Arguments + +```js +Http(host, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------------- | +| `host` |
string
| Kuzzle server hostname or IP | +| `options` |
object
| Http connection options | + +### options + +Http protocol connection options. + +| Property | Type
(default) | Description | +| --------------- | -------------------------------- | ----------------------------------- | +| `port` |
number

(`7512`) | Kuzzle server port | +| `sslConnection` |
boolean

(`false`) | Use SSL to connect to Kuzzle server | + +## Return + +A `Http` protocol instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/6/protocols/http/constructor/snippets/constructor.js b/doc/6/protocols/http/constructor/snippets/constructor.js new file mode 100644 index 000000000..073ebabdd --- /dev/null +++ b/doc/6/protocols/http/constructor/snippets/constructor.js @@ -0,0 +1,16 @@ +// Loads the Http protocol +const + { + Kuzzle, + Http + } = require('kuzzle-sdk'); + +const options = { + sslConnection: false +}; + +// Instantiates the Http protocol +const httpProtocol = new Http('kuzzle', options); + +// Use it with Kuzzle +const kuzzle = new Kuzzle(httpProtocol); diff --git a/doc/6/protocols/http/constructor/snippets/constructor.test.yml b/doc/6/protocols/http/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..585b32c5a --- /dev/null +++ b/doc/6/protocols/http/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: http#constructor +description: Creates a new Http instance +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/6/protocols/http/index.md b/doc/6/protocols/http/index.md new file mode 100644 index 000000000..7d3ae6f0e --- /dev/null +++ b/doc/6/protocols/http/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: Http +description: Http protocol documentation +order: 600 +--- diff --git a/doc/6/protocols/http/introduction/index.md b/doc/6/protocols/http/introduction/index.md new file mode 100644 index 000000000..0bb636705 --- /dev/null +++ b/doc/6/protocols/http/introduction/index.md @@ -0,0 +1,17 @@ +--- +code: false +type: page +title: Introduction +description: Http protocol implementation +order: 0 +--- + +# Http + +The Http protocol can be used by an instance of the SDK to communicate with your Kuzzle server. + +:::info +This protocol does not allow to use the [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). + +If you need real-time features, then you have to use either [WebSocket](/sdk/js/6/protocols/websocket) or [SocketIO](/sdk/js/6/protocols/socketio) protocols. +::: diff --git a/doc/6/protocols/http/properties/index.md b/doc/6/protocols/http/properties/index.md new file mode 100644 index 000000000..e280f5787 --- /dev/null +++ b/doc/6/protocols/http/properties/index.md @@ -0,0 +1,19 @@ +--- +code: false +type: page +title: Properties +description: Http class properties +order: 10 +--- + + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `connected` |
boolean
| Always returns `true` | +| `host` |
string
| Kuzzle server host | +| `http` |
object
| Returns a list of available routes | +| `port` |
number
| Kuzzle server port | +| `protocol` |
string
| `https` or `http` | +| `ssl` |
boolean
| `true` if ssl is active | diff --git a/doc/6/protocols/index.md b/doc/6/protocols/index.md new file mode 100644 index 000000000..a6a409d8a --- /dev/null +++ b/doc/6/protocols/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +order: 300 +title: Protocols +description: Javascript SDK v6.x protocols +--- diff --git a/doc/6/protocols/socketio/constructor/index.md b/doc/6/protocols/socketio/constructor/index.md new file mode 100644 index 000000000..fca54a645 --- /dev/null +++ b/doc/6/protocols/socketio/constructor/index.md @@ -0,0 +1,43 @@ +--- +code: true +type: page +title: constructor +description: Creates a new SocketIO protocol +order: 50 +--- + +# Constructor + +Use this constructor to create a new instance of the `SocketIO` protocol with specific options. + +## Arguments + +```js +SocketIO(host, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------------- | +| `host` |
string
| Kuzzle server hostname or IP | +| `options` |
object
| SocketIO connection options | + +### options + +SocketIO protocol connection options. + +| Property | Type
(default) | Description | +| ------------------- | -------------------------------- | -------------------------------------------------------------- | +| `port` |
number

(`7512`) | Kuzzle server port | +| `sslConnection` |
boolean

(`false`) | Use SSL to connect to Kuzzle server | +| `autoReconnect` |
boolean

(`true`) | Automatically reconnect to kuzzle after a `disconnected` event | +| `reconnectionDelay` |
number

(`1000`) | Number of milliseconds between reconnection attempts | + +## Return + +A `SocketIO` protocol instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/6/protocols/socketio/constructor/snippets/constructor.js b/doc/6/protocols/socketio/constructor/snippets/constructor.js new file mode 100644 index 000000000..ff5f68f10 --- /dev/null +++ b/doc/6/protocols/socketio/constructor/snippets/constructor.js @@ -0,0 +1,16 @@ +// Loads the SocketIO protocol +const + { + Kuzzle, + SocketIO + } = require('kuzzle-sdk'); + +const options = { + autoReconnect: false +}; + +// Instantiates the SocketIO protocol +const socketIOProtocol = new SocketIO('kuzzle', options); + +// Use it with Kuzzle +const kuzzle = new Kuzzle(socketIOProtocol); diff --git a/doc/6/protocols/socketio/constructor/snippets/constructor.test.yml b/doc/6/protocols/socketio/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..f8b638ee1 --- /dev/null +++ b/doc/6/protocols/socketio/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: socketio#constructor +description: Creates a new SocketIO instance +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/6/protocols/socketio/index.md b/doc/6/protocols/socketio/index.md new file mode 100644 index 000000000..44ea1ab0d --- /dev/null +++ b/doc/6/protocols/socketio/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: SocketIO +description: SocketIO protocol documentation +order: 600 +--- diff --git a/doc/6/protocols/socketio/introduction/index.md b/doc/6/protocols/socketio/introduction/index.md new file mode 100644 index 000000000..58717f7ad --- /dev/null +++ b/doc/6/protocols/socketio/introduction/index.md @@ -0,0 +1,16 @@ +--- +code: false +type: page +title: Introduction +description: SocketIO protocol implementation +order: 0 +--- + +# SocketIO + +The SocketIO protocol can be used by an instance of the SDK to communicate with your Kuzzle server. +This protocol allows you to use all the features of Kuzzle, including [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). + +:::info +The SocketIO protocol is used for WebSocket compatibility with older browsers. It is preferable to use the [WebSocket](/sdk/js/6/protocols/websocket) protocol when possible. +::: diff --git a/doc/6/protocols/socketio/properties/index.md b/doc/6/protocols/socketio/properties/index.md new file mode 100644 index 000000000..42aeefe36 --- /dev/null +++ b/doc/6/protocols/socketio/properties/index.md @@ -0,0 +1,22 @@ +--- +code: false +type: page +title: Properties +description: SocketIO class properties +order: 10 +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoReconnect` |
boolean
| Automatically reconnects after a connection loss | +| `connected` |
boolean
| Returns `true` if the socket is open | +| `host` |
string
| Kuzzle server host | +| `port` |
number
| Kuzzle server port | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | +| `ssl` |
boolean
| `true` if ssl is active | + +::: info +Updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on the next `connect` call. +::: diff --git a/doc/6/protocols/websocket/constructor/index.md b/doc/6/protocols/websocket/constructor/index.md new file mode 100644 index 000000000..736df3deb --- /dev/null +++ b/doc/6/protocols/websocket/constructor/index.md @@ -0,0 +1,44 @@ +--- +code: true +type: page +title: constructor +description: Creates a new WebSocket protocol +order: 50 +--- + +# Constructor + +This constructor creates a new WebSocket connection, using the specified options. + +## Arguments + +```js +WebSocket(host, [options]); +``` + +
+ +| Argument | Type | Description | +| --------- | ----------------- | ---------------------------- | +| `host` |
string
| Kuzzle server hostname or IP | +| `options` |
object
| WebSocket connection options | + +### options + +WebSocket protocol connection options. + +| Property | Type
(default) | Description | +| ------------------- | -------------------------------- | -------------------------------------------------------------------------------------------- | +| `autoReconnect` |
boolean

(`true`) | Automatically reconnect to kuzzle after a `disconnected` event | +| `port` |
number

(`7512`) | Kuzzle server port | +| `headers` |
object
(`{}`) | Connection HTTP headers (e.g. origin, subprotocols, ...)
**(Not supported by browsers)** | +| `reconnectionDelay` |
number

(`1000`) | Number of milliseconds between reconnection attempts | +| `sslConnection` |
boolean

(`false`) | Use SSL to connect to Kuzzle server | + +## Return + +A `WebSocket` protocol instance. + +## Usage + +<<< ./snippets/constructor.js diff --git a/doc/6/protocols/websocket/constructor/snippets/constructor.js b/doc/6/protocols/websocket/constructor/snippets/constructor.js new file mode 100644 index 000000000..17fc0cd26 --- /dev/null +++ b/doc/6/protocols/websocket/constructor/snippets/constructor.js @@ -0,0 +1,16 @@ +// Loads the WebSocket protocol +const + { + Kuzzle, + WebSocket + } = require('kuzzle-sdk'); + +const options = { + autoReconnect: false +}; + +// Instantiates the websocket protocol +const websocketProtocol = new WebSocket('kuzzle', options); + +// Use it with Kuzzle +const kuzzle = new Kuzzle(websocketProtocol); diff --git a/doc/6/protocols/websocket/constructor/snippets/constructor.test.yml b/doc/6/protocols/websocket/constructor/snippets/constructor.test.yml new file mode 100644 index 000000000..9f49ef71a --- /dev/null +++ b/doc/6/protocols/websocket/constructor/snippets/constructor.test.yml @@ -0,0 +1,10 @@ +--- +name: websocket#constructor +description: Creates a new WebSocket instance +hooks: + before: + after: +template: empty +expected: Success +sdk: js +version: 6 diff --git a/doc/6/protocols/websocket/index.md b/doc/6/protocols/websocket/index.md new file mode 100644 index 000000000..e57f9b855 --- /dev/null +++ b/doc/6/protocols/websocket/index.md @@ -0,0 +1,7 @@ +--- +code: true +type: branch +title: WebSocket +description: WebSocket protocol documentation +order: 600 +--- diff --git a/doc/6/protocols/websocket/introduction/index.md b/doc/6/protocols/websocket/introduction/index.md new file mode 100644 index 000000000..1757128cc --- /dev/null +++ b/doc/6/protocols/websocket/introduction/index.md @@ -0,0 +1,15 @@ +--- +code: false +type: page +title: Introduction +description: Websocket protocol implementation +order: 0 +--- + +# WebSocket + +Inherits from: [KuzzleEventEmitter](/sdk/js/6/core-classes/kuzzle-event-emitter) + +The WebSocket protocol can be used by an instance of the SDK to communicate with your Kuzzle server. + +This protocol allows you to use all the features of Kuzzle, including [real-time notifications](/sdk/js/6/essentials/realtime-notifications/). diff --git a/doc/6/protocols/websocket/properties/index.md b/doc/6/protocols/websocket/properties/index.md new file mode 100644 index 000000000..6b20dc9fb --- /dev/null +++ b/doc/6/protocols/websocket/properties/index.md @@ -0,0 +1,22 @@ +--- +code: false +type: page +title: Properties +description: Websocket class properties +order: 10 +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | +| `connected` |
boolean
| Returns `true` if the socket is open | +| `host` |
string
| Kuzzle server host | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | +| `port` |
number
| Kuzzle server port | +| `ssl` |
boolean
| `true` if ssl is active | + +::: info +Updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on the next `connect` call. +::: \ No newline at end of file diff --git a/package.json b/package.json index daddc8d77..67971f84a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "prepublish": "npm run build", "test": "npm run --silent lint && npm run unit-testing && npm run functional-testing", "unit-testing": "nyc --reporter=text-summary --reporter=lcov mocha", + "doc-testing": "docker-compose -f .ci/doc/docker-compose.yml pull; docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index", "functional-testing": "cucumber-js --exit --fail-fast", "lint": "eslint --max-warnings=0 ./src ./test", "build": "node build.js" From f51e64b7805511e7807f843b1988d2320899cd32 Mon Sep 17 00:00:00 2001 From: Aschen Date: Mon, 1 Jul 2019 09:24:22 +0200 Subject: [PATCH 20/26] fix link --- doc/6/controllers/collection/create/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/6/controllers/collection/create/index.md b/doc/6/controllers/collection/create/index.md index ece434f22..10faa2dd2 100644 --- a/doc/6/controllers/collection/create/index.md +++ b/doc/6/controllers/collection/create/index.md @@ -7,7 +7,7 @@ description: Create a new collection # create -Creates a new [collection](/core/1/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided index. +Creates a new [collection](/core/1/guides/essentials/store-access-data/) in Kuzzle via the persistence engine, in the provided index. You can also provide an optional data mapping that allow you to exploit the full capabilities of our persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html)). From 5867e92e0dee4d662750720bde4152897a7e3e9d Mon Sep 17 00:00:00 2001 From: Luca Marchesini Date: Mon, 1 Jul 2019 09:27:49 +0200 Subject: [PATCH 21/26] [fix] Broken link --- doc/6/controllers/collection/create/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/6/controllers/collection/create/index.md b/doc/6/controllers/collection/create/index.md index ece434f22..10faa2dd2 100644 --- a/doc/6/controllers/collection/create/index.md +++ b/doc/6/controllers/collection/create/index.md @@ -7,7 +7,7 @@ description: Create a new collection # create -Creates a new [collection](/core/1/guides/essentials/persisted/) in Kuzzle via the persistence engine, in the provided index. +Creates a new [collection](/core/1/guides/essentials/store-access-data/) in Kuzzle via the persistence engine, in the provided index. You can also provide an optional data mapping that allow you to exploit the full capabilities of our persistent data storage layer, [ElasticSearch](https://www.elastic.co/products/elasticsearch) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html)). From 9924fab1623c2ce87179e1b27ec3a9e68bc81178 Mon Sep 17 00:00:00 2001 From: Berthier Esteban <44427849+berthieresteban@users.noreply.github.com> Date: Mon, 1 Jul 2019 11:27:14 +0200 Subject: [PATCH 22/26] Add-getting-started-vuejs-without-vuex (#405) Add VueJS getting-started without vuex --- doc/6/getting-started/vuejs/.gitignore | 3 + doc/6/getting-started/vuejs/cypress.json | 14 ++ .../vuejs/cypress/fixtures/Environment.1.json | 3 + .../vuejs/cypress/fixtures/Environment.2.json | 26 +++ .../vuejs/cypress/fixtures/Environment.3.json | 7 + .../vuejs/cypress/fixtures/Environment.4.json | 7 + .../vuejs/cypress/integration/chat.spec.js | 87 ++++++++ .../vuejs/cypress/plugins/index.js | 17 ++ .../vuejs/cypress/support/commands.js | 106 +++++++++ .../vuejs/cypress/support/index.js | 20 ++ doc/6/getting-started/vuejs/package.json | 50 +++++ .../vuejs/without-vuex/babel.config.js | 5 + .../vuejs/without-vuex/public/favicon.ico | Bin 0 -> 4286 bytes .../vuejs/without-vuex/public/index.html | 17 ++ .../vuejs/without-vuex/src/App.vue | 202 ++++++++++++++++++ .../vuejs/without-vuex/src/assets/logo.png | Bin 0 -> 6849 bytes .../vuejs/without-vuex/src/main.js | 7 + .../vuejs/without-vuex/src/services/kuzzle.js | 3 + 18 files changed, 574 insertions(+) create mode 100644 doc/6/getting-started/vuejs/.gitignore create mode 100644 doc/6/getting-started/vuejs/cypress.json create mode 100644 doc/6/getting-started/vuejs/cypress/fixtures/Environment.1.json create mode 100644 doc/6/getting-started/vuejs/cypress/fixtures/Environment.2.json create mode 100644 doc/6/getting-started/vuejs/cypress/fixtures/Environment.3.json create mode 100644 doc/6/getting-started/vuejs/cypress/fixtures/Environment.4.json create mode 100644 doc/6/getting-started/vuejs/cypress/integration/chat.spec.js create mode 100644 doc/6/getting-started/vuejs/cypress/plugins/index.js create mode 100644 doc/6/getting-started/vuejs/cypress/support/commands.js create mode 100644 doc/6/getting-started/vuejs/cypress/support/index.js create mode 100644 doc/6/getting-started/vuejs/package.json create mode 100644 doc/6/getting-started/vuejs/without-vuex/babel.config.js create mode 100644 doc/6/getting-started/vuejs/without-vuex/public/favicon.ico create mode 100644 doc/6/getting-started/vuejs/without-vuex/public/index.html create mode 100644 doc/6/getting-started/vuejs/without-vuex/src/App.vue create mode 100644 doc/6/getting-started/vuejs/without-vuex/src/assets/logo.png create mode 100644 doc/6/getting-started/vuejs/without-vuex/src/main.js create mode 100644 doc/6/getting-started/vuejs/without-vuex/src/services/kuzzle.js diff --git a/doc/6/getting-started/vuejs/.gitignore b/doc/6/getting-started/vuejs/.gitignore new file mode 100644 index 000000000..cef3da1f7 --- /dev/null +++ b/doc/6/getting-started/vuejs/.gitignore @@ -0,0 +1,3 @@ +/cypress/screenshots/ +/cypress/videos/ +package-lock.json \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress.json b/doc/6/getting-started/vuejs/cypress.json new file mode 100644 index 000000000..97ba7bcda --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress.json @@ -0,0 +1,14 @@ +{ + "baseUrl": "http://localhost:8080", + "viewportWidth": 1400, + "viewportHeight": 900, + "defaultCommandTimeout": 5000, + "env": { + "kuzzle": { + "host": "localhost", + "port": "7512", + "index": "chat", + "collection": "messages" + } + } +} \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/fixtures/Environment.1.json b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.1.json new file mode 100644 index 000000000..a04d96844 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.1.json @@ -0,0 +1,3 @@ +{ + "username": "Elrond" +} \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/fixtures/Environment.2.json b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.2.json new file mode 100644 index 000000000..3c983f6b0 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.2.json @@ -0,0 +1,26 @@ +{ + "username": "Legolas", + "messages": [ + { + "_id": "1", + "payload": { + "value": "It still only counts as one!", + "username": "Gimli" + } + }, + { + "_id": "2", + "payload": { + "value": "What do your elf eyes see?", + "username": "Aragorn" + } + }, + { + "_id": "3", + "payload": { + "value": "What about side by side with a friend?", + "username": "Legolas" + } + } + ] +} \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/fixtures/Environment.3.json b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.3.json new file mode 100644 index 000000000..e84a6f198 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.3.json @@ -0,0 +1,7 @@ +{ + "username": "Sam", + "payload": { + "username": "Sam", + "value": "I can't carry it for you, But I can carry you!" + } +} \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/fixtures/Environment.4.json b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.4.json new file mode 100644 index 000000000..53f49410f --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/fixtures/Environment.4.json @@ -0,0 +1,7 @@ +{ + "username": "Sauron", + "payload": { + "username": "Eowyn", + "value": "I am no man" + } +} \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/integration/chat.spec.js b/doc/6/getting-started/vuejs/cypress/integration/chat.spec.js new file mode 100644 index 000000000..fb30bce85 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/integration/chat.spec.js @@ -0,0 +1,87 @@ +describe('test realtime chat', () => { + let currentIt = 1; + let env; + + before(() => { + cy.initialisation(); + }); + + beforeEach(() => { + cy.visit('/'); + cy.fixture(`Environment.${currentIt}.json`) + .then((fixtures) => { env = fixtures; }) + .then(() => cy.log(`Environment ${currentIt}: `, env)) + .then(() => cy.loadEnvironment(env)); + cy.wait(2000); + }); + + afterEach(() => { + currentIt++; + }); + + it('should enter a nickname', () => { + cy.get('[placeholder="Enter your message"]') + .should('not.exist'); + + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + + + cy.contains('Valid') + .click(); + + cy.get('[placeholder="Enter your message"]') + .should('exist'); + cy.get('[placeholder="Enter your nickname"]') + .should('not.exist'); + }); + + it('should fetch and display some messages', () => { + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + cy.contains('Valid') + .click(); + + env.messages.forEach(message => { + cy.get(message.payload.username === env.username ? '.fromMe': '.fromOthers') + .within(() => { + cy.contains(message.payload.value); + cy.contains(message.payload.username); + }); + }); + }); + + it('should send a message', () => { + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + cy.contains('Valid') + .click(); + cy.createMessage({ + _id: '1', + payload: env.payload + }); + + cy.get('.fromMe') + .within(() => { + cy.contains(env.payload.value); + cy.contains(env.username); + }); + }); + + it('should receive a message', () => { + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + cy.contains('Valid') + .click(); + cy.createMessage({ + _id: '1', + payload: env.payload + }); + + cy.get('.fromOthers') + .within(() => { + cy.contains(env.payload.value); + cy.contains(env.payload.username); + }); + }); +}); \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/plugins/index.js b/doc/6/getting-started/vuejs/cypress/plugins/index.js new file mode 100644 index 000000000..fd170fba6 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/plugins/index.js @@ -0,0 +1,17 @@ +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) + +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config +} diff --git a/doc/6/getting-started/vuejs/cypress/support/commands.js b/doc/6/getting-started/vuejs/cypress/support/commands.js new file mode 100644 index 000000000..2203db146 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/support/commands.js @@ -0,0 +1,106 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add("login", (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This is will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) + +function reinitialisation() { + const kuzzle = Cypress.env('kuzzle'); + + // Clear collection + return cy.request({ + url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/${kuzzle.collection}/_truncate`, + method: 'DELETE', + }) + .then(searchResponse => { + cy.log(`Request : truncate ${kuzzle.collection} status : ${searchResponse.status}`); + cy.wait(500); + }); +} + +Cypress.Commands.add('createMessage', (message) => { + const kuzzle = Cypress.env('kuzzle'); + return cy.request({ + url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/${kuzzle.collection}/${message._id}/_create`, + method: 'POST', + body: message.payload, + }) + .its('body') + .then(response => { + cy.log(`Create : ${message._id} status : ${response.status}`); + cy.wait(500); + }); +}); + + +Cypress.Commands.add('initialisation', () => { + const kuzzle = Cypress.env('kuzzle'); + + // Delete index if exists + cy.request({ + url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/_exists`, + method: 'GET', + }) + .then(existsResponse => { + cy.log(`Request : exists ${kuzzle.index} status : ${existsResponse.status}`); + if (existsResponse.body.result) { + cy.request({ + url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}`, + method: 'DELETE', + }) + .then(deleteResponse => { + cy.log(`Request : delete ${kuzzle.index} status : ${deleteResponse.status}`); + }); + } + }).then(() => { + // Create index + cy.request({ + url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/_create`, + method: 'POST', + }) + .then(createResponse => { + cy.log(`Request : create ${kuzzle.index} status : ${createResponse.status}`); + cy.wait(500); + }); + }) + .then(() => { + // Create collection + cy.request({ + url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/${kuzzle.collection}`, + method: 'PUT', + body: {} + }) + .then(createResponse => { + cy.log(`Request : create ${kuzzle.collection} status : ${createResponse.status}`); + cy.wait(500); + }); + }); +}); + +Cypress.Commands.add('loadEnvironment', (env) => { + reinitialisation(); + if (!env.messages) {return;} + env.messages.forEach(message => { + cy.createMessage(message); + }); +}); \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/cypress/support/index.js b/doc/6/getting-started/vuejs/cypress/support/index.js new file mode 100644 index 000000000..d68db96df --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/support/index.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/doc/6/getting-started/vuejs/package.json b/doc/6/getting-started/vuejs/package.json new file mode 100644 index 000000000..299676360 --- /dev/null +++ b/doc/6/getting-started/vuejs/package.json @@ -0,0 +1,50 @@ +{ + "name": "kuzzle-vuejs-gs", + "version": "0.1.0", + "private": true, + "scripts": { + "postinstall": "if [ ! -f ../../../../dist/kuzzle.js ]; then npm run build --prefix ../../../../;fi && rm -rf ./node_modules/kuzzle-sdk/* && rsync -r --exclude 'getting-started' ../../../../ ./node_modules/kuzzle-sdk", + "serve-without-vuex": "cd without-vuex && vue-cli-service serve", + "build-without-vuex": "cd without-vuex && vue-cli-service build", + "lint-without-vuex": "cd without-vuex && vue-cli-service lint", + "test": "./node_modules/.bin/cypress run" + }, + "dependencies": { + "core-js": "^2.6.5", + "vue": "^2.6.10", + "vuex": "^3.1.1" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "^3.7.0", + "@vue/cli-plugin-eslint": "^3.7.0", + "@vue/cli-service": "^3.7.0", + "babel-eslint": "^10.0.1", + "cypress": "^3.3.1", + "eslint": "^5.16.0", + "eslint-plugin-vue": "^5.0.0", + "vue-template-compiler": "^2.5.21" + }, + "eslintConfig": { + "root": true, + "env": { + "node": true + }, + "extends": [ + "plugin:vue/essential", + "eslint:recommended" + ], + "rules": {}, + "parserOptions": { + "parser": "babel-eslint" + } + }, + "postcss": { + "plugins": { + "autoprefixer": {} + } + }, + "browserslist": [ + "> 1%", + "last 2 versions" + ] +} diff --git a/doc/6/getting-started/vuejs/without-vuex/babel.config.js b/doc/6/getting-started/vuejs/without-vuex/babel.config.js new file mode 100644 index 000000000..ba179669a --- /dev/null +++ b/doc/6/getting-started/vuejs/without-vuex/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/app' + ] +} diff --git a/doc/6/getting-started/vuejs/without-vuex/public/favicon.ico b/doc/6/getting-started/vuejs/without-vuex/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/doc/6/getting-started/vuejs/without-vuex/public/index.html b/doc/6/getting-started/vuejs/without-vuex/public/index.html new file mode 100644 index 000000000..5ee139839 --- /dev/null +++ b/doc/6/getting-started/vuejs/without-vuex/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + kuzzle-vuejs-gs + + + +
+ + + diff --git a/doc/6/getting-started/vuejs/without-vuex/src/App.vue b/doc/6/getting-started/vuejs/without-vuex/src/App.vue new file mode 100644 index 000000000..1d64093ae --- /dev/null +++ b/doc/6/getting-started/vuejs/without-vuex/src/App.vue @@ -0,0 +1,202 @@ + + + + + diff --git a/doc/6/getting-started/vuejs/without-vuex/src/assets/logo.png b/doc/6/getting-started/vuejs/without-vuex/src/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f3d2503fc2a44b5053b0837ebea6e87a2d339a43 GIT binary patch literal 6849 zcmaKRcUV(fvo}bjDT-7nLI_nlK}sT_69H+`qzVWDA|yaU?}j417wLi^B1KB1SLsC& zL0ag7$U(XW5YR7p&Ux?sP$d4lvMt8C^+TcQu4F zQqv!UF!I+kw)c0jhd6+g6oCr9P?7)?!qX1ui*iL{p}sKCAGuJ{{W)0z1pLF|=>h}& zt(2Lr0Z`2ig8<5i%Zk}cO5Fm=LByqGWaS`oqChZdEFmc`0hSb#gg|Aap^{+WKOYcj zHjINK)KDG%&s?Mt4CL(T=?;~U@bU2x_mLKN!#GJuK_CzbNw5SMEJorG!}_5;?R>@1 zSl)jns3WlU7^J%=(hUtfmuUCU&C3%8B5C^f5>W2Cy8jW3#{Od{lF1}|?c61##3dzA zsPlFG;l_FzBK}8>|H_Ru_H#!_7$UH4UKo3lKOA}g1(R&|e@}GINYVzX?q=_WLZCgh z)L|eJMce`D0EIwgRaNETDsr+?vQknSGAi=7H00r`QnI%oQnFxm`G2umXso9l+8*&Q z7WqF|$p49js$mdzo^BXpH#gURy=UO;=IMrYc5?@+sR4y_?d*~0^YP7d+y0{}0)zBM zIKVM(DBvICK#~7N0a+PY6)7;u=dutmNqK3AlsrUU9U`d;msiucB_|8|2kY=(7XA;G zwDA8AR)VCA#JOkxm#6oHNS^YVuOU;8p$N)2{`;oF|rQ?B~K$%rHDxXs+_G zF5|-uqHZvSzq}L;5Kcy_P+x0${33}Ofb6+TX&=y;;PkEOpz%+_bCw_{<&~ zeLV|!bP%l1qxywfVr9Z9JI+++EO^x>ZuCK);=$VIG1`kxK8F2M8AdC$iOe3cj1fo(ce4l-9 z7*zKy3={MixvUk=enQE;ED~7tv%qh&3lR<0m??@w{ILF|e#QOyPkFYK!&Up7xWNtL zOW%1QMC<3o;G9_S1;NkPB6bqbCOjeztEc6TsBM<(q9((JKiH{01+Ud=uw9B@{;(JJ z-DxI2*{pMq`q1RQc;V8@gYAY44Z!%#W~M9pRxI(R?SJ7sy7em=Z5DbuDlr@*q|25V)($-f}9c#?D%dU^RS<(wz?{P zFFHtCab*!rl(~j@0(Nadvwg8q|4!}L^>d?0al6}Rrv9$0M#^&@zjbfJy_n!%mVHK4 z6pLRIQ^Uq~dnyy$`ay51Us6WaP%&O;@49m&{G3z7xV3dLtt1VTOMYl3UW~Rm{Eq4m zF?Zl_v;?7EFx1_+#WFUXxcK78IV)FO>42@cm@}2I%pVbZqQ}3;p;sDIm&knay03a^ zn$5}Q$G!@fTwD$e(x-~aWP0h+4NRz$KlnO_H2c< z(XX#lPuW_%H#Q+c&(nRyX1-IadKR-%$4FYC0fsCmL9ky3 zKpxyjd^JFR+vg2!=HWf}2Z?@Td`0EG`kU?{8zKrvtsm)|7>pPk9nu@2^z96aU2<#` z2QhvH5w&V;wER?mopu+nqu*n8p~(%QkwSs&*0eJwa zMXR05`OSFpfyRb!Y_+H@O%Y z0=K^y6B8Gcbl?SA)qMP3Z+=C(?8zL@=74R=EVnE?vY!1BQy2@q*RUgRx4yJ$k}MnL zs!?74QciNb-LcG*&o<9=DSL>1n}ZNd)w1z3-0Pd^4ED1{qd=9|!!N?xnXjM!EuylY z5=!H>&hSofh8V?Jofyd!h`xDI1fYAuV(sZwwN~{$a}MX^=+0TH*SFp$vyxmUv7C*W zv^3Gl0+eTFgBi3FVD;$nhcp)ka*4gSskYIqQ&+M}xP9yLAkWzBI^I%zR^l1e?bW_6 zIn{mo{dD=)9@V?s^fa55jh78rP*Ze<3`tRCN4*mpO$@7a^*2B*7N_|A(Ve2VB|)_o z$=#_=aBkhe(ifX}MLT()@5?OV+~7cXC3r!%{QJxriXo9I%*3q4KT4Xxzyd{ z9;_%=W%q!Vw$Z7F3lUnY+1HZ*lO;4;VR2+i4+D(m#01OYq|L_fbnT;KN<^dkkCwtd zF7n+O7KvAw8c`JUh6LmeIrk4`F3o|AagKSMK3))_5Cv~y2Bb2!Ibg9BO7Vkz?pAYX zoI=B}+$R22&IL`NCYUYjrdhwjnMx_v=-Qcx-jmtN>!Zqf|n1^SWrHy zK|MwJ?Z#^>)rfT5YSY{qjZ&`Fjd;^vv&gF-Yj6$9-Dy$<6zeP4s+78gS2|t%Z309b z0^fp~ue_}i`U9j!<|qF92_3oB09NqgAoehQ`)<)dSfKoJl_A6Ec#*Mx9Cpd-p#$Ez z={AM*r-bQs6*z$!*VA4|QE7bf@-4vb?Q+pPKLkY2{yKsw{&udv_2v8{Dbd zm~8VAv!G~s)`O3|Q6vFUV%8%+?ZSVUa(;fhPNg#vab@J*9XE4#D%)$UU-T5`fwjz! z6&gA^`OGu6aUk{l*h9eB?opVdrHK>Q@U>&JQ_2pR%}TyOXGq_6s56_`U(WoOaAb+K zXQr#6H}>a-GYs9^bGP2Y&hSP5gEtW+GVC4=wy0wQk=~%CSXj=GH6q z-T#s!BV`xZVxm{~jr_ezYRpqqIcXC=Oq`b{lu`Rt(IYr4B91hhVC?yg{ol4WUr3v9 zOAk2LG>CIECZ-WIs0$N}F#eoIUEtZudc7DPYIjzGqDLWk_A4#(LgacooD z2K4IWs@N`Bddm-{%oy}!k0^i6Yh)uJ1S*90>|bm3TOZxcV|ywHUb(+CeX-o1|LTZM zwU>dY3R&U)T(}5#Neh?-CWT~@{6Ke@sI)uSuzoah8COy)w)B)aslJmp`WUcjdia-0 zl2Y}&L~XfA`uYQboAJ1;J{XLhYjH){cObH3FDva+^8ioOQy%Z=xyjGLmWMrzfFoH; zEi3AG`_v+%)&lDJE;iJWJDI@-X9K5O)LD~j*PBe(wu+|%ar~C+LK1+-+lK=t# z+Xc+J7qp~5q=B~rD!x78)?1+KUIbYr^5rcl&tB-cTtj+e%{gpZZ4G~6r15+d|J(ky zjg@@UzMW0k9@S#W(1H{u;Nq(7llJbq;;4t$awM;l&(2s+$l!Ay9^Ge|34CVhr7|BG z?dAR83smef^frq9V(OH+a+ki#q&-7TkWfFM=5bsGbU(8mC;>QTCWL5ydz9s6k@?+V zcjiH`VI=59P-(-DWXZ~5DH>B^_H~;4$)KUhnmGo*G!Tq8^LjfUDO)lASN*=#AY_yS zqW9UX(VOCO&p@kHdUUgsBO0KhXxn1sprK5h8}+>IhX(nSXZKwlNsjk^M|RAaqmCZB zHBolOHYBas@&{PT=R+?d8pZu zUHfyucQ`(umXSW7o?HQ3H21M`ZJal+%*)SH1B1j6rxTlG3hx1IGJN^M7{$j(9V;MZ zRKybgVuxKo#XVM+?*yTy{W+XHaU5Jbt-UG33x{u(N-2wmw;zzPH&4DE103HV@ER86 z|FZEmQb|&1s5#`$4!Cm}&`^{(4V}OP$bk`}v6q6rm;P!H)W|2i^e{7lTk2W@jo_9q z*aw|U7#+g59Fv(5qI`#O-qPj#@_P>PC#I(GSp3DLv7x-dmYK=C7lPF8a)bxb=@)B1 zUZ`EqpXV2dR}B&r`uM}N(TS99ZT0UB%IN|0H%DcVO#T%L_chrgn#m6%x4KE*IMfjX zJ%4veCEqbXZ`H`F_+fELMC@wuy_ch%t*+Z+1I}wN#C+dRrf2X{1C8=yZ_%Pt6wL_~ zZ2NN-hXOT4P4n$QFO7yYHS-4wF1Xfr-meG9Pn;uK51?hfel`d38k{W)F*|gJLT2#T z<~>spMu4(mul-8Q3*pf=N4DcI)zzjqAgbE2eOT7~&f1W3VsdD44Ffe;3mJp-V@8UC z)|qnPc12o~$X-+U@L_lWqv-RtvB~%hLF($%Ew5w>^NR82qC_0FB z)=hP1-OEx?lLi#jnLzH}a;Nvr@JDO-zQWd}#k^an$Kwml;MrD&)sC5b`s0ZkVyPkb zt}-jOq^%_9>YZe7Y}PhW{a)c39G`kg(P4@kxjcYfgB4XOOcmezdUI7j-!gs7oAo2o zx(Ph{G+YZ`a%~kzK!HTAA5NXE-7vOFRr5oqY$rH>WI6SFvWmahFav!CfRMM3%8J&c z*p+%|-fNS_@QrFr(at!JY9jCg9F-%5{nb5Bo~z@Y9m&SHYV`49GAJjA5h~h4(G!Se zZmK{Bo7ivCfvl}@A-ptkFGcWXAzj3xfl{evi-OG(TaCn1FAHxRc{}B|x+Ua1D=I6M z!C^ZIvK6aS_c&(=OQDZfm>O`Nxsw{ta&yiYPA~@e#c%N>>#rq)k6Aru-qD4(D^v)y z*>Rs;YUbD1S8^D(ps6Jbj0K3wJw>L4m)0e(6Pee3Y?gy9i0^bZO?$*sv+xKV?WBlh zAp*;v6w!a8;A7sLB*g-^<$Z4L7|5jXxxP1}hQZ<55f9<^KJ>^mKlWSGaLcO0=$jem zWyZkRwe~u{{tU63DlCaS9$Y4CP4f?+wwa(&1ou)b>72ydrFvm`Rj-0`kBJgK@nd(*Eh!(NC{F-@=FnF&Y!q`7){YsLLHf0_B6aHc# z>WIuHTyJwIH{BJ4)2RtEauC7Yq7Cytc|S)4^*t8Va3HR zg=~sN^tp9re@w=GTx$;zOWMjcg-7X3Wk^N$n;&Kf1RgVG2}2L-(0o)54C509C&77i zrjSi{X*WV=%C17((N^6R4Ya*4#6s_L99RtQ>m(%#nQ#wrRC8Y%yxkH;d!MdY+Tw@r zjpSnK`;C-U{ATcgaxoEpP0Gf+tx);buOMlK=01D|J+ROu37qc*rD(w`#O=3*O*w9?biwNoq3WN1`&Wp8TvKj3C z3HR9ssH7a&Vr<6waJrU zdLg!ieYz%U^bmpn%;(V%%ugMk92&?_XX1K@mwnVSE6!&%P%Wdi7_h`CpScvspMx?N zQUR>oadnG17#hNc$pkTp+9lW+MBKHRZ~74XWUryd)4yd zj98$%XmIL4(9OnoeO5Fnyn&fpQ9b0h4e6EHHw*l68j;>(ya`g^S&y2{O8U>1*>4zR zq*WSI_2o$CHQ?x0!wl9bpx|Cm2+kFMR)oMud1%n2=qn5nE&t@Fgr#=Zv2?}wtEz^T z9rrj=?IH*qI5{G@Rn&}^Z{+TW}mQeb9=8b<_a`&Cm#n%n~ zU47MvCBsdXFB1+adOO)03+nczfWa#vwk#r{o{dF)QWya9v2nv43Zp3%Ps}($lA02*_g25t;|T{A5snSY?3A zrRQ~(Ygh_ebltHo1VCbJb*eOAr;4cnlXLvI>*$-#AVsGg6B1r7@;g^L zFlJ_th0vxO7;-opU@WAFe;<}?!2q?RBrFK5U{*ai@NLKZ^};Ul}beukveh?TQn;$%9=R+DX07m82gP$=}Uo_%&ngV`}Hyv8g{u z3SWzTGV|cwQuFIs7ZDOqO_fGf8Q`8MwL}eUp>q?4eqCmOTcwQuXtQckPy|4F1on8l zP*h>d+cH#XQf|+6c|S{7SF(Lg>bR~l(0uY?O{OEVlaxa5@e%T&xju=o1`=OD#qc16 zSvyH*my(dcp6~VqR;o(#@m44Lug@~_qw+HA=mS#Z^4reBy8iV?H~I;{LQWk3aKK8$bLRyt$g?- h(App), +}).$mount('#app') diff --git a/doc/6/getting-started/vuejs/without-vuex/src/services/kuzzle.js b/doc/6/getting-started/vuejs/without-vuex/src/services/kuzzle.js new file mode 100644 index 000000000..06d4cdf11 --- /dev/null +++ b/doc/6/getting-started/vuejs/without-vuex/src/services/kuzzle.js @@ -0,0 +1,3 @@ +import { Kuzzle, WebSocket } from 'kuzzle-sdk'; + +export default new Kuzzle(new WebSocket('localhost')); \ No newline at end of file From 35b1532958f3b05735b60ec60d8476e67a815357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Blondel?= Date: Mon, 1 Jul 2019 11:28:31 +0200 Subject: [PATCH 23/26] make createUser id parameter optional (#408) Make createUser id parameter optional as it is in the API. --- src/controllers/security/index.js | 3 --- test/controllers/security.test.js | 12 ------------ 2 files changed, 15 deletions(-) diff --git a/src/controllers/security/index.js b/src/controllers/security/index.js index e8ccf1e51..5ec1e2d97 100644 --- a/src/controllers/security/index.js +++ b/src/controllers/security/index.js @@ -156,9 +156,6 @@ class SecurityController extends BaseController { } createUser (_id, body, options = {}) { - if (!_id) { - throw new Error('Kuzzle.security.createUser: _id is required'); - } if (!body) { throw new Error('Kuzzle.security.createUser: body is required'); } diff --git a/test/controllers/security.test.js b/test/controllers/security.test.js index ad578f129..23c185347 100644 --- a/test/controllers/security.test.js +++ b/test/controllers/security.test.js @@ -429,18 +429,6 @@ describe('Security Controller', () => { }); describe('createUser', () => { - it('should throw an error if the "_id" argument is not provided', () => { - const body = { - content: {foo: 'bar'}, - credentials: { - strategy: {foo: 'bar'} - } - }; - should(function () { - kuzzle.security.createUser(undefined, body, options); - }).throw('Kuzzle.security.createUser: _id is required'); - }); - it('should throw an error if the "body" argument is not provided', () => { should(function () { kuzzle.security.createUser('userId', undefined, options); From 438cd4b6d8db1e71534ad855901a1351aa31f9ae Mon Sep 17 00:00:00 2001 From: Berthier Esteban <44427849+berthieresteban@users.noreply.github.com> Date: Mon, 1 Jul 2019 13:44:55 +0200 Subject: [PATCH 24/26] Add-readme-to-vuejs-getting-started (#406) Add readme to vueJS getting started (without vuex) --- .../vuejs/cypress/integration/tchat.spec.js | 87 +++++++++++++ doc/6/getting-started/vuejs/index.md | 7 + .../vuejs/without-vuex/index.md | 121 ++++++++++++++++++ .../vuejs/without-vuex/src/App.vue | 77 ++++++----- 4 files changed, 253 insertions(+), 39 deletions(-) create mode 100644 doc/6/getting-started/vuejs/cypress/integration/tchat.spec.js create mode 100644 doc/6/getting-started/vuejs/index.md create mode 100644 doc/6/getting-started/vuejs/without-vuex/index.md diff --git a/doc/6/getting-started/vuejs/cypress/integration/tchat.spec.js b/doc/6/getting-started/vuejs/cypress/integration/tchat.spec.js new file mode 100644 index 000000000..6d3ad2034 --- /dev/null +++ b/doc/6/getting-started/vuejs/cypress/integration/tchat.spec.js @@ -0,0 +1,87 @@ +describe('test realtime tchat', () => { + let currentIt = 1; + let env; + + before(() => { + cy.initialisation(); + }); + + beforeEach(() => { + cy.visit('/'); + cy.fixture(`Environment.${currentIt}.json`) + .then((fixtures) => { env = fixtures; }) + .then(() => cy.log(`Environment ${currentIt}: `, env)) + .then(() => cy.loadEnvironment(env)); + cy.wait(2000); + }); + + afterEach(() => { + currentIt++; + }); + + it('should enter a nickname', () => { + cy.get('[placeholder="Enter your message"]') + .should('not.exist'); + + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + + + cy.contains('Valid') + .click(); + + cy.get('[placeholder="Enter your message"]') + .should('exist'); + cy.get('[placeholder="Enter your nickname"]') + .should('not.exist'); + }); + + it('should fetch and display some messages', () => { + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + cy.contains('Valid') + .click(); + + env.messages.forEach(message => { + cy.get(message.payload.username === env.username ? '.fromMe': '.fromOthers') + .within(() => { + cy.contains(message.payload.value); + cy.contains(message.payload.username); + }); + }); + }); + + it('should send a message', () => { + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + cy.contains('Valid') + .click(); + cy.createMessage({ + _id: '1', + payload: env.payload + }); + + cy.get('.fromMe') + .within(() => { + cy.contains(env.payload.value); + cy.contains(env.username); + }); + }); + + it('should receive a message', () => { + cy.get('[placeholder="Enter your nickname"]') + .type(env.username); + cy.contains('Valid') + .click(); + cy.createMessage({ + _id: '1', + payload: env.payload + }); + + cy.get('.fromOthers') + .within(() => { + cy.contains(env.payload.value); + cy.contains(env.payload.username); + }); + }); +}); \ No newline at end of file diff --git a/doc/6/getting-started/vuejs/index.md b/doc/6/getting-started/vuejs/index.md new file mode 100644 index 000000000..f3fa0ce0d --- /dev/null +++ b/doc/6/getting-started/vuejs/index.md @@ -0,0 +1,7 @@ +--- +code: false +type: branch +title: VueJS +description: Get started with the Javascript SDK and VueJS +order: 300 +--- diff --git a/doc/6/getting-started/vuejs/without-vuex/index.md b/doc/6/getting-started/vuejs/without-vuex/index.md new file mode 100644 index 000000000..2c8e991df --- /dev/null +++ b/doc/6/getting-started/vuejs/without-vuex/index.md @@ -0,0 +1,121 @@ +--- +type: page +code: false +title: Without Vuex +description: Getting started with Kuzzle and VueJS +order: 0 +--- + + +# Getting Started with Kuzzle and VueJS + +This section deals with **Kuzzle** (+ **Javascript SDK**) and **VueJS**. We will create **documents** in Kuzzle and subscribe to [document notifications](/sdk/js/6/essentials/realtime-notifications/#document-messages) to develop a realtime chat. + +You can find the full code of this guide [here](https://github.com/kuzzleio/sdk-javascript/tree/6-dev/doc/6/getting-started/vuejs/without-vuex). + +## Requirements + +- **Node.js** >= 8.0.0 ([install here](https://nodejs.org/en/download/)) +- **Vue CLI** ([install here](https://cli.vuejs.org/guide/installation.html)) +- **Running Kuzzle Stack** ([instructions here](/core/1/guides/getting-started/running-kuzzle/)) + +## Prepare your environment + +Create your VueJS app with Vue CLI. You'll need to select manually the features, +just add Babel, Linter and select the default options for the other features. +```bash +vue create kuzzle-playground +``` + +Install the kuzzle-sdk: +```bash +cd kuzzle-playground +yarn add kuzzle-sdk +``` + +In the _App.vue_ file, you should remove the tag, the import and the component registration of the `HelloWorld` component, we won't use it. + +## Instanciating Kuzzle SDK + +We have to connect the server so that our client can interact with it. + +To do this, we have to create _src/services/kuzzle.js_ file to put our kuzzle instance, a bit like a singleton: + +<<< ./src/services/kuzzle.js + +We need to import our Kuzzle SDK instance, so just add the following line in your `