ソースを参照

feat: migrate database driver from sqlite3 to sql.js and initialize TypeORM connection in AppModule

Dr-Swopt 4 日 前
コミット
f4b6c68e95
2 ファイル変更6 行追加4 行削除
  1. 1 1
      package.json
  2. 5 3
      src/app.module.ts

+ 1 - 1
package.json

@@ -35,7 +35,7 @@
     "reflect-metadata": "^0.2.2",
     "rxjs": "^7.8.1",
     "socket.io": "^4.8.3",
-    "sqlite3": "^5.1.7",
+    "sql.js": "^1.12.0",
     "systeminformation": "^5.31.5",
     "typeorm": "^0.3.28"
   },

+ 5 - 3
src/app.module.ts

@@ -8,10 +8,12 @@ import { SurveillanceModule } from './surveillance/surveillance.module';
 @Module({
   imports: [
     TypeOrmModule.forRoot({
-      type: 'sqlite',
-      database: 'palm_history.db',
+      type: 'sqljs',
+      location: 'palm_history.db',
+      autoSave: true,
+      useLocalForage: false,
       autoLoadEntities: true,
-      synchronize: true, // Auto-create tables (use only for development)
+      synchronize: true,
     }),
     PalmOilModule,
     SurveillanceModule,  // Lego 09 — boots PID polling on startup