Skip to content

Instantly share code, notes, and snippets.

@mr-pascal
Created May 1, 2021 07:27
Show Gist options
  • Select an option

  • Save mr-pascal/89050c587a1c47a7ff8765b63f2b3dbf to your computer and use it in GitHub Desktop.

Select an option

Save mr-pascal/89050c587a1c47a7ff8765b63f2b3dbf to your computer and use it in GitHub Desktop.
/**
*
* @param {Object} el
* @param {string} el.key
* @param {number} el.value
* @returns
*/
const createSimpleRow = (el) => ({
key: el.key,
data: {
[COLUMN_FAMILY_ID_1]: {
[COLUMN_QUALIFIER_1]: {
timestamp: new Date(),
value: el.value,
},
},
},
});
/**
*
* @param {Table} table
*/
const writeData = async (table) => {
let data, rowsToInsert;
// Write first set of data
data = [{ key: 'a', value: 1 }, { key: 'b', value: 2 }, { key: 'c', value: 3 }, { key: 'd', value: 4 }, { key: 'e', value: 5 }];
rowsToInsert = data.map(createSimpleRow);
await table.insert(rowsToInsert);
sleep(250);
data = [{ key: 'e', value: 10 }];
rowsToInsert = data.map(createSimpleRow);
await table.insert(rowsToInsert);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment