You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ask the way to inject sql.js when creating new connections on Express.js #522
I just solved the problem by directly copying the sql-wasm.wasm file on the index.ts directory, while autoSave should be true. When autoSave option is not declared, I do not see the clarification by userId.
importexpressfrom'express';import{createConnection}from'typeorm';importroutesfrom'./routes';import{errorHandler}from'./error/ErrorHandler';importredisfrom"redis";import{Logger}from"tslog";constcors=require('cors');// redis settingconstport=6379;consthost="localhost";constpassword="changeme";constredisClient=redis.createClient(port,host);redisClient.auth(password);constapp=express();constinitSqlJs=require('sql.js');constgetSQL=async()=>{constSQL=awaitinitSqlJs({// Required to load the wasm binary asynchronously. Of course, you can host it wherever you want// You can omit locateFile completely when running in nodelocateFile: file=>`https://sql.js.org/dist/${file}`});returnnewSQL.Database();}console.log(getSQL())// CORS 미들웨어 사용app.use(cors());// Request body를 parsing 하기 위한 미들웨어 사용app.use(express.json());app.use(express.urlencoded({extended: true}));// routes 폴더로 분기app.use(routes);app.use(errorHandler);constlog: Logger=newLogger({name: "딜리버블 백엔드 짱짱"});createConnection({type: "sqljs",location: "./sql-wasm.wasm",autoSave: true,entities: ["../entity/**/*.ts"],logging: ['query','schema'],synchronize: true}).then(async(connection)=>{// await insertScriptData(connection);// const user = await MockUserToFavorite(connection);// await insertNewsData(connection);app.listen(8080,()=>{log.info('Server is running on port 8080');});});
(Use `node --trace-warnings ...` to show where the warning was created)
2022-07-21 19:02:47.115 INFO [딜리버블 백엔드 짱짱 src/util/redis.ts:16 RedisClient.<anonymous>] Redis plugged in.
2022-07-21 19:02:47.117 INFO [딜리버블 백엔드 짱짱 src/controllers/UserController.ts:19 RedisClient.<anonymous>] Redis plugged in.
Redis plugged in.
query: PRAGMA foreign_keys = OFF
query: BEGIN TRANSACTION
query: SELECT * FROM "sqlite_master" WHERE "type" = 'table' AND "name" = 'typeorm_metadata'
query: COMMIT
query: PRAGMA foreign_keys = ON
2022-07-21 19:02:47.342 INFO [딜리버블 백엔드 짱짱 src/index.ts:64 Server.<anonymous>] Server is running on port 8080
^C
Activity
realsigridjin commentedon Jul 21, 2022
I just solved the problem by directly copying the
sql-wasm.wasmfile on the index.ts directory, while autoSave should be true. WhenautoSaveoption is not declared, I do not see the clarification by userId.