Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code problems #20

Closed
aldeluis opened this issue Dec 15, 2015 · 7 comments
Closed

Example code problems #20

aldeluis opened this issue Dec 15, 2015 · 7 comments

Comments

@aldeluis
Copy link

Hi, I'm not very good programming with JS but I managed to use this extension to FeathersJS (it rocks!). In the process I've encountered some problems:

  1. The example code doesn't work because the object referenced in the createTable sentence is "people", not "todos": people.knex.schema.createTable()
  2. I'm using Postgresql. In this case I have to finish the block with a promise .return() to get it work. This is my code block:
// This drops and creates table every time
todos.knex.schema.dropTableIfExists('todos').then(function(rows){
  return todos.knex.schema.createTable('todos', function(table) {
    table.increments('id');
    table.string('text');
    table.boolean('complete');
  })}).return();
@daffl
Copy link
Member

daffl commented Dec 15, 2015

Thanks for letting us know! I will double check how it works with Postgres and we're also working on a new version at https://github.com/feathersjs/feathers-knex/tree/es6 which should land shortly and will have a verified example. If you don't mind trying that version once it is out that would be greatly appreciated.

@aldeluis
Copy link
Author

Yes! I will try that new version!

There's another detail in order to make the example work. It's a dirty patch, I don't know how to make it right: create method doesn't return the id

In file feathers-knex/lib/index.js, line 167, I have to add a .returning('id'). to make it work:
this.db().insert(data).returning('id').then(function (rows) {

@aldeluis
Copy link
Author

Last message was a patch intended for the npm version npm install feathers-knex@1.2.2. This version differs substantially from branch 1.2.2 in this repository.

¿Where can I find the library distributed in npm?

@daffl
Copy link
Member

daffl commented Dec 18, 2015

It isn't different we're only publishing the version transpiled from the ES6 original sources to NPM. You can get it by cloning the repository, checking out the v1.2.2 tag and then running npm install && npm run compile. I'll hopefully be able to publish the version I mentioned soon.

@aldeluis
Copy link
Author

Ah, now I understand. Thank you!

I've done two changes on v1.2.2 that are working for me in PostgreSQL. I will try to propose them as pull requests.

@ekryski
Copy link
Member

ekryski commented Dec 21, 2015

Sounds good @aldeluis. You might just want to wait a couple more days. I'm going to be putting the final touches on the new ES6 version of the Knex adapter. Even though we ❤️ PRs I'd hate for you to submit something that is going to be useless in the coming days.

@ekryski
Copy link
Member

ekryski commented Dec 21, 2015

Rather than procrastinate I fixed this up. PR #22 should resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants