我有一个数据库准备使用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"
}
模型发现是一个正在积极开发的功能,请参阅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;