EntryMutationTransaction

EntryMutationTransaction

Creates mutation actions to be applied to MutableData

Constructor

new EntryMutationTransaction()

Source:

Methods

delete(keyName, version) → {Promise}

Creates an action to delete an existing entry. Does not commit to network.

Parameters:
Name Type Description
keyName String | Buffer

the key you want to delete

version Number

The version successor, to confirm you are actually asking for the correct MutableData version.

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
       const mData = await app.mutableData.newRandomPublic(15001);
       await mData.quickSetup({ surname: 'Turing' });
       const version = await mData.getVersion();
       const entries = await mData.getEntries();
       const keyName = 'dnaChecksum';
       await entries.delete(keyName, version + 1);
    } catch(err) {
      throw err;
    }
};

insert(keyName, value) → {Promise}

Creates an action to store a new key/value entry. Does not commit to network.

Parameters:
Name Type Description
keyName String | Buffer
value String | Buffer
Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
       const mData = await app.mutableData.newRandomPublic(15001);
       await mData.quickSetup({});
       const entries = await mData.getEntries();
       const keyName = 'surname';
       const value = 'Turing';
       await entries.insert(keyName, value);
    } catch(err) {
      throw err;
    }
};

update(keyName, value, version) → {Promise}

Creates an action to update an existing entry. Does not commit to network.

Parameters:
Name Type Description
keyName String | Buffer
value String | Buffer
version Number

The version successor, to confirm you are actually asking for the correct MutableData version.

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
       const mData = await app.mutableData.newRandomPublic(15001);
       await mData.quickSetup({ surname: 'Turing' });
       const version = await mData.getVersion();
       const entries = await mData.getEntries();
       const keyName = 'street_address';
       const value = '7297 Highfield Road';
       await entries.update(keyName, value, version + 1);
    } catch(err) {
      throw err;
    }
};