I want to do a search into my DB looking for an element that is inside a Map.
The element that I've been looking for is reference
DB SCHEMA EXAMPLE
{
id: "someid",
payment_method:{
reference:"some Reference",
typeOf : "Card"
}
amount:500
}
I want to look if the reference that the client sends to me is actually in my DB.
This what I tried:
function searchReference(event, callback){
console.log(event.folio);
var params = {
TableName: process.env.TABLE_REFERENCES,
FilterExpression: "#idRef = :data",
ExpressionAttributeNames: {
"#idRef": "payment_method.reference",
},
ExpressionAttributeValues: {
":data": event.folio
}
};
docClient.scan(params, function(err, data) {
if (err) {
console.log("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
var responseD = buildCallBack(403,"ReferenceError",null);
callback(err, responseD);
} else {
console.log("data");
console.log(data);
if (isEmpty(data)) {
var responseD = buildCallBack(403,"Reference not found",null);
callback(null, responseD);
} else {
console.log(data);
doValidation(callback, event, data);
}
}
});
}
But when the scan is done my data is empty, I'm sure that the reference that I'm trying to search is in the DB, but i really don't know what to change in my code.
This is what i'm receiving
{ Items: [], Count: 0, ScannedCount: 2 }