aliyun / aliyun-tablestore-nodejs-sdk

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

batchWriteRow update 异常 #35

Open mxinglee opened 4 years ago

mxinglee commented 4 years ago

函数计算中 nodejs代码如下:

   var params = {
        tables: [
            {
                tableName: "XXX",
                rows: [
                    {
                        type: "PUT",
                        condition: new TableStore.Condition(TableStore.RowExistenceExpectation.EXPECT_NOT_EXIST, null),
                        primaryKey: [{ 'PK': "XXX" }],
                        attributeColumns: [
                            { 'content': req.body.content },
                            { 'author': author }
                        ]
                    },
                    {
                        type: "UPDATE",
                        condition: new TableStore.Condition(
                            TableStore.RowExistenceExpectation.EXPECT_EXIST,
                            null
                        ),
                        primaryKey: [  { 'PK': "another_XXXX" } ],
                        attributeColumns: [ { 'INCREMENT': [{'cnt': Long.fromNumber(1) }] } ]
                    }
                ]
            }
        ]
    };

    iDiaryDb.batchWriteRow(params, function(err, data) {
       // ....
    });

异常信息: at Request.emit (/usr/local/lib/node_modules/tablestore/lib/request.js:189:14) retryable: false } 'Error: Expect TableStore.UpdateType but it was:INCREMENT\n at Object.computeUpdateRowSize (/usr/local/lib/node_modules/tablestore/lib/protocol/plian_buffer_builder.js:142:35)\n at Object.serializeForUpdateRow (/usr/local/lib/node_modules/tablestore/lib/protocol/plian_buffer_builder.js:210:28)\n at Object.encodeBatchWriteRow [as batchWriteRow] (/usr/local/lib/node_modules/tablestore/lib/protocol/encoder.js:327:72)\n at Object.encode (/usr/local/lib/node_modules/tablestore/lib/protocol/encoder.js:13:32)\n at Request.buildContent (/usr/local/lib/node_modules/tablestore/lib/client.js:35:38)\n at Request.callListeners (/usr/local/lib/node_modules/tablestore/lib/sequential_executor.js:113:20)\n at Request.callListeners (/usr/local/lib/node_modules/tablestore/lib/sequential_executor.js:114:16)\n at Request.callListeners (/usr/local/lib/node_modules/tablestore/lib/sequential_executor.js:114:16)\n at Request.emit (/usr/local/lib/node_modules/tablestore/lib/sequential_executor.js:81:10)\n at Request.emit (/usr/local/lib/node_modules/tablestore/lib/request.js:189:14)' 收起


我尝试使用batchWriteRow 中使用两个PUT 类型操作,可以成功执行。