Retrieve table data DynamoDB

0

I am trying to recover data from a DynamoDB table that meet 3 conditions (that is, the parameters match with 3 attributes that I give it).

I work with Nodejs, DynamoDB and Dynamoose.

If I do it with just one parameter everything works perfectly:

Controller.getDifferencesFromDB(params)
     .then(function(datosDB) {
        console.log("DATOS = ", datosDB); 

     }).catch(function(err) {
        console.error(err);
     });

And the promise that recovers the values of the BBDD is:

getDifferencesFromDB(providerName) {

return new Promise(function(resolve, reject) {

  var TermsModel = require('../models/terms.js');

    TermsModel.scan('Name').eq(Name).exec(function (err, config) {
      if(err) {
        reject(err);
      }
      else {
        resolve(config);
      }
    });

});

},

Now I would like to pass two more parameters besides "Name", like this:

    var params = {
      TableName: "Terms",
      Key:{
          "provName": provName,
          "productType": productType,
          "language": language
      }
    };

And to the promise I will pass the parameters ...

getDifferencesFromDB(params) {

return new Promise(function(resolve, reject) {

  var TermsModel = require('../models/terms.js');

    TermsModel.query(params, function (err, data) {
      if(err) {
        reject(err);
      }
      else {
        resolve(data);
      }
    });

    });
  },

But this throws me an error because something will be wrong ... The error says the following:

TypeError: Cannot read property 'toDynamo' of undefined
at Query.exec

How can I query DynamoDB with Nodejs by passing it 3 parameters?

With one and with scan it works, but when I add 3 and use query I have problems

    
asked by Norak 15.11.2017 в 18:57
source

0 answers