Entries

Entries

MutableData Entries operations

Constructor

new Entries()

Source:

Methods

get(keyName) → {Promise.<ValueVersion>}

Look up the value of a specific key

Parameters:
Name Type Description
keyName String

the key to lookup

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 entries = await mData.getEntries();
        const value = await entries.get('surname')
    } catch(err) {
      throw err;
    }
};

insert(keyName, value) → {Promise}

Insert a new entry. Once you call MutableData.put with this entry, it will fail if the entry already exists or the current app doesn't have the permissions to edit that MutableData.

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  entriesArray = await entries.insert('given_name', 'Alan');
    } catch(err) {
      throw err;
    }
};

len() → {Promise.<Number>}

Get the total number of entries in the MutableData

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 perms = await mData.getPermissions();
      const length = await perms.len();
    } catch(err) {
      throw err;
    }
};

listEntries() → {Promise.<Array>}

Get a list with the entries contained in this MutableData

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
        const mData = await app.mutableData.newRandomPublic(15001);
        await mData.quickSetup({ key1: 'value1', key2: 'value2' });
        const entries = await mData.getEntries();
        const  entriesArray = await entries.listEntries();
        entriesArray.forEach((entry) => {
          const key = entry.key.toString();
          const value = entry.value.buf.toString();
          console.log('Key: ', key);
          console.log('Value: ', value);
        });
    } catch(err) {
      throw err;
    }
};

mutate() → {Promise.<EntryMutationTransaction>}

Create a new mutation transaction for the entries

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  mutationIntertace = await entries.mutate();
    } catch(err) {
      throw err;
    }
};