如何使用typeorm访问“ information_schema”?

时间:2019-07-19 15:22:07

标签: typeorm

尝试使用typeorm查询information_schema,但失败了,如何使用typeorm访问此数据?

  

QueryFailedError:关系“ information_schema.columns”不存在

const rawData = await connection.query(`
SELECT
   COLUMN_NAME
FROM
   information_schema.COLUMNS
WHERE
   TABLE_NAME = 'members';
`);

1 个答案:

答案 0 :(得分:0)

必须修改查询:

const rawData = await connection.query(`
SELECT COLUMN_NAME 
FROM "information_schema"."columns" 
WHERE ("table_schema" = 'public' AND "table_name" = 'members')
`);

在这里https://wanago.io/2019/01/28/typeorm-migrations-postgres/