ITADN

Mysql2 type error when trying to query connection

#27OpenPuetz 创建于 2024-10-18
P
Puetzcommented
Hi, I want to use the mysql2 npm package with Deno 2. I installed the package using the npm prefix and am able to import it just fine. When I try to run any query on my database connection I'm getting a typescript error "Property 'query' does not exist on type 'Connection'". I looked at the [example](https://github.com/denoland/examples/tree/main/with-mysql2) in this repo as well as the official mysql2 documentation and I can't figure out what I'm doing wrong. deno.json ```json { "name": "@scope/deno-backend", "version": "0.1.0", "exports": "./main.ts", "tasks": { "dev": "deno run --watch main.ts" }, "imports": { "mysql2": "npm:mysql2@^3.11.3" } } ``` main.ts ```typescript import mysql from "mysql2/promise"; const connection = await mysql.createConnection({ host: "localhost", user: "user", password: "password", database: "react19_db", }); const results = await connection.query("SELECT * FROM `test`"); ``` If I did something wrong during my setup, then I'm really sorry. It's my first time using Deno 2. Cheers, Thomas
1 条评论