loopback 4从数据库中发现模型

问题描述 投票:1回答:1

我有一个数据库准备使用postgresgl,我使用loopback 4作为框架,我想通过从数据库中读取它自动创建我的模型。我使用连接器在loopback和postgresql之间创建了一个连接,但无法从数据库导入任何内容。每个时间我在数据库中创建一个表我必须使用lopback创建它,我想知道是否有一种方法将数据库模式转换为生成的模型。这是我到目前为止所做的:

{
  "name": "testtest",
  "connector": "postgresql",
  "url": "postgres://postgres:root@localhost:5432/testtest",
  "host": "localhost",
  "port": 5432,
  "user": "postgres",
  "password": "root",
  "database": "testtest"
}
node.js database postgresql model loopback
1个回答
2
投票

模型发现是一个正在积极开发的功能,请参阅pull请求https://github.com/strongloop/loopback-next/pull/2245

您可以查看开发版本,并告诉我们它是如何工作的。

交叉发布https://github.com/strongloop/loopback-next/pull/2245#issuecomment-468863700的说明:

# Clone the repo and install the dev version of `lb4` CLI
git clone -b pr-model-discovery --single-branch https://github.com/marvinirwin/loopback-next;
cd loopback-next/packages/cli;
npm install && npm run build && npm run link;

# Switch to your project
cd `LOOPBACK_4_PROJECT`;
npm run build;
# Run model discovery
lb4 discover;
© www.soinside.com 2019 - 2024. All rights reserved.