i have dynamodb table,
table name xx
primary partition key id (number)
primary sort key name (string)
and want query name.
'use strict'; const aws = require("aws-sdk"); const dynamodb = new aws.dynamodb(); const docclient = new aws.dynamodb.documentclient(); exports.handler = function(event, ctx, callback) { var params = { tablename: 'xx', keyconditionexpression: "#name = :name", expressionattributenames:{ "#name": "name" }, expressionattributevalues: { ":name":event.name } }; docclient.query(params, function(err, data){ if(err){ callback(err, null); }else{ callback(null, data); } }); }
but got error called :"query condition missed key schema element:id:" how deal that?
it sounds id
primary key of table. either need include id
in key condition, or scan
instead of query
.
Comments
Post a Comment