0

I am trying to consult a DynamoDB table with 3 parameters, but it does not work. However, with 1 parameter it works perfectly.

I'm work with NodeJs, DynamoDB, Dynamoose... and here is my code:

    var params = {

        TableName: "DifferentTermsPages",

        KeyConditionExpression:"#providerName = :providerName and #productType = :productType and #language = :language",

        ExpressionAttributeNames: {
            "#providerName":"providerName",
            "#productType":"productType",
            "#language":"language"
            },

        ExpressionAttributeValues: {
            ":providerName":providerName,
            ":productType":productType,
            ":language":language
            }

        };


       OcrController.getDifferencesFromDB(params)
        .then(function(dataDB) {
            console.log("DATA = ", dataDB); 
        }).catch(function(err) {
            console.error(err);
       });

Call to another function with a promise:

  getDifferencesFromDB(params) {

    return new Promise(function(resolve, reject) {

        DifferentTermsPagesModel.scan(params).exec().then(function (err, data) {
          if(err) {
            reject(err);
          }
          else {
            console.log("OK!!");
            resolve(data);
          }
        });

    });
  }

The error that shows me...

TypeError: Cannot read property 'toDynamo' of undefined
at Scan.exec (/API/src/node_modules/dynamoose/lib/Scan.js:57:23)
at ...

Where is my error?? How can I resolve it? Or another form to make this...

Norak
  • 383
  • 2
  • 6
  • 14
  • What are the key attributes of your table? Apparently, you cant have three attributes defined as keys. – notionquest Nov 16 '17 at 15:40
  • The hashKey is an attibute called "id" and is unique, but I would like to search for those 3 parameters, can it be? thanks! – Norak Nov 16 '17 at 15:44

1 Answers1

0

As you are using the scan api, please use FilterExpression rather than KeyConditionExpression.

FilterExpression:"#providerName = :providerName AND #productType = :productType AND #language = :language",
notionquest
  • 37,595
  • 6
  • 111
  • 105