aws-DynamoDB的多列格式
在AWS 的IOT-Core 中通过rule engines 将smoke alert event 转存到 (通过Lambda -->)Dynamodb 中,结果发现,数据都放在一列里面了。
-------------------------------------------------------------------------
鼓捣了很久还没解决这个问题,后面看了些文档在Lambda 中处理:
var params = {
Item:{
date:Date.now(),
message: "Hello, AWS Lambda-DynamoDB-5",
CODensity: event.state.reported.CODensity,
BatteryCapacity: event.state.reported.BatteryCapacity,
ProductLifeCycle: event.state.reported.ProductLifeCycle,
SmokeErrState: event.state.reported.SmokeErrState,
SmokeAlertFlag: event.state.reported.SmokeAlertFlag
},
TableName: 'Lambda-Write-to-Dynamodb'
};
docClient.put(params, function(err, data){
if (err){
console.log("fail to write into Dynamodb");
callback(err, null);
}else{
console.log("successfully write into AWS Dynamodb");
callback(null, data);
}
});
----------------------------------------------------------------------
结果如下:
--------------------------------------------------------------------------