Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 环回&x2B;用户模型迁移到postgres数据库_Javascript_Node.js_Postgresql_Loopbackjs - Fatal编程技术网

Javascript 环回&x2B;用户模型迁移到postgres数据库

Javascript 环回&x2B;用户模型迁移到postgres数据库,javascript,node.js,postgresql,loopbackjs,Javascript,Node.js,Postgresql,Loopbackjs,我是环回新手 我正在尝试注册、登录等用户模型。 我跟踪了这个网址- 它的工作很好,但它的工作没有postgres数据库 我添加了datasoruces.json代码 { "db": { "name": "db", "connector": "memory" }, "mydata": { "postgres": { "host": "localhost", "port": "54

我是环回新手

我正在尝试注册、登录等用户模型。 我跟踪了这个网址-

它的工作很好,但它的工作没有postgres数据库

我添加了datasoruces.json代码

{
    "db": {
        "name": "db",
        "connector": "memory"
    },
    "mydata": {
        "postgres": {
            "host": "localhost",
            "port": "5432",
            "database": "myapps_login",
            "username": "postgres",
            "password": "password",
            "name": "postgres",
            "debug": true,
            "connector": "postgresql"
        }
    }

如何使用数据库访问用户模型?

有两个问题。首先,您没有正确定义数据源。您不应该有嵌套的
postgres
对象:

"mydata": {
    "name": "mydata",
    "host": "localhost",
    "port": "5432",
    "database": "myapps_login",
    "username": "postgres",
    "password": "password",
    "debug": true,
    "connector": "postgresql"
}
接下来,你需要。编辑
server/model config.json
文件:

{
  // ...
  "User": {
    "dataSource": "mydata",
    "public": true
  },
  // ...
}
最后,确保已安装postgres连接器依赖项(从命令行,在项目目录中):


server/model-config.json不适用于loopback4。有没有办法让它在环回4中工作?
npm install --save loopback-connector-postgresql