Created
May 1, 2021 07:27
-
-
Save mr-pascal/89050c587a1c47a7ff8765b63f2b3dbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @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