Queries and history

    accepts the following parameters:

    • Key: a key of an item
    • Offset: the starting index (excluded from the search). Optional
    • Limit: maximum returned items. Optional
    • Desc: items are returned in reverse order. Optional
    • SinceTx:
    1. try {
    2. immuClient.set("hello", value1);
    3. immuClient.set("hello", value2);
    4. } catch (CorruptedDataException e) {
    5. // ...
    6. }
    7. List<KV> historyResponse1 = immuClient.history("hello", 10, 0, false, 1);

    Note that, similar with many other methods, history method is overloaded to allow different kinds/set of parameters.

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Python sdk github project (opens new window)

    1. import ImmudbClient from 'immudb-node'
    2. import Parameters from 'immudb-node/types/parameters'
    3. const IMMUDB_HOST = '127.0.0.1'
    4. const IMMUDB_PORT = '3322'
    5. const IMMUDB_USER = 'immudb'
    6. const IMMUDB_PWD = 'immudb'
    7. const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
    8. (async () => {
    9. await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
    10. const key = 'hello'
    11. await cl.set({ key, value: 'immutable world' })
    12. await cl.set({ key, value: 'immudb' })
    13. const historyReq: Parameters.History = {
    14. key
    15. }
    16. const historyRes = cl.history(historyReq)
    17. console.log('success: history', historyRes)
    18. })()

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    If you’re using another development language, please read up on our immugw (opens new window) option.

    Counting entries is not supported at the moment.

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Java sdk github project (opens new window)

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Node.js sdk github project (opens new window)

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    The scan command is used to iterate over the collection of elements present in the currently selected database. Scan accepts the following parameters:

    • Prefix: prefix. If not provided all keys will be involved. Optional
    • SeekKey: initial key for the first entry in the iteration. Optional
    • Desc: DESC or ASC sorting order. Optional
    • Limit: maximum returned items. Optional
    • SinceTx: immudb will wait that the transaction provided by SinceTx be processed. Optional
    • NoWait: Default false. When true scan doesn’t wait for the index to be fully generated and returns the last indexed value. Optional

    An ordinary scan command and a reversed one.

    1. client.Set(ctx, []byte(`aaa`), []byte(`item1`))
    2. client.Set(ctx, []byte(`bbb`), []byte(`item2`))
    3. client.Set(ctx, []byte(`abc`),[]byte(`item3`))
    4. scanReq := &schema.ScanRequest{
    5. Prefix: []byte(`a`),
    6. }
    7. list, err := client.Scan(ctx, scanReq)
    8. if err != nil {
    9. log.Fatal(err)
    10. }
    11. fmt.Printf("%v\n", list)
    12. scanReq1 := &schema.ScanRequest{
    13. SeekKey: []byte{0xFF},
    14. Prefix: []byte(`a`),
    15. Desc: true,
    16. }
    17. list, err = client.Scan(ctx, scanReq1)
    18. if err != nil {
    19. log.Fatal(err)
    20. }
    21. fmt.Printf("%v\n", list)
    22. // scan on all key values on the current database, with a fresh snapshot
    23. scanReq2 := &schema.ScanRequest{
    24. SeekKey: []byte{0xFF},
    25. Desc: true,
    26. SinceTx: math.MaxUint64,
    27. }
    28. list, err = client.Scan(ctx, scanReq2)
    29. if err != nil {
    30. log.Fatal(err)
    31. }
    32. fmt.Printf("%v\n", list)
    1. byte[] value1 = {0, 1, 2, 3};
    2. byte[] value2 = {4, 5, 6, 7};
    3. try {
    4. immuClient.set("scan1", value1);
    5. immuClient.set("scan2", value2);
    6. } catch (CorruptedDataException e) {
    7. // ...
    8. }
    9. // Example of using scan(prefix, sinceTxId, limit, desc).
    10. List<KV> scanResult = immuClient.scan("scan", 1, 5, false);
    11. // We expect two entries in the result.

    scan is an overloaded method, therefore multiple flavours of it with different parameter options exist.

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Python sdk github project (opens new window)

    Example with an offset:

    1. import ImmudbClient from 'immudb-node'
    2. import Parameters from 'immudb-node/types/parameters'
    3. const IMMUDB_HOST = '127.0.0.1'
    4. const IMMUDB_PORT = '3322'
    5. const IMMUDB_USER = 'immudb'
    6. const IMMUDB_PWD = 'immudb'
    7. const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
    8. (async () => {
    9. await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
    10. await cl.set({ key: 'abc', value: 'item3' })
    11. const scanReq: Parameters.Scan = {
    12. seekkey: '',
    13. prefix: '',
    14. desc: true,
    15. limit: 0,
    16. sincetx: 0
    17. }
    18. const scanRes = await cl.scan(scanReq)
    19. console.log('success: scan', scanRes)
    20. const scanReq1: Parameters.Scan = {
    21. seekkey: 'bbb',
    22. prefix: '',
    23. desc: true,
    24. limit: 0,
    25. sincetx: 0
    26. }
    27. const scanRes1 = await cl.scan(scanReq1)
    28. console.log('success: scan', scanRes1)
    29. const scanReq2: Parameters.Scan = {
    30. seekkey: 'b',
    31. prefix: 'b',
    32. desc: true,
    33. limit: 0,
    34. sincetx: 0
    35. }
    36. const scanRes2 = await cl.scan(scanReq2)
    37. console.log('success: scan', scanRes2)
    38. })()

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    If you’re using another development language, please read up on our immugw (opens new window) option.

    SetReference is like a “tag” operation. It appends a reference on a key/value element. As a consequence, when we retrieve that reference with a Get or VerifiedGet the value retrieved will be the original value associated with the original key. Its VerifiedReference counterpart is the same except that it also produces the inclusion and consistency proofs.

    1. _, err = client.Set(ctx, []byte(`firstKey`),[]byte(`firstValue`))
    2. if err != nil {
    3. log.Fatal(err)
    4. }
    5. reference, err := client.SetReference(ctx, []byte(`myTag`), []byte(`firstKey`))
    6. if err != nil {
    7. log.Fatal(err)
    8. }
    9. fmt.Printf("%v\n", reference)
    10. firstItem, err := client.Get(ctx, []byte(`myTag`))
    11. if err != nil {
    12. log.Fatal(err)
    13. }
    14. fmt.Printf("%v\n", firstItem)

    Example with verifications

    1. _, err = client.Set(ctx, []byte(`secondKey`),[]byte(`secondValue`))
    2. if err != nil {
    3. log.Fatal(err)
    4. }
    5. reference, err = client.VerifiedSetReference(ctx, []byte(`mySecondTag`), []byte(`secondKey`))
    6. if err != nil {
    7. log.Fatal(err)
    8. }
    9. fmt.Printf("%v\n", reference)
    10. secondItem, err := client.Get(ctx, []byte(`mySecondTag`))
    11. if err != nil {
    12. log.Fatal(err)
    13. }
    14. fmt.Printf("%v\n", secondItem)
    1. byte[] key = "testRef".getBytes(StandardCharsets.UTF_8);
    2. byte[] val = "abc".getBytes(StandardCharsets.UTF_8);
    3. TxMetadata txMd = null;
    4. try {
    5. txMd = immuClient.set(key, val);
    6. } catch (CorruptedDataException e) {
    7. // ...
    8. }
    9. byte[] ref1Key = "ref1_to_testRef".getBytes(StandardCharsets.UTF_8);
    10. byte[] ref2Key = "ref2_to_testRef".getBytes(StandardCharsets.UTF_8);
    11. try {
    12. txMd = immuClient.setReference(ref1Key, key);
    13. } catch (CorruptedDataException e) {
    14. // ...
    15. }
    16. try {
    17. txMd = immuClient.verifiedSetReference(ref2Key, key);
    18. } catch (VerificationException e) {
    19. // ...
    20. }

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    1. import ImmudbClient from 'immudb-node'
    2. import Parameters from 'immudb-node/types/parameters'
    3. const IMMUDB_HOST = '127.0.0.1'
    4. const IMMUDB_PORT = '3322'
    5. const IMMUDB_USER = 'immudb'
    6. const IMMUDB_PWD = 'immudb'
    7. const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
    8. (async () => {
    9. await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
    10. const setReq: Parameters.Set = {
    11. key: 'firstKey',
    12. value: 'firstValue'
    13. }
    14. await cl.set(setReq)
    15. const verifiedReferenceReq: Parameters.SetReference = {
    16. key: 'myTag',
    17. referencedKey: 'firstKey'
    18. }
    19. const verifiedReferenceRes = await cl.verifiedSetReference(verifiedReferenceReq)
    20. const getReq: Parameters.Get = {
    21. key: 'myTag'
    22. }
    23. const getRes = await cl.get(getReq)
    24. console.log('success: get by reference', getRes)
    25. })()

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on .Net sdk github project (opens new window)

    If you’re using another development language, please read up on our option.

    When reference is resolved with get or verifiedGet in case of multiples equals references the last reference is returned.

    1. _, err = client.Set(ctx, []byte(`secondKey`),[]byte(`secondValue`))
    2. if err != nil {
    3. log.Fatal(err)
    4. }
    5. _, err = client.Set(ctx, []byte(`secondKey`),[]byte(`thirdValue`))
    6. if err != nil {
    7. log.Fatal(err)
    8. }
    9. reference, err = client.VerifiedSetReference(ctx, []byte(`myThirdTag`), []byte(`secondKey`))
    10. if err != nil {
    11. log.Fatal(err)
    12. }
    13. fmt.Printf("%v\n", reference)
    14. thirdItem, err := client.Get(ctx, []byte(`myThirdTag`))
    15. if err != nil {
    16. log.Fatal(err)
    17. }
    18. fmt.Printf("%v\n", thirdItem)

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Java sdk github project (opens new window)

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    1. import ImmudbClient from 'immudb-node'
    2. import Parameters from 'immudb-node/types/parameters'
    3. const IMMUDB_HOST = '127.0.0.1'
    4. const IMMUDB_PORT = '3322'
    5. const IMMUDB_USER = 'immudb'
    6. const IMMUDB_PWD = 'immudb'
    7. const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
    8. (async () => {
    9. await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
    10. const setReq: Parameters.Set = {
    11. key: 'firstKey',
    12. value: 'firstValue'
    13. }
    14. await cl.set(setReq)
    15. const setReq1: Parameters.Set = {
    16. key: 'secondKey',
    17. value: 'secondValue'
    18. }
    19. await cl.set(setReq1)
    20. const verifiedReferenceReq: Parameters.SetReference = {
    21. key: 'myTag',
    22. referencedKey: 'firstKey'
    23. }
    24. await cl.verifiedSetReference(verifiedReferenceReq)
    25. const verifiedReferenceReq1: Parameters.SetReference = {
    26. key: 'myTag',
    27. referencedKey: 'secondKey'
    28. }
    29. await cl.verifiedSetReference(verifiedReferenceReq1)
    30. const getReq: Parameters.Get = {
    31. key: 'myTag'
    32. }
    33. const getSecondItemRes = await cl.get(getReq)
    34. console.log('success: get by second reference', getSecondItemRes)
    35. })()

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on .Net sdk github project (opens new window)

    If you’re using another development language, please read up on our option.

    It’s possible to bind a reference to a key on a specific transaction using SetReferenceAt and VerifiedSetReferenceAt

    1. meta, err := client.Set(ctx, []byte(`secondKey`),[]byte(`secondValue`))
    2. if err != nil {
    3. log.Fatal(err)
    4. }
    5. _ , err = client.Set(ctx, []byte(`secondKey`),[]byte(`thirdValue`))
    6. if err != nil {
    7. log.Fatal(err)
    8. }
    9. reference, err = client.VerifiedSetReferenceAt(ctx, []byte(`myThirdTag`), []byte(`secondKey`), meta.Id )
    10. if err != nil {
    11. log.Fatal(err)
    12. }
    13. fmt.Printf("%v\n", reference)
    14. thirdItem, err := client.Get(ctx, []byte(`myThirdTag`))
    15. if err != nil {
    16. log.Fatal(err)
    17. }
    18. fmt.Printf("%v\n", thirdItem)

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Python sdk github project (opens new window)

    1. import ImmudbClient from 'immudb-node'
    2. import Parameters from 'immudb-node/types/parameters'
    3. const IMMUDB_HOST = '127.0.0.1'
    4. const IMMUDB_PORT = '3322'
    5. const IMMUDB_USER = 'immudb'
    6. const IMMUDB_PWD = 'immudb'
    7. const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
    8. (async () => {
    9. await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
    10. const { id } = await cl.set({ key: 'firstKey', value: 'firstValue' })
    11. await cl.set({ key: 'firstKey', value: 'secondValue' })
    12. const verifiedSetReferenceAtReq: Parameters.VerifiedSetReferenceAt = {
    13. key: 'myFirstTag',
    14. referencedKey: 'firstKey',
    15. attx: id
    16. }
    17. const verifiedSetReferenceAtRes = await cl.verifiedSetReferenceAt(verifiedSetReferenceAtReq)
    18. console.log('success: verifiedSetReferenceAt', verifiedSetReferenceAtRes)
    19. const getSecondItemRes = await cl.get({ key: 'myFirstTag' })
    20. console.log('success: get second item by reference', getSecondItemRes)

    This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on

    If you’re using another development language, please read up on our immugw (opens new window) option.