0
我現在有一個表:迪納摩壞阿比異常
{
"AttributeDefinitions": [
{
"AttributeName": "soAssetId",
"AttributeType": "N"
},
{
"AttributeName": "timestamp",
"AttributeType": "N"
}
],
"TableName": "odm-rates",
"KeySchema": [
{
"AttributeName": "soAssetId",
"KeyType": "HASH"
},
{
"AttributeName": "timestamp",
"KeyType": "RANGE"
}
],
"TableStatus": "ACTIVE",
"CreationDateTime": "2017-10-15T15:24:14.470Z",
"ProvisionedThroughput": {
"LastIncreaseDateTime": "1970-01-01T00:00:00.000Z",
"LastDecreaseDateTime": "1970-01-01T00:00:00.000Z",
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:ddblocal:000000000000:table/odm-rates",
"GlobalSecondaryIndexes": [
{
"IndexName": "rateRange",
"KeySchema": [
{
"AttributeName": "soAssetId",
"KeyType": "HASH"
},
{
"AttributeName": "timestamp",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"IndexStatus": "ACTIVE",
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"IndexSizeBytes": 0,
"ItemCount": 0,
"IndexArn": "arn:aws:dynamodb:ddblocal:000000000000:table/odm-rates/index/rateRange"
}
]
}
當我嘗試寫:
dynamo.batchWriteItem({
RequestItems: {
"odm-rates": [{},
{
PutRequest: {
Item: {
"soAssetId": { N: "143" },
"value": { S: "13423423" },
"bidValue": { S: "234234234" },
"askValue": { S: "5433434343" },
"timestamp": { N: "324234234" }
}
}
}
]
}
}, function(err, data) {
console.log("LOG");
if (err) console.log(err);
else console.log(data);
});
我得到以下異常:
{ ValidationException: Supplied AttributeValue has more than one datatypes set, must contain exactly one of the supported datatypes
at Request.extractError (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /sites/nsfxpricer/node/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/sites/nsfxpricer/node/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
message: 'Supplied AttributeValue has more than one datatypes set, must contain exactly one of the supported datatypes',
code: 'ValidationException',
time: 2017-10-15T16:10:16.201Z,
requestId: '61bdb8cc-cb17-401a-b461-c22f2efd7454',
statusCode: 400,
retryable: false,
retryDelay: 36.32793383670548 }
我已經試過像插入數據有200種不同的方式,但實際的異常似乎與潛在的問題完全無關。官方的API簡直是poo-poo?我如何正確創建二級索引?
爲什麼你在這裏有一個空對象作爲數組中的第一項:'「odm-rates」:[{},'。 –