Strongloop mysql连接器ER_NO_DB_ERROR:未选择数据库

时间:2015-10-07 11:17:20

标签: mysql node.js strongloop

我用nodejs和strongloop创建了一个网站。我使用了mysql连接器并测试了Strongloop Arc中的连接。连接正常。我用弧形工具(发现模型)创建了模型。也没关系。

但是当我打开Strongloop API Explorer并进行测试以获取数据时,我总是得到错误:

  

" ER_NO_DB_ERROR:未选择数据库"。

3 个答案:

答案 0 :(得分:0)

您是否确认您的模型已连接到dbAuction而不是db? 使用arc添加模型时,'datasource'应为'dbAuction'。

您还可以检查'server /'目录中的model-config.json。名为“dataSource”的属性属于模型名称,如

"modelname" : {
  "dataSouce":"dbAuction"
  ...
},
 ...

答案 1 :(得分:0)

这是model-config.json

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins"
    ]
  },
  "User": {
    "dataSource": "db"
  },
  "AccessToken": {
    "dataSource": "db",
    "public": false
  },
  "ACL": {
    "dataSource": "db",
    "public": false
  },
  "RoleMapping": {
    "dataSource": "db",
    "public": false
  },
  "Role": {
    "dataSource": "db",
    "public": false
  },
  "newModel": {
    "dataSource": "db",
    "public": true
  },
  "Biedingen": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Kavel": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Gebruikers": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Message": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Veilingen": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Sourcemessage": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Veilingenkavels": {
    "dataSource": "dbAuction",
    "public": true
  },
  "Veilingsoorten": {
    "dataSource": "dbAuction",
    "public": true
  }

和datasources.json

{
  "db": {
    "name": "db",
    "connector": "mysql"
  },
  "dbAuction": {
    "host": "localhost",
    "port": 3306,
    "database": "auctions",
    "password": "",
    "name": "dbAuction",
    "connector": "mysql",
    "user": "root"
  }
}

答案 2 :(得分:0)

由于声誉太低,我无法添加评论。 我建议你可以改变

中的'mysql'
"db": {
    "name": "db",
    "connector": "**mysql**"
因为“db”对于某些模型很有用而你错误地改变了以便“db”无法正常工作,这可能导致这个问题。