feathers
feathers copied to clipboard
Explicit table (as `from(...)` / `into(...)`) required (Model)
Steps to reproduce
Retrieve a default FeathersJS service and then the associated Model.
Perform KnexJS operations on that Model, e.g. record select(...) or insert(...).
The queries fails unless the table name is also explicitly set:
// (e.g. in a service hook)
// Retrieve FeathersJS service and associated Model
const ordersService = app.service('orders');
const ordersModel = ordersService.Model;
// select example
const orders = await ordersModel.select('finished'); // query fails, table undefined in query!
const orders = await ordersModel.select('finished').from('order'); // query works only with table name explicitly stated.
// insert example
const result = await ordersModel.insert(exampleOrders); // query fails, table undefined in query!
const result = await ordersModel.insert(exampleOrders).into('orders'); // query works only with table name explicitly stated.
Expected behavior
No need to explicitly state the table name when the FeathersJS Model service is used.
Actual behavior
Queries all fail unless the table names are explicitly stated.
@strarsis You will likely get some better traction with this issue by posting it in the feathers-knex repo
https://github.com/feathersjs-ecosystem/feathers-knex
With the new @feathersjs/knex you can get a reference to to the table by calling service.db([params]):
app.service('orders').db().select('finished')