jyore / dynamo-cache

A Cache Mechanism for DynamoDB
GNU General Public License v3.0
0 stars 2 forks source link

TypeError: Cannot read property 'getItem' of undefined #5

Open kubrickfr opened 8 years ago

kubrickfr commented 8 years ago

When trying to do docClient.query:

Unhandled rejection TypeError: Cannot read property 'getItem' of undefined
    at Object.get (/home/test/Downloads/test-server/lambda/node_modules/aws-sdk/lib/dynamodb/document_client.js:261:31)
    at /home/test/Downloads/test-server/lambda/node_modules/dynamo-cache/index.js:131:28
    at get (/home/test/Downloads/test-server/lambda/node_modules/dynamo-cache/lib/inmemory-provider.js:22:7)
    at DocumentClient.query (/home/test/Downloads/test-server/lambda/node_modules/dynamo-cache/index.js:125:15)
    at /home/test/Downloads/test-server/lambda/test.js:66:15
    at Promise._execute (/home/test/Downloads/test-server/lambda/node_modules/bluebird/js/release/debuggability.js:299:9)
    at Promise._resolveFromExecutor (/home/test/Downloads/test-server/lambda/node_modules/bluebird/js/release/promise.js:481:18)
    at new Promise (/home/test/Downloads/test-server/lambda/node_modules/bluebird/js/release/promise.js:77:14)
    at search (/home/test/Downloads/test-server/lambda/test.js:25:10)
    at Object.<anonymous> (/home/test/Downloads/test-server/lambda/test.js:77:1)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
jyore commented 8 years ago

can you please paste your configuration object and the query command you are using?

kubrickfr commented 8 years ago
var AWS = require('aws-sdk');
// Use bluebird implementation of Promise
var Promise = require('bluebird');
AWS.config.setPromisesDependency(require('bluebird'));
var dynamoCache = require('dynamo-cache');
var docClient = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10', region: "eu-west-1", endpoint: "dynamodb.eu-west-1.amazonaws.com", accessKeyId:"xx", secretAccessKey:"xx"});
docClient.configCache()
var paramsQuery= { TableName: 'XXXObjects',
  IndexName: 'ParentID-date_created-index',
  KeyConditionExpression: 'ParentID = :pid AND #CreateDate BETWEEN :afterDate AND :beforeDate',
  ExpressionAttributeValues: 
   { ':pid': 'FolCWpHq',
     ':afterDate': 0,
     ':beforeDate': 9007199254740991 },
  ProjectionExpression: '#Name, #CreateDate, targets_total, targets_validated',
  ExpressionAttributeNames: { '#Name': 'Name', '#CreateDate': 'date_created' } }

    docClient.query(paramsQuery, (err, data) => {
      if (err) {
        console.log(JSON.stringify(paramsQuery));
        reject(err);
      } else {
        resolve(data);
      }
    })