如何使用 knex postgres 创建 FeathersJS 服务

How to create FeathersJS services with knex postgres

在试用 FeathersJS 时,我尝试按照文档创建两个服务。第一个称为 x,另一个称为 y。

当我用

创建 x 时
~/r/feathers-chat ❯❯❯ feathers generate service
? What kind of service is it? KnexJS
? What is the name of the service? x
? Which path should the service be registered on? /x
? Which database are you connecting to? PostgreSQL
? What is the database connection string?
  postgres://user:password@localhost:5432/feathers_chat

一切正常。

当我创建 y

~/r/feathers-chat ❯❯❯ feathers generate service
? What kind of service is it? KnexJS
? What is the name of the service? y
? Which path should the service be registered on? /y
? Which database are you connecting to? PostgreSQL

抛出以下错误。

events.js:160
  throw er; // Unhandled 'error' event
  ^

TypeError: Parameter "url" must be a string, not object
at Url.parse (url.js:88:11)
at Object.urlParse [as parse] (url.js:82:5)
at ConnectionGenerator._getConfiguration (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:46:24)
at ConnectionGenerator._writeConfiguration (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:103:32)
at ConnectionGenerator.writing (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/generator-feathers/generators/connection/index.js:293:10)
at Object.<anonymous> (/Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/yeoman-generator/lib/index.js:417:23)
at /Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/run-async/index.js:25:25
at /Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/run-async/index.js:24:19
at /Users/user/.nvm/versions/node/v6.10.2/lib/node_modules/feathers-cli/node_modules/yeoman-generator/lib/index.js:418:9
at runCallback (timers.js:666:20)

当 default.js

中定义了 postgres 连接时,feathersJS 客户端似乎崩溃了

因此,如果我事先创建连接,客户端会在创建第一个服务时崩溃并出现完全相同的错误。

我不明白我做错了什么,如果您能帮助我使用同一个 postgres 数据库创建第二个服务,我们将不胜感激!

原来是feathers-cli@2.2.2有bug,我卸载安装了2.1.1版本就没有问题了。会提示这个错误。