Как получить указанные c столбцы и применить условие в DynamoDB? - PullRequest
0 голосов
/ 01 мая 2020

Я пытаюсь получить 3 столбца и применить условие к одному из параметров.

  const result = await docClient.scan({
    TableName: ridesTable,
    AttributesToGet: ['from_city_id', 'from_date', 'Car_Cancellation'],
    FilterExpression: 'Car_Cancellation = :one',
    ExpressionAttributeValues : {':one' : 1}
  }).promise()

но я получаю эту ошибку при запуске

{
    "errorType": "ValidationException",
    "errorMessage": "Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {AttributesToGet} Expression parameters: {FilterExpression}",
    "code": "ValidationException",
    "message": "Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {AttributesToGet} Expression parameters: {FilterExpression}",
    "time": "2020-05-01T20:08:30.178Z",
    "requestId": "BFPV6QL9U98FC93312C89Q6SKFVV4KQNSO5AEMVJF66Q9ASUAAJG",
    "statusCode": 400,
    "retryable": false,
    "retryDelay": 25.189864204800905,
    "stack": [
        "ValidationException: Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {AttributesToGet} Expression parameters: {FilterExpression}",
        "    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:51:27)",
        "    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
        "    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
        "    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
        "    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
        "    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
        "    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
        "    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
        "    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
        "    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
    ]
}

Что означает эта строка?

Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {AttributesToGet} Expression parameters: {FilterExpression}"

Как я могу go вокруг нее

1 Ответ

1 голос
/ 01 мая 2020

AttributesToGet - это устаревший параметр, и вы смешали устаревший API с более новым API на основе выражений. Вместо этого используйте ProjectionExpression .

...