将适配器更改为风帆磁盘或风帆内存时,风帆无法举起

时间:2018-09-25 02:46:44

标签: sails.js

我想将Sails与sails-disk一起使用,migration:drop,这样每当我运行测试用例时,我就可以在local.js上使用以下配置创建一个新数据库。我的帆扬帆很好。但是,一旦我更新了migration:drop或adapter到sails-disk或sails-memory。我无法从引导程序中启航,在服务器下,我什至无法获取配置信息。帆扬起只是处理。没有任何详细信息。

#config.js
    module.exports = {

  models: {
    connection: 'testing',
    migrate: 'drop',
  },

  connections: {
    testing: {
      adapter: 'sails-disk',
      host: '127.0.0.1',
      user: 'test',
      password: 'test',
      database: 'db',
    },
  },
};
#bootstrap.test.js

const TestConfig = require('./config/local');

before((done) => {
  // Increase the Mocha timeout so that Sails has enough time to lift.
  Sails.lift({
    connections: TestConfig.connections,
    models: TestConfig.models,
  }, function(err) {
    if (err) { return done(err); }

      return done(err, server);
    });
});

#error message
after adding more debug information before return I can not get config information

    1) "before all" hook

0 passing (3s)
1 failing

1)  "before all" hook:
   Uncaught TypeError: Cannot read property 'config' of undefined
    at async.series (test/bootstrap.test.js:29:26)
    at node_modules/async/dist/async.js:3888:9
    at node_modules/async/dist/async.js:473:16
    at replenish (node_modules/async/dist/async.js:1006:25)
    at node_modules/async/dist/async.js:1016:9
    at eachOfLimit (node_modules/async/dist/async.js:1041:24)
    at node_modules/async/dist/async.js:1046:16
    at _parallel (node_modules/async/dist/async.js:3879:5)
    at Object.series (node_modules/async/dist/async.js:4735:5)
    at Sails.lift (test/bootstrap.test.js:19:11)

1 个答案:

答案 0 :(得分:0)

由于您未提供任何错误消息,所以我只能猜测您的配置错误。 您必须为每个连接命名,并告诉您要使用哪个连接。

module.exports = {
  models: {
    migrate: 'drop',
    connection : 'testing',
  },
  connections: {
    testing : {
      adapter: 'sails-disk',
      host: '127.0.0.1',
      user: 'user',
      password: 'password',
      database: 'db',
   }
 },
},
相关问题