我有以下代码:
exports.handler = function(event, context) {
console.log("Request received:\n", JSON.stringify(event));
console.log("Context received:\n", JSON.stringify(context));
var doc = require('dynamodb-doc');
var dynamodb = new doc.DynamoDB();
var Message = callback();
var datetiem = new Date().toISOString().split('T')[0];
console.log('date is ', datetiem); // prints 2018-01-09
var datetime1 = JSON.stringify(datetiem);
console.log(datetime1); //prints "2018-01-09"
var params = {
Key: {
"abc" : datetime1
},
TableName: 'myTable',
ProjectionExpression: 'message'
};
function callback (message) {
dynamodb.getItem(params, function (err, data) {
if (err) {
context.fail('ERROR: Dynamo failed: ' + err);
} else {
console.log('Dynamo Success: ' + JSON.stringify(data, null, ' '));
console.log('data', data)
let Message = data['Item'].message;
console.log('test',Message);
}
});
}
};
问题是,当我尝试在Eventhandler中读取原始值时,我得到public Test() {
var dt = new DataTable("arguments");
dt.Columns.Add("id", typeof(string));
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("type", typeof(string));
dt.Rows.Add("a", "b", "c");
dt.Rows.Add("1", "2", "3");
dt.RowDeleted += DtOnRowDeleted;
dt.Rows[0].Delete();
}
private void DtOnRowDeleted(object sender, DataRowChangeEventArgs e) {
var id = e.Row["id", DataRowVersion.Original];
}
:
VersionNotFoundException
如何从已删除的数据行中获取ID?
答案 0 :(得分:0)
在设置表格后添加AcceptChanges方法。
dt.Rows.Add("a", "b", "c");
dt.Rows.Add("1", "2", "3");
dt.AcceptChanges();
dt.RowDeleted += DtOnRowDeleted;