本文介绍了环回-“无法读取null的属性'connector'"在连接器挂钩中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我尝试遵循此示例

https://docs.strongloop.com/display/public/LB/连接器+钩子

var connector = MyModel.getDataSource().connector;
  connector.observe('before execute', function(ctx, next) {
  // ...
   next();
});

但是属性连接器"似乎未定义.我需要在启动脚本中添加连接器挂钩.有什么主意吗?

But the property 'connector' seems to be undefined. I need to add a connector hook in the boot script. Any idea?

推荐答案

使用类似这样的方法来添加连接器.

Use something like this to add a connector.

{
  "db": {
    "host": "",
    "port": 0,
    "database": "",
    "password": "",
    "name": "db",
    "connector": "memory",
    "user": ""
  },
  "mongodb": {
    "host": "0.0.0.0",
    "port": 27017,
    "database": "drugcorner",
    "password": "12345",
    "name": "mongodb",
    "connector": "mongodb",
    "user": "robins"
  }
}

我们有名称为 mongodb 的MongoDb数据源数据源.现在,在所有引导文件中为 mongodb 使用连接器.

We have have MongoDb datasource datasource defined with name mongodb.Now to use a connector for mongodb inside any boot files.

var mongoConnector = app.dataSources.mongodb.connector;

这篇关于环回-“无法读取null的属性'connector'"在连接器挂钩中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-09 03:14