Search code examples
feathersjsfeathers-sequelize

FeathersJS: Basic setup for sequelize and SQL Server


I'm an absolute beginner with Feathers, but it looks promising, so I'm trying to see if I can connect it to my SQL Server database, but I'm stuck right away.

I followed the docs and used feathers generate service, then edited my connection string, but then when I ran npm start it throws and error in src/models/sqlserver.model.js:

==> const sqlserver = sequelizeClient.define('sqlserver', {...
TypeError: Cannot read property 'define' of undefined

The generator edited default.json and added all these files:

/src
  mssql.js
  /services
    index.js
    sqlserver/
      sqlserver.filters.js
      sqlserver.hooks.js
      sqlserver.service.js

but the docs don't mention any of them (at least, not as I understood it), or what I need to change. I would think the generator is the easiest way to set this up, but it's confusing to me as the docs seem to ignore the use of the generator, and everything is in app.js.

Would appreciate any guidance anyone can provide for just setting up a basic SQL Server service in Feathers.


Solution

  • This was indeed a bug that should be fixed in feathers-cli v2.0.4 (see pull request here). You can update using npm update feathers-cli -g and generating a new application.

    Alternatively you can change your existing src/sequelize.js file where it says

    app.set('mssqlClient', sequelize);
    

    To

    app.set('sequelizeClient', sequelize);
    

    Which will should also solve the problem.