Nestjs-Learning icon indicating copy to clipboard operation
Nestjs-Learning copied to clipboard

数据库更换为Sqlite3的简单方法

Open johngai19 opened this issue 5 years ago • 0 comments

在完成例子的时候没有安装PostgreSql,就想更换为sqlite3. npm i --save sqlite3,修改配置如下。 在运行时提示不能在项目外导入模块。查资料说是因为程序在运行时从src编译到了dist,因此把entity从src修改到了dist之后可以正常使用。

还想更换为mongodb但是显示没有成功,可能因为跟案例里面的自增id有关,有机会可以再测试一下。

{
    "type": "sqlite",
    "database": "./mydb.sql",
    "entities": [
        "dist/**/**.entity{.ts,.js}"
    ],
    "synchronize": true,
    "logging": true
}

johngai19 avatar Dec 28 '19 08:12 johngai19