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

Initialization should conform with other adapters #24

Closed
ekryski opened this issue Jan 4, 2016 · 2 comments
Closed

Initialization should conform with other adapters #24

ekryski opened this issue Jan 4, 2016 · 2 comments

Comments

@ekryski
Copy link
Member

ekryski commented Jan 4, 2016

All other db adapters support these options:

  • Model (required) - The knex object scoped to a table
  • id (default: id) [optional] - The name of the id property
  • paginate [optional] - A pagination object containing a default and max page size (see below)

So it should look like this:

var knex = require('knex');
var knexService = require('feathers-knex');

app.use('/todos', knexService({
  Model: knex('todos')
}));
@ekryski
Copy link
Member Author

ekryski commented Jan 6, 2016

Closed via 9e7a20c

@ekryski ekryski closed this as completed Jan 6, 2016
@ekryski
Copy link
Member Author

ekryski commented Jan 6, 2016

We needed to add the name attribute to this adapter because of the way that knex queries work. If you don't make a call to knex('table_name') every time then you end up with weird results. An alternative is to use the .from('table_name') syntax but you'd still need to call it every time you make a query.

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

1 participant