代码之家  ›  专栏  ›  技术社区  ›  Mohammad

无法使用mysql创建数据源

  •  0
  • Mohammad  · 技术社区  · 6 年前

    我正在用mysql创建环回应用程序。我设置的数据源将是mysql,但当我运行的应用程序,我得到以下错误控制台窗口。

    ReferenceError:无法创建数据源“shop”:无法初始化连接器“mysql”:未定义时间

    {
      "db": {
        "name": "db",
        "connector": "memory"
      },
      "shop": {
        "host": "localhost",
        "port": 8081,
        "url": "",
        "database": "shoppingdatabase",
        "password": "",
        "name": "shop",
        "user": "root",
        "connector": "mysql",
        "connectTimeout":9000000
      }
    }
    

    这是你的密码模型.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,
        "options": {
          "strictObjectIDCoercion": true
        }
      },
      "Role": {
        "dataSource": "db",
        "public": false
      },
      "carts": {
        "dataSource": "shop",
        "public": true
      },
      "products": {
        "dataSource": "shop",
        "public": true
      },
      "users": {
        "dataSource": "shop",
        "public": true
      },
      "vendors": {
        "dataSource": "shop",
        "public": true
      }
    }
    

    enter image description here

    0 回复  |  直到 6 年前
        1
  •  0
  •   B--rian Optider    6 年前

        {
          "db": {
          "host": "localhost",
          "port": 3306,
          "url": "",
          "database": "shoppingdatabase",
          "password": "",
          "name": "db",
          "user": "root",
          "connector": "mysql",
          "connectTimeout":9000000
         }
       }
    

        {
         "_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,
         "options": {
           "strictObjectIDCoercion": true
          }
        },
        "Role": {
         "dataSource": "db",
         "public": false
        },
        "carts": {
         "dataSource": "db",
         "public": true
        },
        "products": {
         "dataSource": "db",
         "public": true
        },
        "users": {
         "dataSource": "db",
         "public": true
        },
        "vendors": {
         "dataSource": "db",
         "public": true
        }
      }
    

    并保持密码保护。