CoursePark / KnexNest

A wrapper for Knex.js that can output list of objects hydrated from a select
76 stars 10 forks source link

TypeError: Cannot read property 'config' of undefined #9

Open runnerpaul opened 5 years ago

runnerpaul commented 5 years ago

I've created a query

const customerProducts = await knex.select([
      'CustomerProduct.id',
      'CustomerProduct.last_delivered AS lastDelivered',
      'CustomerProduct.customer_id AS customerId',
      'product.id',
      'product.title',
      'product.code',
    ])
    .from('customer_products AS CustomerProduct')
    .innerJoin('products AS product', 'CustomerProduct.product_id', 'product.id')
    .where(whereClause)
    .limit(limit)
    .offset(offset);

    knexnest(customerProducts).then(function (data) {
      result = data;
    });
return result;

When I try to execute this code I get this error:

TypeError: Cannot read property 'config' of undefined

I'm not sure why I should get it though.

alitinker commented 5 years ago

I ran into this. Don't await the knex.select. Await the knexnest promise instead.