Skip to content

ask the way to inject sql.js when creating new connections on Express.js #522

Closed
@sigridjineth

Description

@sigridjineth

I tried this to create new connection to sql.js by using the code below on index.ts

createConnection({
  type: "sqljs",
  location: "../node_modules/sql.js/dist/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);
  log.debug(connection)

  app.listen(8080, () => {
    log.info('Server is running on port 8080');
  });
});

However, the error was thrown like the following:

(node:85901) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TypeError: Failed to parse URL from /Users/sigridjin.eth/Documents/deliverble-backend/node_modules/sql.js/dist/sql-wasm.wasm

I already tried the following options but it was failed; the method of readFile does not expect two arguments.

 const wasmBinary = await readFile(new URL("../node_modules/sql.js/dist/sql-wasm.wasm", import.meta.url));
  const SQLJS = await initSql({
    wasmBinary,
  });

#517

What should I do? Thanks for in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions