aliyun / aliyun-tablestore-nodejs-sdk

Aliyun TableStore(原OTS) SDK for Node.js
Apache License 2.0
88 stars 33 forks source link

使用getRow查询单行无返回结果 #65

Open grapewheel opened 1 year ago

grapewheel commented 1 year ago

使用getRow单行查询:

const tableStoreService = await useInject(TableStoreService)

const result = await tableStoreService.getRow({
    tableName: 'install',
    primaryKey: [{ sn: 'I2023091317390264223' }],
    maxVersions: 1,
})

返回(无结果):

 {
    "consumed": {
      "capacityUnit": {
        "read": 1,
        "write": 0
      }
    },
    "row": ""
  }

使用BatchGetRow多行查询:

const tableStoreService = await useInject(TableStoreService)

const result = await tableStoreService.batchGetRow({
      tables: [
          {
              tableName: 'install',
              primaryKey: [
                  [{ sn: 'I2023091317390264223' }]
              ],
              maxVersions: 1,
          },
      ],
})

返回(有结果):

{
    "tables": [
      [
        {
          "isOk": true,
          "errorCode": null,
          "errorMessage": null,
          "tableName": "install",
          "capacityUnit": {
            "read": 1,
            "write": 0
          },
          "primaryKey": [
            {
              "name": "sn",
              "value": "I2023091317390264223"
            }
          ],
          "attributes": [
            {
              "columnName": "electricPrice",
              "columnValue": 0.8,
              "timestamp": 1694597943098
            },
           ...
          ]
        }
      ]
    ],
}

使用阿里云tablestore后台是能查询的