All Products
Search
Document Center

Tablestore:Read a single row

Last Updated:Jun 04, 2026

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

Initialize a Tablestore client

Method

getRow: function getRow(params, callback)

Parameters

Name

Type

Description

tableName (Required)

string

The table name.

primaryKey (Required)

Array

The primary key columns, including names and values.

  • Supported data types: STRING, INTEGER, and BINARY.

  • The number and types of primary key columns must match the table schema.

maxVersions (Optional)

number

The maximum number of versions to return. Default: 1.

  • If more versions match than the specified maximum, the latest versions are returned first.

timeRange (Optional)

object

The version range to query.

  • Each attribute column can have multiple versions. Only versions within the specified range are returned.

columnsToGet (Optional)

Array

The columns to read. Can be primary key or attribute columns.

  • If not set, the entire row is returned.

  • If the row contains none of the specified columns, null is returned.

columnFilter (Optional)

TableStore.ColumnCondition

The filter condition. Filters.

  • When both columnsToGet and columnFilter are set, columns are selected first, then filtered.

transactionId (Optional)

string

The local transaction ID. Local transactions.

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']

References