【问题标题】:sails Sorry, this function doesn't know how to handle {...} callbacks帆 对不起,这个函数不知道如何处理 {...} 回调
【发布时间】:2018-05-14 19:37:43
【问题描述】:

不知何故,我的sails.js 1.x 环境已经受到破坏,以至于我不再能够对我的PostgreSQL 数据库进行本机查询。我确定问题出在某个包的版本上,因为我在周末对 NodeJS 9 进行了一些实验,但这段代码在周五工作,我看不到问题所在。有什么建议吗?

sails> sails.getDatastore().sendNativeQuery('SELECT COUNT(*) FROM "user"').then(console.log);
Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }

sails> UsageError: Sorry, this function doesn't know how to handle {...} callbacks.
If provided, the 2nd argument should be a function like `function(err,result){...}`
|  If you passed in {...} on purpose as a "switchback" (dictionary of callbacks),
|  please be aware that, as of machine v15, you can no longer pass in a switchback
|  as the 2nd argument.  And you can't pass a switchback in to .exec() anymore either.
|  Instead, you'll need to explicitly call .switch().
 [?] See https://sailsjs.com/support for help.
    at /Users/patrick/src/healthcelerate/hc-registry/node_modules/sails-hook-orm/lib/datastore-method-utils/private/do-with-connection.js:133:24
    at _makeCallToDuringFn (/Users/patrick/src/healthcelerate/hc-registry/node_modules/sails-hook-orm/lib/datastore-method-utils/private/do-with-connection.js:101:28)
    at /Users/patrick/src/healthcelerate/hc-registry/node_modules/sails-hook-orm/lib/datastore-method-utils/private/do-with-connection.js:103:7
    at /Users/patrick/src/healthcelerate/hc-registry/node_modules/sails-hook-orm/lib/datastore-method-utils/private/do-with-connection.js:66:14
    at /Users/patrick/src/healthcelerate/hc-registry/node_modules/machinepack-postgresql/node_modules/machine/lib/private/help-build-machine.js:966:24
    at Function.handlerCbs.success (/Users/patrick/src/healthcelerate/hc-registry/node_modules/machinepack-postgresql/node_modules/machine/lib/private/help-build-machine.js:826:26)
    at cb (/Users/patrick/src/healthcelerate/hc-registry/node_modules/machinepack-postgresql/machines/get-connection.js:87:20)
    at BoundPool.<anonymous> (/Users/patrick/src/healthcelerate/hc-registry/node_modules/pg-pool/index.js:137:9)
    at bound (domain.js:301:14)
    at runBound (domain.js:314:12)
    at /Users/patrick/src/healthcelerate/hc-registry/node_modules/generic-pool/lib/generic-pool.js:347:9
    at BoundPool.<anonymous> (/Users/patrick/src/healthcelerate/hc-registry/node_modules/pg-pool/index.js:103:7)
    at Connection.<anonymous> (/Users/patrick/src/healthcelerate/hc-registry/node_modules/pg/lib/client.js:158:7)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:121:20)
    at Connection.emit (events.js:211:7)
    at Socket.<anonymous> (/Users/patrick/src/healthcelerate/hc-registry/node_modules/pg/lib/connection.js:121:12)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:607:20)
sails>

任何提示或想法都会非常受欢迎。

【问题讨论】:

  • 我遇到了同样的错误!
  • 原来是我正在运行的风帆版本中的一个错误。我将风帆升级到最新版本(1.0.2 IIRC)并解决了它。
  • 我正在使用sails@1.0.2。能否请您指定sails-postgresql 版本

标签: sails.js sails-postgresql


【解决方案1】:

这原来是我们正在运行的 Sails 版本中的一个错误。我将sails 升级到1.0.2 并解决了。

【讨论】:

  • 我删除了node_modulespackage-lock.json。做了npm cache clean --forcenpm install。它工作“奇怪”
  • 不管怎样,我发现 yarn 与 npm 的问题要少得多
  • 好的,会试试看。谢谢:)
猜你喜欢
  • 2019-11-16
  • 2016-06-19
  • 2011-12-21
  • 1970-01-01
  • 2018-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-15
相关资源
最近更新 更多