Call `getRow` in the Tablestore Node.js SDK to read a single row. Use primary keys, version ranges, and column filters to control the response.
Notes
Provide the complete primary key, including the auto-increment primary key column value.
Prerequisites
Method
getRow: function getRow(params, callback)
Examples
Read a row with primary key value `row1`:
var params = {
tableName: 'test_table',
primaryKey: [{ 'id': 'row1' }]
};
client.getRow(params, function (err, data) {
if (err) {
console.log('Get row failed with error: ', err);
return;
}
console.log('Read CU Cost: ', data.consumed.capacityUnit.read);
console.log('Write CU Cost: ', data.consumed.capacityUnit.write);
console.log('Row Data: ', JSON.stringify(data.row));
});
-
Set a time range. Only versions within this range are returned.
params.timeRange = { startTime: (Date.now() - 86400 * 1000).toString(), endTime: Date.now().toString() } -
Specify the attribute columns to read.
params.columnsToGet = ['col2']