s4-client
Installation
yarn add @propelleraero/s4-client
Usage
Basic Example
import { S4Client, BaseUrl, TableRecord } from 's4-client';
const baseUrl = BaseUrl.STAGING;
const consumer = 'cool-app-name';
const secretKey = '...';
const client = new S4Client(baseUrl, consumer, secretKey);
const tableName = 'debug';
const partitionKey = 'sensor123';
const records: TableRecord[] = [
{
timestamp: Date.now(),
value: 'cool string',
},
{
timestamp: Date.now() + 1000,
value: 'another cool string',
},
];
const insertResponse = await client.insertRecords(
tableName,
partitionKey,
records
);
console.log(insertResponse);
const start = records[0].timestamp;
const end = start + 10 * 1000;
const queryResponse = await client.retrieveRecords(
tableName,
partitionKey,
start,
end
);
console.log(queryResponse);