dzzzzzy / Nestjs-Learning

nestjs 学习教程 :books:,跟我一起学习 nest 框架~ :muscle:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

johngai19 opened this issue · 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
}