环回 + 用户模型迁移到 Postgres 数据库
loopback + user model migrate into postgres database
我是环回的新手,
我尝试使用用户模型,如注册,登录。我关注了这个网址 - https://github.com/strongloop/loopback-example-user-management
它工作得很好,但它在没有 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"
}
接下来,您需要将User
模型附加到新数据源。编辑server/model-config.json
文件:
{
// ...
"User": {
"dataSource": "mydata",
"public": true
},
// ...
}
最后,确保您已经安装了 postgres 连接器依赖项(从命令行,在项目目录中):
npm install --save loopback-connector-postgresql
相关文章:
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 如何通过php页面将数据库值检索到jquery自动完成框中
- 使用javascript从数据库中添加表
- 通过CSV文件上载更新数据库表
- 平均值:无法将数据更新到数据库
- 如何使用 Angular JS 将数据保存在数据库中
- Rails-JQueryUIAutcomplete和AJAX不工作,可以't连接到数据库
- 在谷歌地图上绘制位置数据库
- PHP:显示sqlite数据库中的html格式数据,使用tinymce保存
- 将地理编码结果转换为php变量以发布到mysql数据库
- 从数据库中检索字段,而不模拟它们
- javascript:将数据库中的数据插入到html5文本字段中
- 使用 sequelize ORM 连接到节点上的 Amazon RDS Postgres 数据库.js出现问题
- 环回 + 用户模型迁移到 Postgres 数据库
- 在安装流星postgres之前有什么步骤吗?我无法连接数据库
- 如何通过sequelize-postgres数据库和迁移在服务器重启后幸存下来
- REST API与node.js CRUD与Postgres数据库
- Postgres + Node,将开发环境迁移到Windows,并且在连接数据库时遇到认证问题
- 我们如何从数据库中使用 jquery 读取 xml 文件(postgres)
- 如何进行身份验证以连接到Postgres中的数据库