ReferenceError: users is not defined when trying to connect to postgres

ReferenceError: users is not defined when trying to connect to postgres

我一直在关注这个视频 https://www.youtube.com/watch?v=ufdHsFClAk0 并且在 32:54 当那个人得到结果时我得到了一个错误 ReferenceError: users is not defined。到目前为止,这是我的代码

const {Client} = require('pg')
const users = [{ id: 1 }] 
const client = new Client({
    user: "postgres",
    password: "testing",
    host: "BlackPearl",
    port: 5432,
    database: users
})

execute()

async function execute(){
    await client.connect()
    console.log("Connected")
    const results = await client.query("select * from users")
    console.table(results.rows)
    await client.end()
    console.log("Disconnected")
}

和here is what i see in pgAdmin4

那是我的 package.json

{
  "name": "expr",
  "version": "1.0.0",
  "description": "",
  "main": "experiment.js",
  "scripts": {
    "test": "node experiment.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pg": "^8.7.1"
  }
}

在终端我写 npm run test

改变这个:

const client = new Client({
    user: "postgres",
    password: "testing",
    host: "BlackPearl",
    port: 5432,
    database: users
})

对此:

const client = new Client({
    user: "postgres",
    password: "testing",
    host: "BlackPearl",
    port: 5432,
    database: 'users'
})

数据库名称应该是一个字符串,而不是一个引用,如果它被称为不同的(不是users)使用正确的名称