Atomic counter provides real-time statistics for online applications, such as the real-time page views (PVs) of a post.

Note For more information about atomic counters, see Atomic counters.


The following parameters have been added to the updateRow operation to operate an atomic counter:
  • INCREMENT related logic is added to updateOfAttributeColumns to increment or decrement an attribute value by a number.
  • returnColumns in returnContent is used to specify the column on which the atomic counter operation is performed. returnType is used to specify the type of the returned value. TableStore.ReturnType.AfterModify is used to specify that the updated column values must be returned.


The following code provides an example on how to use the updateRow operation to update the columns whose valid values are integers when you write a row of data:
var params = {
  tableName: "<Your-Table-Name>",
  condition: new TableStore.Condition(TableStore.RowExistenceExpectation.EXPECT_EXIST, null),
  primaryKey: [{'pk0': Long.fromNumber(1)}],
  // Perform an atomic counter operation on the price attribute.
  updateOfAttributeColumns: [
    {'INCREMENT': [{'price': Long.fromNumber(10)}]}
  // Return the updated values of the price attribute.
  returnContent: {
    returnColumns: ["price"],
    returnType: TableStore.ReturnType.AfterModify

  function (err, data) {
    if (err) {
      console.log('error:', err);

    console.log('success:', JSON.stringify(data, null, 2));