运行 deno v1.1.0 并使用 deno-postgres
数据库是这样配置的
import { Client } from "https://deno.land/x/postgres/mod.ts";
class Database {
client?: Client;
constructor() {
this.connect();
}
async connect() {
this.client = new Client({
user: "someuser",
database: "somedb",
hostname: "somehost",
password: "somepassword",
port: 5432,
});
await this.client.connect();
}
}
export default new Database().client;
但是当我尝试启动我的应用程序时,我不断遇到此错误:
Listening on port 7700 ...
error: Uncaught Error: Another accept task is ongoing
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
at async ListenerImpl.accept ($deno$/net.ts:63:17)
at async Server.acceptConnAndIterateHttpRequests (https://deno.land/std@0.56.0/http/server.ts:212:14)
at async MuxAsyncIterator.callIteratorNext (https://deno.land/std@0.56.0/async/mux_async_iterator.ts:28:29)
更新!将我的数据库文件更改为此文件,它现在可以工作了:
import { Client } from "https://deno.land/x/postgres/mod.ts";
const client = new Client({
user: "someuser",
database: "somedatabase",
hostname: "somehost",
password: "somepassword",
port: 5432,
});
await client.connect();
export default client;