升级到Buzzard之后,羽毛-sequelize不再与```raw:false```一起使用

时间:2017-12-28 10:43:43

标签: sequelize.js feathersjs feathers-sequelize

我在我的服务器上使用feathersjs(带有websockets)和sequelize并升级到Buzzard版本。这个钩子在我的服务器上,用于在升级之前正常工作: ```

module.exports = function (options = {}) { 
  return function (hook) {
    if (hook.params.query && hook.params.query.include) {
      const joinModel = hook.app.service('favorites_points').Model;
      const pointsModel = hook.app.service('points').Model;
      hook.params.sequelize = {
        raw: false,
        include: [{
          model: joinModel,
          as: 'FavPoints',
          include: [{
            model: pointsModel
          }]
        }]
      };
      delete hook.params.query.include;
    }
    return Promise.resolve(hook);
  };
};

升级后,从客户端调用时: api.service('users').get(2, {query: {include: true}})

我收到此错误(顺便说一句:当我遗漏内部include: [{ model: pointsModel }]时,仍然存在同样的错误):

index.js?3d97:235 Uncaught (in promise) Error: Maximum call stack size exceeded
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:28:20)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:35:11)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
    at hasBinary (/home/usr/api_server/node_modules/has-binary2/index.js:56:59)
convert @ index.js?3d97:235
(anonymous) @ client.js?8dbe:71
Socket.onack @ socket.js?0183:312
Socket.onpacket @ socket.js?0183:236
(anonymous) @ index.js?cea2:21
Emitter.emit @ index.js?a675:133
Manager.ondecoded @ manager.js?0ad8:332
(anonymous) @ index.js?cea2:21
Emitter.emit @ index.js?a675:133
Decoder.add @ index.js?5f3d:241
Manager.ondata @ manager.js?0ad8:322
(anonymous) @ index.js?cea2:21
Emitter.emit @ index.js?a675:133
Socket.onPacket @ socket.js?5eac:456
(anonymous) @ socket.js?5eac:273
Emitter.emit @ index.js?a675:133
Transport.onPacket @ transport.js?64e8:145
Transport.onData @ transport.js?64e8:137
ws.onmessage @ websocket.js?7304:147
Promise rejected (async)
queryMe @ Nearby.vue?9ccf:48
boundFn @ vue.runtime.esm.js?ff9b:189
click @ Nearby.vue?dc3e:39
invoker @ vue.runtime.esm.js?ff9b:1979
Vue.$emit @ vue.runtime.esm.js?ff9b:2489
click @ quasar.esm.js?8bfb:3118
boundFn @ vue.runtime.esm.js?ff9b:188
invoker @ vue.runtime.esm.js?ff9b:1979
fn._withTask.fn._withTask @ vue.runtime.esm.js?ff9b:1777

当我评论raw: false,时,它会给出正确的输出。我查了一下,但在我的'升级前版本'中,当我离开raw: false,时,查询也会起作用,但是当它添加时输出结构是不同的(更嵌套),所以让我觉得sequelize被简单地绕过了可能没有急切加载等等所以我想使用raw: false,

升级服务器的Package.json后:

"@feathersjs/authentication": "^2.1.0",
"@feathersjs/authentication-jwt": "^1.0.1",
"@feathersjs/authentication-local": "^1.0.2",
"@feathersjs/authentication-oauth2": "^1.0.2",
"@feathersjs/configuration": "^1.0.1",
"@feathersjs/errors": "^3.2.0",
"@feathersjs/express": "^1.1.2",
"@feathersjs/feathers": "https://github.com/feathersjs/feathers.git#master",
"@feathersjs/socketio": "^3.0.1",
"feathers-authentication-hooks": "^0.1.5",
"feathers-hooks-common": "git://github.com/feathers-plus/feathers-hooks-common.git#master",
"feathers-sequelize": "^3.0.0",
"sequelize": "^4.28.6",

在服务器上升级Package.json之前:

"feathers": "^2.2.3",
"feathers-authentication": "^1.3.0",
"feathers-authentication-hooks": "^0.1.5",
"feathers-authentication-jwt": "^0.3.2",
"feathers-authentication-local": "^0.4.4",
"feathers-authentication-oauth2": "^0.3.2",
"feathers-blob": "^1.3.1",
"feathers-configuration": "^0.4.2",
"feathers-errors": "^2.9.2",
"feathers-hooks": "^2.1.2",
"feathers-hooks-common": "^3.10.0",
"feathers-rest": "^1.8.1",
"feathers-seeder": "^1.0.10",
"feathers-sequelize": "^2.4.0",
"feathers-socketio": "^2.0.1",
"sequelize": "^4.23.1",

我的问题:为什么它不再适用于raw: false,,我该如何解决?

1 个答案:

答案 0 :(得分:0)

添加dehydrate hook(作为后挂钩)后,输出符合预期。我不清楚为什么在升级之前这不是问题。