postgresql - 环回用户存储在哪里?

标签 postgresql loopbackjs

我正在使用环回。默认情况下,它有一个用户 API。我通过 loopback-connector-postgresql 使用 postgres .

this guide 上的前两段代码之后,我能够创建用户,但我不知道如何查看用户。

首先,当我尝试让所有用户都在 /explorer 路径下时。我收到 401 需要授权。我也无法在我的 postgres 数据库中找到我的 User 数据。我检查了所有数据库和表格,没有发现任何与 User 相关的内容。我的用户被持久保存到哪里?

我还为 User 修改了 model-config.json 以查看我是否可以获得访问权限:

"User": {
  "dataSource": "mydb",
  "public": true
}
...

但运气不好。

最佳答案

根据环回文档,您可以指定内存数据必须存储在 server/datasources.json 中的位置,如下所示:

  "db": {
    "name": "db",
    "connector": "memory",
    "file": "mydata.json"
  }

有关更多信息,您可以阅读: https://docs.strongloop.com/display/public/LB/Memory+connector

注意:

The memory connector is designed for development and testing of a single-process application without setting up a database. It cannot be used in a cluster as the worker processes will have their own isolated data not shared in the cluster. You can persist data between application restarts using the file property. See Data persistence for more information.

要查看或管理用户,您必须创建新模型并从环回默认用户模型扩展它,然后在 server/model-config.json 中为该模型分配您的 postgresql 连接器。 接下来注册新用户然后它将保存在您的 postgresql 数据库中。

或者像这样在 server/model-config.json 中将用户模型数据源更改为您的 postgresql:

 "User": {
    "dataSource": "MongoDB"
  }

请注意,在第一次插入 Users 模型后可以观察到更改。

参见 this project您可以了解如何配置它。

关于postgresql - 环回用户存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35836164/

相关文章:

python - Django ORM - 不同表中行的部分匹配

sql - 我应该如何将文本添加到我的列的选择语句中

loopbackjs - 环回: return error from beforeValidation hook

node.js - 环回mmsql聚合,groupby

ruby-on-rails - rails : calculate stats and group by day

postgresql - 如何将栅格从内存位图(而不是文件)加载到 PostgreSQL 中

sql - 处理 SQL 特殊字符

安装 MySQL 连接器后,MySQL 表自动创建在 Loopback Node API 框架中不起作用

axios - 如何在 axios PUT 请求中传递参数?

node.js - 如何通过环回获取主详细信息查询?