CoursePark / KnexNest

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

knexQuery.then is not a function #4

Closed jricaldi closed 8 years ago

jricaldi commented 8 years ago

I am implemented

recipesRest.get(function(req,res){
  knex.select("r.id_recipe").from("recipe AS r");

  knexnest(knex).then(function(data){
    console.log(data);
    res.json(JSON.parse(JSON.stringify(data)));
  });
});

but show me this error

TypeError: knexQuery.then is not a function

jch254 commented 8 years ago

I'm getting this too. Can't get it to work.

MitMaro commented 8 years ago

If I had to take a guess, the code provided isn't passing an instance of a query, but knex. The correct code would be something like:

recipesRest.get(function(req,res){
  var sql = knex.select("r.id_recipe").from("recipe AS r");

  knexnest(sql).then(function(data){
    console.log(data);
    res.json(JSON.parse(JSON.stringify(data)));
  });
});
dvalentiate commented 8 years ago

@MitMaro is correct and I've updated the README