在DynamoDB中,如何使用动态节点模块计算mysql“从tablename中选择计数(*)”?
发布于 2016-12-20 17:03:52
在DynamoDB中没有直接等效的东西。然而,解决方法之一是使用describe获取ItemCount。
ItemCount的缺点:-
DynamoDB大约每六小时更新一次此值。最近的变化可能不会反映在这个值中。
从本地实例获取电影表项计数的DynamoDB代码:-
'use strict';
var dynamoose = require('dynamoose');
dynamoose.AWS.config.update({
accessKeyId : 'AKID',
secretAccessKey : 'SECRET',
region : 'us-east-1'
});
dynamoose.local();
var Schema = dynamoose.Schema;
var Table = dynamoose.Table;
var table = new Table('Movies', null, null, dynamoose);
table.describe(function(err, data) {
if (err) {
console.log(JSON.stringify(err));
} else {
console.log(JSON.stringify(data, null, 2));
console.log("Number of item =====>", JSON.stringify(data.Table.ItemCount, null, 2));
}
});输出:-
Number of item =====> 24https://stackoverflow.com/questions/41246577
复制相似问题