You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When my service class extends knex service, a newly created instance of my service is pure knex service instance.
constService=require('feathers-knex')classCaseServiceextendsService{testMethod(){console.log('Hello from test method!')}}module.exports=functioninit(options){returnnewCaseService(options)}module.exports.CaseService=CaseService
Simple call to the test method during service initialization:
constcreateService=require('./case.class.js')...module.exports=function(app){
...
// Initialize our service with any options it requiresletservice1=createService(options)service1.testMethod()...
throws an error:
service1.testMethod()
^
TypeError: service1.testMethod is not a function
Expected behavior
Original intention was to extend knex service class and override some functions as I need custom stuff in there.
Actual behavior
Looks like my class is totally ignored and returned instance is knex service.
The following code works though (extending knex service by using builtin function extend()):
constService=require('feathers-knex')classCaseService{testMethod(){console.log('Hello from test method!')}}module.exports=functioninit(options){returnnewService(options).extend(newCaseService(options))}// disabled for safety reasons// module.exports.CaseService = CaseService
The text was updated successfully, but these errors were encountered:
lukaszczerpak
changed the title
how to properly extend knex service
How to properly extend knex service
Apr 6, 2018
The service is exported by require('feathers-knex').Service so it should be const { Service } = require('feathers-knex') (see common database API Documentation).
Steps to reproduce
When my service class extends knex service, a newly created instance of my service is pure knex service instance.
Simple call to the test method during service initialization:
throws an error:
Expected behavior
Original intention was to extend knex service class and override some functions as I need custom stuff in there.
Actual behavior
Looks like my class is totally ignored and returned instance is knex service.
System configuration
Module versions: feathers-knex: 3.0.6
NodeJS version: 8.11.1
Operating System: macOS Sierra (10.12.6)
Workaround
The following code works though (extending knex service by using builtin function extend()):
The text was updated successfully, but these errors were encountered: