我的表格项的形式为
function addDoc(movie,cb){
var params = {
TableName: "Movies",
Item: {
"year": movie.year,
"title": movie.title,
"info": movie.info,
"genres" : movie.info.genres || []
}
};
docClient.put(params, function(err, data) {
bar.tick(1)
i++;
cb(err);
});
}
async.eachLimit(allMovies,50,addDoc,function (err) {
console.log(err)
console.log("done inserting " + i + " movies");
});
我正在运行这段代码:
var params = {
TableName : "Movies",
//ProjectionExpression:"#yr, title, genres, info.actors[0]",
KeyConditionExpression: "#yr = :yyyy and contains(genres, :g1)",
ExpressionAttributeNames:{
"#yr": "year"
},
ExpressionAttributeValues: {
":yyyy":1992,
":g1" : "Drama"
},
//Select : "COUNT"
};
var start = Date.now()
docClient.query(params, function(err, data) {
if (err) {
console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
} else {
console.log("time elapsed :",Date.now()-start);
console.log("Query succeeded.");
console.log(data)
}
});
我遇到了这个错误:
"在KeyConditionExpression中使用了无效的操作符:contains"
有什么想法吗?
contains
可以用在KeyConditionExpression
上吗?(参考链接为:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.ReadData.Query.html) - MK Yung