node.js と Express を使用して、DynamoDB ローカルから html テーブルに項目をリストしようとしています。DynamoDB データは次のようになります。
{"Items": [{ "id": "A004","name": "ACC LR2","userId": ["1","2","3","4"], {"id": "0001","name": "ABG IT","userId": [ "8","9","10","11"]}}]}
私のnodejsルートは次のようになります:
router.get('/groups', function(req, res, next) {
var params = {
TableName: 'userGroup',
};
dynamodb.scan(params, function(err, data) {
if (err) {
console.log(err);
}
else {
console.log("These are Groups: "+ console.log(JSON.stringify(data.Items)));
res.render('groups',{_uG : data.Items});
}
});
});
HTMLの私のテーブルは次のようになります:
<table>
<thead>
<th>Id</th>
<th>name</th>
<th>user id</th>
</thead>
<tbody>
<% for(var i = 0; i < _uG.length; i++) { %>
<tr class="gradeA even" role="row">
<td class="sorting_1"><%= _uG[i].id.S %></td>
<td><%= _uG[i].name.S %></td>
<td><%= _uG[i].userId[i].L %></td>
</tr>
<% } %>
</tbody>
</table>
console.log には、次のような結果が表示されます。
{"id":{"S":"A004"},"name":{"S":"ACC LR2"},"userId":{"L":[{"S":"7"},{"S":"8"},{"S":"9"},{"S":"10"},{"S":"11"}]}}
id と name のアイテムを一覧表示できますが、 userID を一覧表示できません。html テーブルに userID を一覧表示するにはどうすればよいですか?? .. 助けていただければ幸いです..