Reading and inserting data

    The only difference is that VerifiedSet returns proofs needed to mathematically verify that the data was not tampered. Note that generating that proof has a slight performance impact, so primitives are allowed without the proof. It is still possible get the proofs for a specific item at any time, so the decision about when or how frequently to do checks (with the Verify version of a method) is completely up to the user. It’s possible also to use dedicated auditors to ensure the database consistency, but the pattern in which every client is also an auditor is the more interesting one.

    1. byte[] value = new byte[]{1, 2, 3};
    2. try {
    3. immuClient.set(key, value);
    4. } catch (CorruptedDataException e) {
    5. // ...
    6. }
    7. try {
    8. value = immuClient.get(key);
    9. } catch (Exception e) {
    10. // ...
    11. }

    Note that value is a primitive byte array. You can set the value of a String using:
    "some string".getBytes(StandardCharsets.UTF_8)

    Also, set method is overloaded to allow receiving the key parameter as a byte[] data type.

    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 = { key: 'hello', value: 'world' }
    11. const setRes = await cl.set(setReq)
    12. console.log('success: set', setRes)
    13. const getReq: Parameters.Get = { key: 'hello' }
    14. const getRes = await cl.get(getReq)
    15. console.log('success: get', getRes)
    16. })()

    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 projectReading and inserting data - 图2 (opens new window)

    You can retrieve a key on a specific transaction with VerifiedGetAt and since a specific transaction with VerifiedGetSince.

    1. ventry, err = client.VerifiedGetAt(ctx, []byte(`key`), meta.Id)
    2. if err != nil {
    3. log.Fatal(err)
    4. }
    5. fmt.Printf("Successfully retrieved entry at %v with value %s\n", ventry.Tx, ventry.Value)
    6. ventry, err = client.VerifiedGetSince(ctx, []byte(`key`), 4)
    7. if err != nil {
    8. log.Fatal(err)
    9. }
    10. fmt.Printf("Successfully retrieved entry at %v with value %s\n", ventry.Tx, ventry.Value)

    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_USER = 'immudb'
    4. const IMMUDB_PWD = 'immudb'
    5. const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
    6. (async () => {
    7. await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
    8. const { id } = await cl.set({ key: 'key', value: 'value' })
    9. const verifiedGetAtReq: Parameters.VerifiedGetAt = {
    10. key: 'key',
    11. attx: id
    12. }
    13. const verifiedGetAtRes = await cl.verifiedGetAt(verifiedGetAtReq)
    14. console.log('success: verifiedGetAt', verifiedGetAtRes)
    15. for (let i = 0; i < 4; i++) {
    16. await cl.set({ key: 'key', value: `value-${i}` })
    17. }
    18. const verifiedGetSinceReq: Parameters.VerifiedGetSince = {
    19. key: 'key',
    20. sincetx: 2
    21. }
    22. const verifiedGetSinceRes = await cl.verifiedGetSince(verifiedGetSinceReq)
    23. console.log('success: verifiedGetSince', verifiedGetSinceRes)
    24. })()

    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 projectReading and inserting data - 图5 (opens new window)

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

    It’s possible to retrieve all the keys inside a specific transaction.

    1. setRequest := &schema.SetRequest{KVs: []*schema.KeyValue{
    2. {Key: []byte("key1"), Value: []byte("val1")},
    3. {Key: []byte("key2"), Value: []byte("val2")},
    4. }}
    5. meta, err := client.SetAll(ctx, setRequest)
    6. if err != nil {
    7. log.Fatal(err)
    8. }
    9. tx , err := client.TxByID(ctx, meta.Id)
    10. if err != nil {
    11. log.Fatal(err)
    12. }
    13. for _, entry := range tx.Entries {
    14. item, err := client.VerifiedGetAt(ctx, entry.Key, meta.Id)
    15. if err != nil {
    16. log.Fatal(err)
    17. }
    18. fmt.Printf("retrieved key %s and val %s\n", item.Key, item.Value)
    19. }
    1. TxMetadata txMd = null;
    2. try {
    3. txMd = immuClient.verifiedSet(key, val);
    4. } catch (VerificationException e) {
    5. // ...
    6. try {
    7. Tx tx = immuClient.txById(txMd.id);
    8. } catch (MaxWidthExceededException | NoSuchAlgorithmException e) {
    9. // ...
    10. }

    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 projectReading and inserting data - 图8 (opens new window)

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

    It’s possible to retrieve all the keys inside a specific verified transaction.

    1. setRequest := &schema.SetRequest{KVs: []*schema.KeyValue{
    2. {Key: []byte("key1"), Value: []byte("val1")},
    3. {Key: []byte("key2"), Value: []byte("val2")},
    4. }}
    5. meta, err := client.SetAll(ctx, setRequest)
    6. if err != nil {
    7. log.Fatal(err)
    8. }
    9. tx , err := client.VerifiedTxByID(ctx, meta.Id)
    10. if err != nil {
    11. log.Fatal(err)
    12. }
    13. for _, entry := range tx.Entries {
    14. item, err := client.VerifiedGetAt(ctx, entry.Key, meta.Id)
    15. if err != nil {
    16. log.Fatal(err)
    17. }
    18. fmt.Printf("retrieved key %s and val %s\n", item.Key, item.Value)
    19. }
    1. TxMetadata txMd = null;
    2. try {
    3. txMd = immuClient.verifiedSet(key, val);
    4. } catch (VerificationException e) {
    5. // ...
    6. }
    7. try {
    8. Tx tx = immuClient.verifiedTxById(txMd.id);
    9. } catch (VerificationException e) {
    10. // ...
    11. }

    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 projectReading and inserting data - 图10 (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: 'key', value: 'value' })
    11. const verifiedTxByIdReq: Parameters.VerifiedTxById = { tx: id }
    12. const verifiedTxByIdRes = await cl.verifiedTxByID(verifiedTxByIdReq)

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